# Newton's Method Converges in Mathematica for non-convergent functions

In mathematica I set f[x_] := Sign[x] Sqrt[Abs[x]] and then I solved it in a root finding for Newton's method by doing FindRoot[f[x], {x, 1}, Method -> "Newton"] which returns {x -> 0.}. This is all fine and good as yes the root is obviously at f[0]; however, when iterating newton's method for $f(x)=\text{Sign}(x)\sqrt{|x|}$ for the initial value $x_0 = 1$ you get $x_{k+1} = x_{k} - \frac{f(x_k)}{f'(x_k)}$ which turns into $x_{k+1} = x_k-2\text{Sign}(x)|x|$. We would get $x_1 = 1 - 2*\text{Sign}(1)*|1| = -1$ then we get $x_2 = -1 - 2*\text{Sign}(-1) |-1| = -1 + 2 = 1$ and it obviously oscillates at $\pm 1$ but never converges to zero; yet mathematica converges this to 0 immediately, is there a way to truly iterate newton's method in Mathematica?

• interesting observation. We can surmise Method -> "Newton" is not strictly pure newton but has some tweak to avoid such oscillation. What exactly is the question though? You can implement it yourself obviously. – george2079 Oct 2 '15 at 21:00
• see here for diy implementations: mathematica.stackexchange.com/q/34229/2079 – george2079 Oct 2 '15 at 21:02
• Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. – bbgodfrey Oct 2 '15 at 21:02
• You can always write your own Newton-Raphson solver. It's not even a particularly difficult exercise. But why bother? The built-in solvers are better than anything you could write. – m_goldberg Oct 2 '15 at 21:32
• little correction, the linked page pertains to a modified newton method, but should give the idea. The other caveat here, mathematica does not nicely deal with analytic derivatives of Abs and Sign so it will take bit of work to show your exact oscillation result. – george2079 Oct 2 '15 at 21:42

Note that neither Sign nor Abs is differentiable so that Newton's Method may not be applied to the OP's problem in its given form.

Caveat: I am assuming this is a toy example, to show that the unadorned Newton's method fails on some functions. Normally, FindRoot uses step control to try to avoid certain common traps in using Newton's Method. One can turn off the protections with the option setting "StepControl" -> None as shown below.

Needs["OptimizationUnconstrainedProblems"]

FindRootPlot[Sign[x] Sqrt[Abs[x]], {x, 1},
Method -> {"Newton", "StepControl" -> None}]


If we define the functions in terms of differentiable functions, one can invoke Newton's Method successfully:

sign[x_] := Piecewise[{{1, x > 0}, {-1, x < 0}}, 0];
abs[x_] := Sqrt[x^2];
FindRootPlot[sign[x] Sqrt[abs[x]], {x, 1},
Method -> {"Newton", "StepControl" -> None}]


To see the steps, we can Sow and Reap them:

Reap@FindRoot[sign[x] Sqrt[abs[x]], {x, 1},
Method -> {"Newton", "StepControl" -> None}, StepMonitor :> Sow[x]]


The steps oscillate between ±1.

• Please replace sign[x] Sqrt[abs[x]] with uppercase letters. – user31001 Oct 3 '15 at 9:00
• @Willinski. Michael is defining special versions of those functions to make his point. The replacement you request would invalidate his answer. – m_goldberg Oct 3 '15 at 9:41
• @m_goldberg Oh, yes! My blind eyes! – user31001 Oct 3 '15 at 10:10