ROOTFINDING
Fixed Point Method
www.jesus-avalos.ucoz.com
ALGORITHM CODE:
FixedPointIteration[x0_,max_]:=Module[{},p0=N[x0];k=0;
Print["0 p=",PaddedForm[p0,{15,15}]];
While[k<max,Module[{},p1=g[p0];k=k+1;
Print[" p"k, "=", PaddedForm[p1,{15,15}]];
p0=p1;];];
p=p0;
Print[" "];
Print["The function is g[x]=", g[x]];
Print[" p=",PaddedForm[p,{15,15}]];
Print["g[p]=",PaddedForm[g[p],{15,15}]];];
EXAMPLE: x^3+x-1=0
g[x_]=(1-x)1/3
FixedPointIteration[0.5,12]
0 p= 0.500000000000000
p = 0.793700525984100
2 p = 0.590880113275177
3 p = 0.742363932168006
4 p = 0.636310203481661
5 p = 0.713800814144207
6 p = 0.659006145622400
7 p = 0.698632605730219
8 p = 0.670448496228072
9 p = 0.690729120589141
10 p = 0.676258924926827
11 p = 0.686645536864490
12 p = 0.679222339897004
13 p = 0.684544005469716
The function is g[x]= (1-x)1/3
p= 0.684544005469716
g[p]= 0.680737373803562
Plot[{x^3+x-1,(1-x)1/3, x},{x,0,1}]
|