#%config InlineBackend.figure_format = 'svg'
from pylab import *
The secant method approximates the function by an affine polynomial and finds the root of the polynomial. We can improve this method by constructing a quadratic polynomial approximation.
3.6.1 Muller’s method ¶ Given three initial guesses x 0 , x 1 , x 2 x_0, x_1, x_2 x 0 , x 1 , x 2 , construct a quadratic polynomial p ( x ) p(x) p ( x ) such that
p ( x i ) = f ( x i ) , i = 0 , 1 , 2 p(x_i) = f(x_i), \qquad i=0,1,2 p ( x i ) = f ( x i ) , i = 0 , 1 , 2 The next approximation to the root x 3 x_3 x 3 is taken as the root of p p p
p ( x 3 ) = 0 p(x_3) = 0 p ( x 3 ) = 0 We can write the Newton form of the interpolating polynomial[1]
p ( x ) = f ( x 2 ) + ( x − x 2 ) f [ x 2 , x 1 ] + ( x − x 2 ) ( x − x 1 ) f [ x 2 , x 1 , x 0 ] p(x) = f(x_2) + (x-x_2) f[x_2,x_1] + (x-x_2)(x-x_1) f[x_2,x_1,x_0] p ( x ) = f ( x 2 ) + ( x − x 2 ) f [ x 2 , x 1 ] + ( x − x 2 ) ( x − x 1 ) f [ x 2 , x 1 , x 0 ] or equivalently
p ( x ) = f ( x 2 ) + w ( x − x 2 ) + f [ x 2 , x 1 , x 0 ] ( x − x 2 ) 2 p(x) = f(x_2) + w(x-x_2) + f[x_2,x_1,x_0](x-x_2)^2 p ( x ) = f ( x 2 ) + w ( x − x 2 ) + f [ x 2 , x 1 , x 0 ] ( x − x 2 ) 2 where
w = f [ x 2 , x 1 ] + ( x 2 − x 1 ) f [ x 2 , x 1 , x 0 ] = f [ x 2 , x 1 ] + f [ x 2 , x 0 ] − f [ x 0 , x 1 ] w = f[x_2,x_1] + (x_2 - x_1) f[x_2,x_1,x_0] = f[x_2,x_1] + f[x_2,x_0] - f[x_0,x_1] w = f [ x 2 , x 1 ] + ( x 2 − x 1 ) f [ x 2 , x 1 , x 0 ] = f [ x 2 , x 1 ] + f [ x 2 , x 0 ] − f [ x 0 , x 1 ] Now find the root x 3 x_3 x 3 that is closest to x 2 x_2 x 2
x 3 − x 2 = − w ± w 2 − 4 f ( x 2 ) f [ x 2 , x 1 , x 0 ] 2 f [ x 2 , x 1 , x 0 ] x_3 - x_2 = \frac{-w \pm \sqrt{w^2 - 4f(x_2)f[x_2,x_1,x_0]}}{2f[x_2,x_1,x_0]} x 3 − x 2 = 2 f [ x 2 , x 1 , x 0 ] − w ± w 2 − 4 f ( x 2 ) f [ x 2 , x 1 , x 0 ] We have to choose the sign in the numerator that leads to small numerator. However this can lead to loss of significant figures. We can rewrite this as
x 3 = x 2 − 2 f ( x 2 ) w ± w 2 − 4 f ( x 2 ) f [ x 2 , x 1 , x 0 ] x_3 = x_2 - \frac{2 f(x_2)}{w \pm \sqrt{w^2 - 4 f(x_2) f[x_2,x_1,x_0]}} x 3 = x 2 − w ± w 2 − 4 f ( x 2 ) f [ x 2 , x 1 , x 0 ] 2 f ( x 2 ) Now we choose sign in denominator so that denominator is large in magnitude. We apply this algorithm recursively to obtain a sequence of iterates { x n } \{ x_n \} { x n } . If x n → α x_n \to \alpha x n → α and f ′ ( α ) ≠ 0 f'(\alpha) \ne 0 f ′ ( α ) = 0 , then α is a root of f f f . To prove this, show that
w → f ′ ( α ) w \to f'(\alpha) w → f ′ ( α ) so that in the limit the iteration looks like
α = α − 2 f ( α ) f ′ ( α ) ± [ f ′ ( α ) ] 2 − 4 f ( α ) f " ( α ) \alpha = \alpha - \frac{2 f(\alpha)}{f'(\alpha) \pm \sqrt{[f'(\alpha)]^2 - 4 f(\alpha) f"(\alpha)}} α = α − f ′ ( α ) ± [ f ′ ( α ) ] 2 − 4 f ( α ) f " ( α ) 2 f ( α ) But f ′ ( α ) ≠ 0 f'(\alpha) \ne 0 f ′ ( α ) = 0 and so the denominator is not zero, which implies that f ( α ) = 0 f(\alpha) = 0 f ( α ) = 0 .
The order of convergence p ≈ 1.84 p \approx 1.84 p ≈ 1.84 and is a root of
x 3 − x 2 − x − 1 = 0 x^3 - x^2 - x -1 = 0 x 3 − x 2 − x − 1 = 0 So this method converges faster than secant method but slower than Newton-Raphson method. Moreover
lim n → ∞ ∣ α − x n + 1 ∣ ∣ α − x n ∣ p = ∣ f ( 3 ) ( α ) 6 f ′ ( α ) ∣ ( p − 1 ) / 2 \lim_{n \to \infty} \frac{|\alpha - x_{n+1}|}{|\alpha - x_n|^p} = \left| \frac{f^{(3)} (\alpha)}{6f'(\alpha)} \right|^{(p-1)/2} n → ∞ lim ∣ α − x n ∣ p ∣ α − x n + 1 ∣ = ∣ ∣ 6 f ′ ( α ) f ( 3 ) ( α ) ∣ ∣ ( p − 1 ) /2 Muller’s method can give rise to complex roots even when starting with real initial guesses.
3.6.2 Inverse quadratic interpolation ¶ We treat x x x as a function of f f f , i.e., x = x ( f ) x = x(f) x = x ( f ) . Like in Muller’s method, let us take x 0 , x 1 , x 2 x_0, x_1,x_2 x 0 , x 1 , x 2 and f i = f ( x i ) f_i = f(x_i) f i = f ( x i ) , i = 0 , 1 , 2 i=0,1,2 i = 0 , 1 , 2 , but now construct an approximation
x = q ( f ; x 0 , x 1 , x 2 ) x = q(f; x_0,x_1,x_2) x = q ( f ; x 0 , x 1 , x 2 ) such that
x i = q ( f i ; x 0 , x 1 , x 2 ) , i = 0 , 1 , 2 x_i = q(f_i; x_0,x_1,x_2), \qquad i=0,1,2 x i = q ( f i ; x 0 , x 1 , x 2 ) , i = 0 , 1 , 2 Once the quadratic polynomial q q q is found, we estimate the root as
x 4 = q ( 0 ; x 0 , x 1 , x 2 ) x_4 = q(0; x_0,x_1,x_2) x 4 = q ( 0 ; x 0 , x 1 , x 2 ) This can be used to generate the iteration
x n + 1 = q ( 0 ; x n , x n − 1 , x n − 2 ) x_{n+1} = q(0; x_n, x_{n-1}, x_{n-2}) x n + 1 = q ( 0 ; x n , x n − 1 , x n − 2 ) Note that all the iterates will be real if we start with real initial guess.
3.6.3 Linear fractional method ¶ Suppose f ( x ) f(x) f ( x ) has a vertical and horizontal asymptote, e.g., f ( x ) = 1 x − a f(x) = \frac{1}{x} - a f ( x ) = x 1 − a . Then the secant method may not converge, see figure (xxx), where x 3 x_3 x 3 can go to − ∞ -\infty − ∞ . Instead of linear approximation, we can use a fractional approximation.
Given x 0 , x 1 , x 2 x_0, x_1, x_2 x 0 , x 1 , x 2 , fit a rational polynomial
g ( x ) = x − a b x − c g(x) = \frac{x - a}{bx - c} g ( x ) = b x − c x − a using
g ( x i ) = f ( x i ) , i = 0 , 1 , 2 g(x_i) = f(x_i), \qquad i=0,1,2 g ( x i ) = f ( x i ) , i = 0 , 1 , 2 The solution is simplified if we shift the origin, y = x − x 2 y = x - x_2 y = x − x 2 and
g ( y ) = y − a b y − c , g ( y i ) = f ( x i ) , i = 0 , 1 , 2 g(y) = \frac{y-a}{by-c}, \qquad g(y_i) = f(x_i), \quad i=0,1,2 g ( y ) = b y − c y − a , g ( y i ) = f ( x i ) , i = 0 , 1 , 2 The next approximation is x 3 = x 2 + a x_3 = x_2 + a x 3 = x 2 + a .