Approximating Roots of Equations Roots of single equations can always be written as solutions of the form f ( x) 0 . For example, if f ( x) ax 2 bx c 0 , there will be two possible roots given by b b 2 4ac . 2a But only polynomials to the fourth degree can be solved using algebraic operations. As an example of a more complicated case consider f ( x) tan x x 0 . x There are no algebraic solutions. The roots must be found numerically Roots by Bisection: For f ( x) 0 Bisection Algorithm Begin 1. Set n=0 2. Find a0 & b0 3. Set m=(an+bn)/2 4. If f(a0)f(m)<0 then an+1=an, bn+1=m Else an+1=m, bn+1= bn 5. End if 6. Set n=n+1 7. If |bn-an|>then Go to step 3 Else Root=(an+bn)/2 End if End Linear Interpolation By similar triangles x3 x1 0 f ( x1 ) x2 x1 f ( x2 ) f ( x1 ) or x3 x1 ( x2 x1 ) f ( x1 ) x f ( x2 ) x2 f ( x1 ) 1 f ( x2 ) f ( x1 ) f ( x2 ) f ( x1 ) Continuing x4 x2 f ( x3 ) x3 f ( x2 ) f ( x3 ) f ( x 2 ) Then xn 1 xn1 f ( xn ) xn f ( xn1 ) f ( xn ) f ( xn 1 ) Newton’s Method Using a Taylor series f ( x) f ( x0 ) ( x x0 ) f ' ( x0 ) Setting f ( x1 ) 0 , and using the Taylor series f ( x0 ) x1 x0 . f ' ( x0 ) Similarly f ( x1 ) x2 x1 f ' ( x1 ) and in general f ( xn ) xn1 xn f ' ( xn ) For example to find 2 use f ( x) x 2 2 0 . Then f ' ( x) 2 x and f ( xn ) x 2 2 xn xn 2 xn 2 xn 1 xn1 xn xn n f ' ( xn ) 2 xn 2 xn 2 xn 2 xn 2 2 2 2 Take x0 0 then x1 1 1 1.5 2 x2 0.75 0.666... 1.41666... x3 1.4142157 x4 1.412136 x5 1.412136 As a second example consider f ( x) e x 2 x 0 then f ' ( x) e x 2 . Take x0 0, f(x0 ) e 0 -2 0 1, f '(x0 ) e 0 -2 1 then 1 x1 0 1, f ( x1 ) e 2, f '( x1) e 2 then 1 x2 1 1 0 x3 1, x4 0, x5 1, ... As a last example consider f ( x) tan x x, f ' ( x) sec 2 x 1 tan 2 x . 1 3 Take x0 3.927 then x1 6.854, x2 21.92, x3 5,551, x4 18,700 ... 2 2 Convergence of Newton’s Method: We can write f ( xN ) xN 1 g ( xN ) xN . f ' ( xN ) If x r is a root, then f (r ) 0 and r g (r ) . The error can be found by subtracting, then x N 1 r g ( x N ) g (r ) , is the error. Performing a Taylor series expansion about x N r , 1 g ( x N ) g (r ) g ' (r )( x N r ) g ' ' ( )( x N r ) 2 2 f (r ) where r x N . We can find the terms using g (r ) r then f ' (r ) f ' (r ) f (r ) f ' ' (r ) f (r ) f ' ' (r ) g ' (r ) 1 0 f ' (r ) f ' (r )2 f ' (r )2 since f (r ) 0 . Hence 1 g ( x N ) g (r ) g ' ' ( )( x N r ) 2 2 Gives the error to second order as E N x N 1 r g ( x N ) g (r ) 1 g ' ' ( )( x N r ) 2 2 Fixed Point Iteration Sometimes is referred to as back substitution. Recall from Newton’s method that the root used xN 1 g ( xN ) and converged at the root r when r g (r ) , or at f (r ) r g (r ) 0 . As an example consider f ( x) x 2 2 x 3 0 1) The exact solution can be found by factoring. f ( x) ( x 3)( x 1) =0. Then the solutions are: x 1, 3 . 2) Choose x2 2x 3 or xN 1 2 xN 3 g ( xN ) . For x0 4 then x1 3.316, x2 3.104 x3 3.034, x4 3.011 x5 3.004, x6 3.001, ... 3) Writing f ( x) x( x 2) 3 0 then we can set xN 1 3 . xN 2 For x0 4 then x1 1.500, x2 6.000 x3 0.375, x4 1.263 x5 0.919, x6 1.028 x7 0.991, x8 1.003 4) Now try x N 1 2 xN 3 2 Again take x0 4 then x1 6.5 x2 19.635 x3 191.0 Convergence Criteria for Fixed Point Iteration For a root at r g (r ) and x N 1 g ( x N ) the error is x N 1 r g ( x N ) g (r ) By the mean value theorem g ' ( ) g ( x N ) g (r ) x N r xN r g ( x N ) g (r ) , where x N r (for x N r ). xN r Let eN x N r then eN 1 x N 1 r g ' ( )eN or eN 1 g ' ( ) eN . Hence e N 1 eN g ' ( ) and at the root eN 1 g ' (r ) eN Hence if g (x ) and g ' ( x ) are continuous in the interval about the root x r of x g (x ) , then x g (x) for N 1, 2, 3,... will converge to the root x r provided that x1 is chosen in an interval where g ' ( x) 1 . The condition is sufficient but not necessary. Convergence Criteria for Newton’s Method Recall that Newton’s method can be written as x N 1 x N f (xN ) g(xN ) . f ( x N ) Since g ' ( x) f ( x) f ' ' ( x) f ' ( x)2 convergence will occur when f ( x) f ' ' ( x) f ' ( x)2 when x r . 1 ,