Steffensen's method: Difference between revisions

Content deleted Content added
wlink
No edit summary
Line 17:
 
Similar to [[Newton's method]] and most other quadratically convergent methods, the crucial weakness with the method is the choice of the starting value <math>x_0</math>&nbsp;. If the value of <math>x_0</math> is not "close enough" to the actual solution, the method will fail and the sequence of values <math>x_0, x_1, x_2, x_3,\dots</math> will either flip flop between two extremes, or diverge to infinity (possibly both!).
 
==Implementation in Matlab==
 
Here is the source for an implementation of Steffensen's Method in [[MATLAB]].
 
<source lang="matlab">
function Steffensen(f,p0,tol)
% This function takes as inputs: a fixed point iteration function, f,
% and initial guess to the fixed point, p0, and a tolerance, tol.
% The fixed point iteration function is assumed to be input as an
% inline function.
% This function will calculate and return the fixed point, p,
% that makes the expression f(x) = p true to within the desired
% tolerance, tol.
 
format compact % This shortens the output.
format long % This prints more decimal places.
 
for i=1:1000 % get ready to do a large, but finite, number of iterations.
% This is so that if the method fails to converge, we won't
% be stuck in an infinite loop.
p1=f(p0); % calculate the next two guesses for the fixed point.
p2=f(p1);
p=p0-(p1-p0)^2/(p2-2*p1+p0) % use Aitken's delta squared method to
% find a better approximation to p0.
if abs(p-p0)<tol % test to see if we are within tolerance.
break % if we are, stop the iterations, we have our answer.
end
p0=p; % update p0 for the next iteration.
end
if abs(p-p0)>tol % If we fail to meet the tolerance, we output a
% message of failure.
'failed to converge in 1000 iterations.'
end
</source>
 
==Generalisation==