kill(all)$

maxima : plot fixed point iteration :find intersection (two curves. sqrt(2)),cvg,version 1.0
peter.vlasschaert@gmail.com,31/08/2022

used : fixed point iteration
⇒ finding the root of nonlinear equation , with start value = good guess.

How to draw graph :  plot2d
----------------------------
Menu :Plot → Plot2d-> 
first line : x,1/2*(x+2/x)
option : drop down menu

fixed point iteration :
================
x = g(x)  ,suppose r = root ,r =g(r)  → cvg : g'(x) < 1
......................................................................................
special case  (= root): g`(r)  < 1

p1:x;

→ Heron Formula : sqrt(2)

→ g(x)

p2:1/2*(x+2/x);

wxplot2d([1/2*(x+2/x),x], [x,0.9,2.0],
[gnuplot_postamble, "set size ratio 1; set zeroaxis;"])$

find : sqrt(2) ,intersect(p1,p2)

p3:solve(p1=p2,x);

→ numerical value

p3a:print(float(p3[2]))$

cvg :differentation : g'(x) < 1
------------------------------------

→ g'(x)

p4:'diff(p2,x) =diff(p2,x) ;

→ less than : root

p4a:subst([x=1.4],rhs(p4));

if p4a < 1 then  print( "then convergence for the solution ")$

→ the root : sqrt(2)

p4b:subst([p3a],rhs(p4));

if p4b < 1 then  print( "then convergence for the solution ")$

graphical : solution
-------------------------

wxplot2d([1/2*(x+2/x),x,rhs(p4)], [x,0.9,2.0],
[gnuplot_postamble, "set size ratio 1; set zeroaxis;"])$

rem :green part : g'(x)

How draw tangent line to blue curve :
============================

first step: definition tangent line .
-------------------------------------------

p5:y = m*(x-x0) + y0;

second step : point (x0,y0) to draw tangent line.
--------------------------------------------------------------

x0:float(sqrt(2));
y0:subst([x=x0],p2);

third step : m=slope linear equation.
------------------------------------------------

m:subst([x=x0],rhs(p4));

fourth: linear equation (form : y=ax+b).
----------------------------------------------------

p6:ev(p5,nouns);

p6a:rhs(p6);

final : graphical solution (for cvg).
----------------------------------------------

wxplot2d([1/2*(x+2/x),x,p6a], [x,0.9,2.0],
[gnuplot_postamble, "set size ratio 1; set zeroaxis;"])$

rem : fun3 (=green line): tangent line to blue curve (Heron Formula),see Maxima Document here.
reason cvg : green line below the red 

print ("cvg: g'(x)<1, green line always below red line")$

rem : r = root ,the cvg only in the neighbourhood of the intersection =r 
         ⇒ fixeed point iteration : r = g(r)
----------------------------------------------------------------------------------------------
intersection : three curves in the figure above.
----------------------------------------------------------------------------------------------