[Math] Newton’s Method: Found a case where it doesn’t work. Why

MATLABnewton raphsonnumerical methods

So I was looking to use Newton's Method to evaluate $x^3-2*x+2 = 0$.
I noticed that I could plug in a negative number for $x_0$ and it worked but when I tried $x_0 = 0$ then my code started going crazy and did not find the root. Anyone know why this does this, and how I can fix it? Thanks!

Best Answer

$$ x_{new} = x_{old} -\frac{x_{old}^3 -2x_{old} +2}{3x_{old}^2-2} $$ First iterations with $x_0$ $$ x_{1} = 0 -\frac{2}{-2} = 1\\ x_2 = 1 -\frac{1}{1} = 0 = x_0 $$ Thus you hit a limit cycle (attractor) where the values will just repeat.