Convergence of the Newton Method
>longestformat; iterate("(x+2/x)/2",2)
1.414213562373095
>iterate("(x+2/x)/2",2,6)
Column 1 to 2:
1.5 1.416666666666667
Column 3 to 4:
1.41421568627451 1.41421356237469
Column 5 to 6:
1.414213562373095 1.414213562373095
>h=~-1e-13,1e-13~
~-1e-013,1e-013~
>function f(x) &= (x+2/x)/2
2
x + -
x
-----
2
>x0=sqrt(2); res=mxmeval("f(x)",x=x0)+mxmeval("diff(f(x),x)",x=x0+h)*h
~1.4142135623730947,1.4142135623730951~
>res << x0+h
1
>mxmieval("(x+2/x)/2",x0+h)
~1.414213562373094,1.414213562373096~
>&expand(x - (x^2-2)/diff(x^2-2,x))
x 1
- + -
2 x
>mxminewton("x^2-2",~1,2~)
~1.4142135623730947,1.4142135623730954~
>&taylor(f(x),x,sqrt(2),2)
2
(x - sqrt(2))
-------------- + sqrt(2)
3/2
2
>&ratsimp(f(x)-sqrt(2))
2 3/2
x - 2 x + 2
---------------
2 x
>mxmnewton("x^3-2*x^2+x",2)
1.000000005479078
>function g(x) &= x^3-2*x^2+x
3 2
x - 2 x + x
>plot2d(mxm("g(x)"),0,2); insimg;

>iterate(&x-g(x)/diff(g(x),x),2,10)
Column 1 to 2:
1.6 1.347368421052632
Column 3 to 4:
1.193516663631397 1.104014284855782
Column 5 to 6:
1.054346842021409 1.027856158851746
Column 7 to 8:
1.014114290149139 1.007105915824406
Column 9 to 10:
1.003565448288775 1.001785885343114
>iterate(&x-2*g(x)/diff(g(x),x),2,10)
Column 1 to 2:
1.2 1.015384615384616
Column 3 to 4:
1.000115673799884 1.00000000668709
Column 5 to 6:
0.9999999734821227 1.000000002788999
Column 7 to 8:
1.000000002788999 1.000000002788999
Column 9 to 10:
1.000000002788999 1.000000002788999
>function dg(x) &= g(x)/diff(g(x),x)
3 2
x - 2 x + x
--------------
2
3 x - 4 x + 1
>plot2d(&dg(x),0.8,2); insimg;

>iterate(&x-dg(x)/diff(dg(x),x),2,10)
Column 1 to 2:
0.8888888888888888 0.9922480620155019
Column 3 to 4:
0.9999694833531766 0.9999999995340271
Column 5 to 6:
0.9999999995340271 0.9999999995340271
Column 7 to 8:
0.9999999995340271 0.9999999995340271
Column 9 to 10:
0.9999999995340271 0.9999999995340271
>t=1.000000001; polyval([0,1,-2,1],t)
0
>polyval(10^10*[0,1,-2,1],t)/10^10
0
>xpolyval(10^10*[0,1,-2,1],t)/10^10
1.000000166480752e-018
>&g(x) with x=1+1/100000000
100000001
-------------------------
1000000000000000000000000
>fpprec::=50; &bfloat(g(x)) with x=1.000000001b0
1.0000000010000000000000000000000006141818534508651b-18
>function g(x) := xpolyval(10^10*[0,1,-2,1],x)/10^10
>function dg(x) &= diff(g(x),x)
2
3 x - 4 x + 1
>iterate("x-2*g(x)/dg(x)",2,5)
Column 1 to 2:
1.2 1.015384615384616
Column 3 to 4:
1.000115673799888 1.000000006689053
Column 5:
1
>function h(x) &= expand(subst(x+1,x,g(x)))
3 2
x + x
>iterate(&x-2*h(x)/diff(h(x),x),1,5)
Column 1 to 2:
0.2 0.01538461538461536
Column 3 to 4:
0.0001156737998843256 6.689053367505012e-009
Column 5:
2.23717167432336e-017
Examples Homepage