Newton’s method (and fixed point) example

f[x_]:=x^2-x-2
g1[x_]:=x^2-2
g2[x_]:=Sqrt[2+x]
g3[x_]:=1+2/x
m=f'[2]; (* here's an idea so that you don't need to keep re-evaluating the derivative *)
g4[x_]:=x-f[x]/m
g5[x_]:=x-f[x]/f'[x]
Iterate[x_]:=N[{g1[x[[1]]],g2[x[[2]]],g3[x[[3]]],g4[x[[4]]],g5[x[[5]]]}]

Let’s run a competition between the methods:

vals={4,4,4,4,4};
i=0
Its=10
While[i<Its,i=i+1;vals=Iterate[vals];Print[vals]]

Now it’s the derivatives that should drive convergence, and then speed of convergence:

Plot[{g1[x],g2[x],g3[x],g4[x],g5[x],x,f[x]},{x,0,4}]

{g1'[2],g2'[2],g3'[2],g4'[2],g5'[2]}

Let’s see what interesting things happen when we use negative (-4) starting values:

vals=-{4,4,4,4,4};
i=0
Its=10
While[i<Its,i=i+1;vals=Iterate[vals];Print[vals]]

Plot[{g1[x],g2[x],g3[x],g4[x],g5[x],x,f[x]},{x,-4,4}]

{g1'[-1],g2'[-1],g3'[-1],g4'[-1],g5'[-1]}