Steffensen's method

From HandWiki
Short description: Newton-like root-finding algorithm that does not use derivatives

In numerical analysis, Steffensen's method is a root-finding technique named after Johan Frederik Steffensen which is similar to Newton's method. Steffensen's method also achieves quadratic convergence, but without using derivatives as Newton's method does.

Simple description

The simplest form of the formula for Steffensen's method occurs when it is used to find a zero of a real function f; that is, to find the real value [math]\displaystyle{ x_\star }[/math] that satisfies [math]\displaystyle{ f(x_\star) = 0 . }[/math] Near the solution [math]\displaystyle{ x_\star, }[/math] the function [math]\displaystyle{ f }[/math] is supposed to approximately satisfy [math]\displaystyle{ -1 \lt f'(x_\star) \lt 0 ; }[/math] this condition makes [math]\displaystyle{ ~ f ~ }[/math] adequate as a correction-function for [math]\displaystyle{ ~ x ~ }[/math] for finding its own solution, although it is not required to work efficiently. For some functions, Steffensen's method can work even if this condition is not met, but in such a case, the starting value [math]\displaystyle{ ~ x_0 ~ }[/math] must be very close to the actual solution [math]\displaystyle{ ~ x_\star ~, }[/math] and convergence to the solution may be slow.

Given an adequate starting value [math]\displaystyle{ ~ x_0 ~, }[/math] a sequence of values [math]\displaystyle{ ~ x_0, \, x_1, \, x_2, \dots, \, x_n, \, \dots ~ }[/math] can be generated using the formula below. When it works, each value in the sequence is much closer to the solution [math]\displaystyle{ ~ x_\star ~ }[/math] than the prior value. The value [math]\displaystyle{ ~ x_n ~ }[/math] from the current step generates the value [math]\displaystyle{ ~ x_{n+1} ~ }[/math] for the next step, via this formula:[1]

[math]\displaystyle{ x_{n+1} = x_n - \frac{\, f(x_n) \,}{g(x_n)} ~ }[/math]

for [math]\displaystyle{ n = 0, 1, 2, 3, ... ~; }[/math] where the slope function [math]\displaystyle{ ~ g(x) ~ }[/math] is a composite of the original function [math]\displaystyle{ ~ f ~ }[/math] given by the following formula:

[math]\displaystyle{ g(x) = \frac{\, f\bigl( x + f(x) \bigr) \,}{f(x)} - 1 ~ }[/math]

or perhaps more clearly,

[math]\displaystyle{ g(x) = \frac{\, f(x + h) - f(x) \,}{h} ~ }[/math]

where [math]\displaystyle{ ~ h = f(x) ~ }[/math] is a step-size between the last iteration point, x, and an auxiliary point located at [math]\displaystyle{ ~ x + h~. }[/math]

The function [math]\displaystyle{ ~ g ~ }[/math] is the average value for the slope of the function [math]\displaystyle{ f }[/math] between the last sequence point [math]\displaystyle{ ~ \left( x, y \right) = \bigl( x_n, \, f\left( x_n \right) \bigr) ~ }[/math] and the auxiliary point [math]\displaystyle{ ~ \bigl(x,y\bigr)=\bigl( x_n + h, \, f\left( x_n + h \right) \, \bigr) ~, }[/math] with the step [math]\displaystyle{ ~ h = f(x_n) ~. }[/math] It is also called the first-order divided difference of [math]\displaystyle{ ~ f ~ }[/math] between those two points.

It is only for the purpose of finding [math]\displaystyle{ ~ h ~ }[/math] for this auxiliary point that the value of the function [math]\displaystyle{ ~ f ~ }[/math] must be an adequate correction to get closer to its own solution, and for that reason fulfill the requirement that [math]\displaystyle{ ~ -1 \lt f'(x_\star) \lt 0 ~. }[/math] For all other parts of the calculation, Steffensen's method only requires the function [math]\displaystyle{ ~ f ~ }[/math] to be continuous and to actually have a nearby solution.[1] Several modest modifications of the step [math]\displaystyle{ ~ h ~ }[/math] in the slope calculation [math]\displaystyle{ ~ g ~ }[/math] exist to accommodate functions [math]\displaystyle{ ~ f ~ }[/math] that do not quite meet the requirement.

Advantages and drawbacks

The main advantage of Steffensen's method is that it has quadratic convergence[1] like Newton's method – that is, both methods find roots to an equation [math]\displaystyle{ ~ f ~ }[/math] just as 'quickly'. In this case quickly means that for both methods, the number of correct digits in the answer doubles with each step. But the formula for Newton's method requires evaluation of the function's derivative [math]\displaystyle{ ~ f' ~ }[/math] as well as the function [math]\displaystyle{ ~ f ~, }[/math] while Steffensen's method only requires [math]\displaystyle{ ~ f ~ }[/math] itself. This is important when the derivative is not easily or efficiently available.

The price for the quick convergence is the double function evaluation: Both [math]\displaystyle{ ~ f(x_n) ~ }[/math] and [math]\displaystyle{ ~ f(x_n + h) ~ }[/math] must be calculated, which might be time-consuming if [math]\displaystyle{ ~ f ~ }[/math] is a complicated function. For comparison, the secant method needs only one function evaluation per step. The secant method increases the number of correct digits by "only" a factor of roughly 1.6 per step, but one can do twice as many steps of the secant method within a given time. Since the secant method can carry out twice as many steps in the same time as Steffensen's method,[lower-alpha 1] when both algorithms succeed, the secant method actually converges faster than Steffensen's method in practical use: The secant method achieves a factor of about (1.6)2 ≈ 2.6 times as many digits for every two steps (two function evaluations), compared to Steffensen's factor of 2 for every one step (two function evaluations).

Similar to most other iterative root-finding algorithms, the crucial weakness in Steffensen's method is the choice of the starting value [math]\displaystyle{ ~ x_0 ~. }[/math] If the value of [math]\displaystyle{ ~ x_0 ~ }[/math] is not 'close enough' to the actual solution [math]\displaystyle{ ~ x_\star ~, }[/math] the method may fail and the sequence of values [math]\displaystyle{ ~ x_0, \, x_1, \, x_2, \, x_3, \, \dots ~ }[/math] may either flip-flop between two extremes, or diverge to infinity, or both.

Derivation using Aitken's delta-squared process

The version of Steffensen's method implemented in the MATLAB code shown below can be found using the Aitken's delta-squared process for accelerating convergence of a sequence. To compare the following formulae to the formulae in the section above, notice that [math]\displaystyle{ x_n = p \, - \, p_n ~. }[/math] This method assumes starting with a linearly convergent sequence and increases the rate of convergence of that sequence. If the signs of [math]\displaystyle{ ~ p_n, \, p_{n+1}, \, p_{n+2} ~ }[/math] agree and [math]\displaystyle{ ~ p_n ~ }[/math] is 'sufficiently close' to the desired limit of the sequence [math]\displaystyle{ ~ p ~, }[/math] we can assume the following:

[math]\displaystyle{ \frac{\, p_{n+1} - p \,}{\, p_n - p \,} ~ \approx ~ \frac{\, p_{n+2} - p \,}{\, p_{n+1} - p \,} }[/math]

then

[math]\displaystyle{ ( p_{n+1} - p)^2 ~ \approx ~ (\, p_{n+2} - p \,)\,(\, p_n - p \, ) ~ }[/math]

so

[math]\displaystyle{ p_{n+1}^2 - 2 \, p_{n+1} \, p + p^2 ~ \approx ~ p_{n+2} \; p_n - (\, p_n + p_{n+2} \,) \, p + p^2 }[/math]

and hence

[math]\displaystyle{ (\, p_{n+2} - 2 \, p_{n+1} + p_n \,) \, p ~ \approx ~ p_{n+2} \, p_n - p_{n+1}^2 ~. }[/math]

Solving for the desired limit of the sequence [math]\displaystyle{ ~ p ~ }[/math] gives:

[math]\displaystyle{ p ~ \approx ~ \frac{\, p_{n+2} \, p_n - p_{n+1}^2 \,}{\, p_{n+2} - 2 \, p_{n+1} + p_n \,} ~=~ \frac{\, p_{n}^2 + p_{n} \, p_{n+2} + 2 \, p_{n} \, p_{n+1} - 2 \, p_{n} \, p_{n+1} - p_{n}^2 - p_{n+1}^2 \,}{\, p_{n+2} - 2 \, p_{n+1} + p_n \,} }[/math]
[math]\displaystyle{ =~ \frac{\, (\, p_{n}^2 + p_{n} \, p_{n+2} - 2 \, p_{n} \, p_{n+1} \,) - (\, p_{n}^2 - 2 \, p_{n} \, p_{n+1} + p_{n+1}^2 \, ) \, }{\, p_{n+2} - 2 \, p_{n+1} + p_n \,} }[/math]
[math]\displaystyle{ =~ p_n - \frac{\,(\, p_{n+1} - p_n )^2 \,}{\, p_{n+2} - 2 \, p_{n+1} + p_n \,} ~, }[/math]

which results in the more rapidly convergent sequence:

[math]\displaystyle{ p ~ \approx ~ p_{n+3} ~=~ p_n - \frac{ \, ( \, p_{n+1} - p_n \, )^2 \, }{ \, p_{n+2} - 2 \, p_{n+1} + p_n \,} ~. }[/math]

Code example

In Matlab

Here is the source for an implementation of Steffensen's Method in 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

In Python

Here is the source for an implementation of Steffensen's Method in Python.

from typing import Callable, Iterator
Func = Callable[[float], float]

def g(f: Func, x: float, fx: float) -> Func:
    """First-order divided difference function.

    Arguments:
        f: Function input to g
        x: Point at which to evaluate g
        fx: Function f evaluated at x 
    """
    return lambda x: f(x + fx) / fx - 1

def steff(f: Func, x: float) -> Iterator[float]:
    """Steffenson algorithm for finding roots.

    This recursive generator yields the x_{n+1} value first then, when the generator iterates,
    it yields x_{n+2} from the next level of recursion.

    Arguments:
        f: Function whose root we are searching for
        x: Starting value upon first call, each level n that the function recurses x is x_n
    """
    while True:    
        fx = f(x)
        gx = g(f, x, fx)(x)
        if gx == 0:
            break
        else:
            x = x - fx / gx    # Update to x_{n+1}
            yield x            # Yield value

Generalization

Steffensen's method can also be used to find an input [math]\displaystyle{ ~ x = x_\star ~ }[/math] for a different kind of function [math]\displaystyle{ ~F~ }[/math] that produces output the same as its input: [math]\displaystyle{ ~ x_\star = F(x_\star) ~ }[/math] for the special value [math]\displaystyle{ ~ x_\star ~. }[/math] Solutions like [math]\displaystyle{ ~ x_\star ~ }[/math] are called fixed points. Many of these functions can be used to find their own solutions by repeatedly recycling the result back as input, but the rate of convergence can be slow, or the function can fail to converge at all, depending on the individual function. Steffensen's method accelerates this convergence, to make it quadratic.

For orientation, the root function [math]\displaystyle{ ~f~ }[/math] and the fixed-point functions are simply related by [math]\displaystyle{ ~ F(x) = x + \varepsilon \,f(x) ~, }[/math] where [math]\displaystyle{ ~ \varepsilon ~ }[/math] is some scalar constant small enough in magnitude to make [math]\displaystyle{ ~F~ }[/math] stable under iteration, but large enough for the non-linearity of the function [math]\displaystyle{ ~f~ }[/math] to be appreciable. All issues of a more general Banach space vs. basic real numbers being momentarily ignored for the sake of the comparison.

This method for finding fixed points of a real-valued function has been generalised for functions [math]\displaystyle{ ~ F : X \to X ~ }[/math] that map a Banach space [math]\displaystyle{ ~ X ~ }[/math] onto itself or even more generally [math]\displaystyle{ ~ F : X \to Y ~ }[/math] that map from one Banach space [math]\displaystyle{ ~ X ~ }[/math] into another Banach space [math]\displaystyle{ ~ Y ~. }[/math] The generalized method assumes that a family of bounded linear operators [math]\displaystyle{ ~ \{\; L(u,v): u, v \in X \;\} ~ }[/math] associated with [math]\displaystyle{ ~ u ~ }[/math] and [math]\displaystyle{ ~ v ~ }[/math] can be devised that (locally) satisfies that condition.[2]

[math]\displaystyle{ F\left( u \right) - F\left( v \right) = L\left( u, v \right) \, \bigl[\, u - v \,\bigr] ~. \qquad\qquad\qquad\qquad ~ }[/math]eqn. (𝄋)

If division is possible in the Banach space, the linear operator [math]\displaystyle{ ~L~ }[/math] can be obtained from

[math]\displaystyle{ L\left( u, v \right) = \bigl[\, F\left( u \right)- F\left( v \right) \,\bigr] \bigl[\, u - v \,\bigr]^{-1} ~, }[/math]

Which may provide some insight. (The quotient form is shown for orientation; it is not required per se.) Expressed in this way, the linear operator [math]\displaystyle{ ~ L ~ }[/math] can be more easily seen to be an elaborate version of the divided difference [math]\displaystyle{ ~ g ~ }[/math] discussed in the first section, above. Note that the division is not necessary; the only requirement is that the operator [math]\displaystyle{ ~ L ~ }[/math] satisfy the equation marked with the segno, (𝄋).

For the basic real number function [math]\displaystyle{ ~ f ~ }[/math], given in the first section, the function simply takes in and puts out real numbers. There, the function [math]\displaystyle{ ~ g ~ }[/math] is a divided difference. In the generalized form here, the operator [math]\displaystyle{ ~ L ~ }[/math] is the analogue of a divided difference for use in the Banach space. The operator [math]\displaystyle{ ~ L ~ }[/math] is roughly equivalent to a matrix whose entries are all functions of vector arguments [math]\displaystyle{ ~ u ~ }[/math] and [math]\displaystyle{ ~ v ~ }[/math].

Steffensen's method is then very similar to the Newton's method, except that it uses the divided difference [math]\displaystyle{ ~ L \bigl( \, F\left( x \right), \, x \,\bigr) ~ }[/math] instead of the derivative [math]\displaystyle{ ~ F'(x) ~. }[/math] Note that for fixed point functions, [math]\displaystyle{ ~ F ~ }[/math] and for linear operators [math]\displaystyle{ ~ L ~ }[/math] meeting the marked (𝄋) condition, [math]\displaystyle{ ~ F'(x) \approx L \bigl( \, F\left( x \right), \, x \,\bigr) \approx I~, }[/math] where [math]\displaystyle{ ~I~ }[/math] is the identity operator.

The generalized iteration formula is given by

[math]\displaystyle{ x_{n+1} = x_n + \Bigl[ I - L\bigl( F\left( x_n \right), x_n \bigr) \Bigr]^{-1}\Bigl[ F\left( x_n \right) - x_n \Bigr] ~, }[/math]

for [math]\displaystyle{ ~n = 1,\,2,\,3,\,... ~. }[/math]

If the operator [math]\displaystyle{ ~ L ~ }[/math] satisfies

[math]\displaystyle{ \Bigl\| L \left( u, v \right) - L \left( x, y \right) \Bigr\| \le k \biggl( \Bigl\|u - x \Bigr\| + \Bigr\| v - y \Bigr\| \biggr) ~ }[/math]

for some constant [math]\displaystyle{ ~ k ~, }[/math] then the method converges quadratically to a fixed point of [math]\displaystyle{ F }[/math] if the initial approximation [math]\displaystyle{ ~ x_0 ~ }[/math] is 'sufficiently close' to the desired solution [math]\displaystyle{ ~ x_\star ~, }[/math] that satisfies [math]\displaystyle{ ~ x_\star = F(x_\star) ~. }[/math]

Notes

  1. Because [math]\displaystyle{ ~ f( x_n + h )~ }[/math] requires the prior calculation of [math]\displaystyle{ ~ h = f(x_n) ~, }[/math] the two evaluations must be done sequentially – the algorithm per se cannot be made faster by running the function evaluations in parallel. This is yet another disadvantage of Steffensen's method.

References

  1. 1.0 1.1 1.2 Numerical Methods. Englewood Cliffs, NJ: Prentice Hall. 1974. pp. 230–231. https://archive.org/details/numericalmethods00dahl. 
  2. Johnson, L.W.; Scholz, D.R. (June 1968). "On Steffensen's method". SIAM Journal on Numerical Analysis 5 (2): 296–302. doi:10.1137/0705026.