Digits:=16;f:=x->x^3-x^2-x-1;The exact solution of x^3-x^2-x-1=0:psol:=fsolve(f(x)=0,x);g:=x->x-0.1*f(x);p:=array(0..20);# Construct the array of p-values.
p[0]:=0:
for i from 1 to 20 do
p[i]:=evalf(g(p[i-1])):
end:lambda:=array(1..20);for i from 1 to 20 do
lambda[i]:=(p[i]-psol)/(p[i-1]-psol);
end do;The values do indeed seem to be converging to 0.45...
Since (p[n]-p)/(p[n-1]-p) seems to converge to a limit, the sequence p[n] seems to be order 1.Steff:=array(0..20):# For Steffensen's algorithm, we compute two steps of the iteration, then use Aitken's method to accelerate.
Steff[0]:=0:
for i from 1 to 10 do
pold1:=Steff[i-1]:
pold2:=evalf(g(pold1)):
pold3:=evalf(g(pold2)):
Steff[i]:=pold1-(pold2-pold1)^2/(pold3-2*pold2+pold1):
print(Steff[i]):
end do:for i from 1 to 10 do
ratio:=(Steff[i]-psol)/(Steff[i-1]-psol)^2:
end do;Looks like it's approaching 0.37 or so, but the roundoff error in the last couple steps is pretty bad.