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?

  • 2
    $\begingroup$ 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. $\endgroup$ – george2079 Oct 2 '15 at 21:00
  • $\begingroup$ see here for diy implementations: mathematica.stackexchange.com/q/34229/2079 $\endgroup$ – george2079 Oct 2 '15 at 21:02
  • $\begingroup$ 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. $\endgroup$ – bbgodfrey Oct 2 '15 at 21:02
  • $\begingroup$ 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. $\endgroup$ – m_goldberg Oct 2 '15 at 21:32
  • $\begingroup$ 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. $\endgroup$ – 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.


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

Mathematica graphics

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}]

Mathematica graphics

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]]

Mathematica graphics

The steps oscillate between ±1.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.