# Are these results reliable to make sure that there is a root in FindRoot?

I want to use FindRoot for a 3-variable equation to make sure if there is a root around the point $$\{x,2.356\},\{y,0.2\},\{z,0.802\}$$


f := 16 ((-1 + x^2) Cos[z] Cosh[2.941592653589793 x] +
2 x Sin[z] Sinh[2.941592653589793 x]) Sinh[π x] +
8 (-1 + x^2) Sinh[x y] + (-3 + x^2)^2 Sinh[
x (2 π + y)] - (1 +
x^2)^2 (2 Cosh[5.883185307179586 x] Sinh[x y] +
Sinh[2 π x - x y]);
der = D[f, {{x, y, z}}];

FindRoot[der == {0, 0, 0}, {{x, 2.356}, {y, 0.2}, {z, 0.802}}];
res = {x, y, z} /. %
f /. %%


The result is

{2.35652, 0.2, 0.802647}

-1.49012*10^-8

Then, when I increase working precision, I get

FindRoot[der == {0, 0, 0}, {{x, 2.356}, {y, 0.2}, {z, 0.802}},
WorkingPrecision -> 32];
res = {x, y, z} /. %
f /. %%


During evaluation of In[134]:= FindRoot::precw: The precision of the argument function ({<<1>>}=={0,0,0}) is less than WorkingPrecision (32.). >>

{2.3565200441011191861934980908179,
0.20000007532203647354553006825369, 0.80264668264222070286493054169596}

Then, does this mean that there is a root at this point? In general, when without increasing precision I get the result $$-\text{1.4901161193847656\grave{ }*{}^{\wedge}-8}$$, does this show that there is a root there? Or, the result must be exactly zero?

• If a continuous function crosses from negative to positive then there must be a root. If you redefine f as a function f[x_,y_,z_] :=...; and apply f @@@ RandomPoint[Sphere[{2.35652, 0.2, 0.802647}, 10^-5], 100] you see both negative and positive values meaning it must equal exactly zero in the vicinity of your approximate root. – flinty Sep 18 at 11:12
• @charmin yes that much is clear and Ulrich's answer shows there are in fact many roots at all points along the contours shown. The only concern I have is whether those contours connect at a point, and plotting would not be adequate to show this. Have a look at the gradient nearby - it's close to zero. Norm[Grad[f[x, y, z], {x, y, z}]] /. {x -> 2.3565200441011191861934980908179, y -> 0.200000075322036473545530068253690, z -> 0.80264668264222070286493054169596}. Unfortunately I don't know how to prove they are connected or otherwise. – flinty Sep 18 at 15:39
• Because of round-off error in floating-point computations of the value of f[], you can only be confident there is (probably) a root, but never completely sure. In fact, given the round-off error in the coefficients of f, the function f and its derivative probably do not simultaneously vanish exactly. They appear very close to doing so, though. I would say it's close enough, but whether one should accept it really depends on how the result is being used. I would accept it because the problem as posed is approximate and I wouldn't insist on exact answers. – Michael E2 Sep 18 at 19:21
• @charmin: Why don't you tell the whole story? Why you concealed the exact expressions of numeric constants? N[\[Pi] - 1/5, 16] == 2.941592653589793 N[2 (\[Pi] - 1/5), 16] == 5.883185307179586 – azerbajdzan Sep 18 at 21:50
• Of course it does effect the result. If you replace exact numbers with rounded then the location of the root is shifted or in extreme situations the root can disappear. – azerbajdzan Sep 20 at 15:41

If you want to use higher precision, you must start with higher precision, preferably exact numbers. So, define:

rf = Rationalize[f, 0];
der = D[rf, {{x, y, z}}]


{8 (-1 + x^2) y Cosh[x y] + (-3 + x^2)^2 (2 π + y) Cosh[ x (2 π + y)] + 16 [Pi] Cosh[π x] ((-1 + x^2) Cos[z] Cosh[(455324788 x)/154788525] + 2 x Sin[z] Sinh[(455324788 x)/154788525]) + 16 (2 x Cos[z] Cosh[(455324788 x)/154788525] + ( 910649576 x Cosh[(455324788 x)/154788525] Sin[z])/154788525 + ( 455324788 (-1 + x^2) Cos[z] Sinh[(455324788 x)/154788525])/154788525 + 2 Sin[z] Sinh[(455324788 x)/154788525]) Sinh[π x] + 16 x Sinh[x y] - (1 + x^2)^2 (2 y Cosh[(439301571 x)/74670701] Cosh[x y] + (2 π - y) Cosh[ 2 π x - x y] + (878603142 Sinh[(439301571 x)/74670701] Sinh[x y])/ 74670701) + 4 x (-3 + x^2) Sinh[x (2 π + y)] - 4 x (1 + x^2) (2 Cosh[(439301571 x)/74670701] Sinh[x y] + Sinh[2 π x - x y]), 8 x (-1 + x^2) Cosh[x y] + x (-3 + x^2)^2 Cosh[ x (2 π + y)] - (1 + x^2)^2 (2 x Cosh[(439301571 x)/74670701] Cosh[x y] - x Cosh[2 π x - x y]), 16 (-(-1 + x^2) Cosh[(455324788 x)/154788525] Sin[z] + 2 x Cos[z] Sinh[(455324788 x)/154788525]) Sinh[π x]}

Then:

sol = FindRoot[der == 0, {{x,2.356},{y,0.2},{z,0.802}}, WorkingPrecision->200]


{x -> 2.3565200441011186709479266836966473183706054854973247601995119877870636
873150981603534010380380229088216334276519966737386820565998325159972020265215
769197743462707338573100057289170401368873924927438, y -> 0.2000000753220364175594993792946585546227992037510471951779256130489297
718727007710657410091878518650360468748052551939442488448945437837928513056149
4115966055206357301610091169316475826091182043682335, z -> 0.8026466826422208601123250913908771602390415263594677011546158692691200
931397804694020271251338364935933644231667289502052519001113569885205311394434
5785707885603139180848781503142732797464512115412727}

Check:

der /. sol


{0.*10^-190, 0.*10^-191, 0.*10^-192}

Here are equations with exact values:

f := 16 ((-1 + x^2) Cos[z] Cosh[(π - 1/5) x] +
2 x Sin[z] Sinh[(π - 1/5) x]) Sinh[π x] +
8 (-1 + x^2) Sinh[x y] + (-3 + x^2)^2 Sinh[x (2 π + y)] -
(1 + x^2)^2 (2 Cosh[2 (π - 1/5) x] Sinh[x y] + Sinh[2 π x - x y]);
der = D[f, {{x, y, z}}];

der == {0, 0, 0}


System of equations der == {0, 0, 0} has the following roots over $$\mathbb{R}$$:

$$\{x, y, z\}=\{0,k_1,2 k_2 \pi\}$$

$$\{x, y, z\}=\{\pm 2.8448343088, 0.8102330214, 3.8176390865 + 2 k \pi\}$$

$$\{x, y, z\}=\{\pm 0.4832801868, -6.3281385527, 2.2986319740 + 2 k \pi\}$$

$$\{x, y, z\}=\{\pm 1.1070908912, 1.8252125391, 1.4689358773 + 2 k \pi\}$$

$$\{x, y, z\}=\{\pm 2.0949603042, 0.1045460795, 0.8907008338 + 2 k \pi\}$$

$$\{x, y, z\}=\{\pm 2.3565200441, 0.2000000753, 0.8026466826 + 2 k \pi\}$$

$$k_1,k_2,k \in \mathbb{Z}$$

I found these roots analytically, hopefully they are all.

There might be roots over $$\mathbb{C}$$ as well, I do not have time for that.

In these plots we can see x coordinates of roots:

ContourPlot3D shows ( see @flinty 's comment) you, that there doesn't exist a pointwise solution near { 2.356 , 0.2 , 0.802 }

f[x_, y_, z_] :=16 ((-1 + x^2) Cos[z] Cosh[2.941592653589793 x] +
2 x Sin[z] Sinh[2.941592653589793 x]) Sinh[\[Pi] x] +8 (-1 + x^2) Sinh[x y] + (-3 + x^2)^2 Sinh[x (2 \[Pi] + y)] - (1 + x^2)^2 (2 Cosh[5.883185307179586 x] Sinh[x y] +Sinh[2 \[Pi] x - x y])

Show[{ContourPlot3D[f[x, y, z] == 0, {x, 2, 3}, {y, 0, 1}, {z, 0, 1}],
Graphics3D[{PointSize[.02], Red, Point[{ 2.356 , 0.2 , 0.802 }]}]}]


• there doesn't exist a pointwise solution ... don't you mean there does exist a solution? If you use more and more PlotPoints then those two contours get closer until they touch at a point. – flinty Sep 18 at 13:54
• @flinty Thanks. I wanted to mention that his answer does not confirm your comment. – charmin Sep 18 at 13:59
• @flinty All the plotted points fullfill f[x,y,z]==0` – Ulrich Neumann Sep 18 at 14:15
• @UlrichNeumann yes I know. But what proves that there doesn't exist a pointwise solution. As far as I can tell, in the limit as PlotPoints goes to infinity and the mesh resolution improves, the two contours should get closer until they touch and meet at a point in very close to the solution in the question. – flinty Sep 18 at 14:41
• @UlrichNeumann maybe I misinterpreted pointwise, or maybe it's because you wrote doesn't exist in your answer (is this a typo?). Based on Carl's answer it looks like there's a special solution where the two surfaces in your answer join and where the gradient is zero. – flinty Sep 19 at 11:11