“Teach A Level Maths” Vol. 2: A2 Core Modules 19: Newton-Raphson Iteration © Christine Crisp Newton-Raphson Iteration Module C3 MEI/OCR "Certain images and/or photos on this presentation are the copyrighted property of JupiterImages and are being used with permission under license. These images and/or photos may not be copied or downloaded without permission from JupiterImages" Newton-Raphson Iteration It isn’t always possible to find iterative formulae of the type x n1 g( x n ) that will find the solution of every equation. Another iterative method that is useful is called the Newton-Raphson method. Newton-Raphson Iteration Suppose we want to find an approximate solution to the equation f ( x) 0 To see how the method works, we’ll sketch using f ( x ) x 3 x 1 . The root lies between 1 and 2. We’ll zoom in near y f ( x) y f ( x) Newton-Raphson Iteration y f (x ) x2 x1 x0 Suppose our first estimate is given by x 0 2 . We draw the tangent to the curve at x 0 The point where the tangent meets the x-axis we call x1 . Repeating . . . Each point x1 , x 2 , . . . is closer to . Newton-Raphson Iteration To carry out the iteration we need to find the points where the tangents meet the x-axis. ( x 0 , y 0 )x y0 y f (x ) x 0 x1 x1 The grad. of the tangent x0 the change in y the change in x y0 dy at x 0 dx x 0 x1 Newton-Raphson Iteration y0 dy and we need to find x . at x 0 1 dx x 0 x1 dy Using y 0 and at x 0 in the formula isn’t very dx convenient, so, since y f ( x ) we have y dy 0 and y0 f ( x0 ) at x 0 f / ( x0 ) dx x 0 x1 Then, f ( x0 ) / f ( x0 ) x 0 x1 f ( x0 ) f ( x0 ) Rearranging: x 0 x1 / x1 x 0 / f ( x0 ) f ( x0 ) We have Newton-Raphson Iteration So, x1 x 0 f ( x0 ) f / ( x0 ) We just need to alter the subscripts to find x 2 x1 Generalising gives x n 1 x n x2 : f ( x1 ) f / ( x1 ) f ( xn ) f / ( xn ) We don’t need a diagram to use this formula but we must know how to differentiate f ( x ) . Convergence is often very fast. Newton-Raphson Iteration e.g. Use the Newton-Raphson method with x 0 2 to find the root of the equation x x 1 0 3 correct to 4 d.p. Solution: Let Differentiate: x n 1 x n f ( x) x 3 x 1 f / ( x) 3 x 2 1 f ( xn ) / f ( xn ) 3 x n 1 x n ( 3 x n 1) 2, ENTER 3 (ANS ANS 1) ANS ( 3ANS 2 1) x 1 6180 ( 4 d.p.) Using a calculator we need: Then, ( x n x n 1) 2 Newton-Raphson Iteration SUMMARY To use the Newton-Raphson method to estimate a root of an equation: rearrange the equation into the form f ( x ) 0 differentiate substitute f ( x ) to find f / ( x ) f ( x ) and f / ( x ) into the x n 1 x n formula f ( xn ) f / ( xn ) choose a suitable starting value for use a calculator to iterate x0 Tip: It saves a lot of errors if, before you type the formula into your calculator, you write the formula with ANS replacing every x. Exercise Newton-Raphson Iteration 1. (a) Use the Newton-Raphson method to estimate the root of the following equation to 6 d.p. using the starting value given: x3 2x2 2 0 ; x0 1 (b) What happens if you use x 0 0 ? (c) Use your calculator or a graph plotter to sketch the graph of y x 3 2 x 2 2 . (d) What is special about the graph at x 0 0 and why does it explain the answer to (b) ? 2. Use the Newton-Raphson method to estimate one root of 3 cos x 1 x to 4 d.p. using x 0 2 Newton-Raphson Iteration (a) x3 2x2 2 0 ; x0 1 Solution: Let f ( x ) x 3 2 x 2 2 x n 1 x n x0 1 , f / ( x) 3 x 2 4 x f ( xn ) f / ( xn ) 3 2 ( x n 2 x n 2) x n 1 x n 2 (3 x n 4 x n ) (ANS3 2ANS 2 2) ANS 2 ( 3ANS 4ANS) x1 0 857143 , x 2 0 839545 , . . . x 0 839287 ( 6 d.p. ) Newton-Raphson Iteration ( x n 2 x n 2) 3 x n 1 x n 2 (3 x n 4 x n ) (b) What happens if you use x 0 0 ? (c) 2 The iteration fails immediately. y x 2x 2 3 2 At x = 0, there is a stationary point. At a stationary point f / ( x ) 0 so in the formula we are dividing by 0. We also notice that the tangent never meets the x-axis. Newton-Raphson Iteration 2. Use the Newton-Raphson method to estimate one root of 3 cos x 1 x to 4 d.p. using x 0 2 Solution: Let f ( x ) 3 cos x 1 x f / ( x ) 3 sin x 1 ( 3 cos x n 1 x n ) x n 1 x n / x n1 x n ( 3 sin x n 1) f ( xn ) ( 3 cos ANS 1 ANS ) x n1 ANS ( 3 sin ANS 1) x 0 2, Radians! x1 1 8562, x 2 1 8624 x 1 8624 ( 4 d.p. ) f ( xn ) Newton-Raphson Iteration The Newton-Raphson method will fail if f / ( x) 0 i.e. at a stationary point It will also sometimes fail to give the expected root if the initial value is close to a stationary point. Can you draw a graph to show what could happen in this case? This is one example. Newton-Raphson Iteration y x3 2x2 5x 1 x0 x 0 1 9 the x 1 576 instead of With iteration gives the root the closer root x 0 187 . Newton-Raphson Iteration Newton-Raphson Iteration The following slides contain repeats of information on earlier slides, shown without colour, so that they can be printed and photocopied. For most purposes the slides can be printed as “Handouts” with up to 6 slides per sheet. Newton-Raphson Iteration It isn’t always possible to find iterative formulae of the type x n1 g( x n ) that will find the solution of every equation. Another iterative method that is useful is called the Newton-Raphson method. Newton-Raphson Iteration SUMMARY To use the Newton-Raphson method to estimate a root of an equation: rearrange the equation into the form differentiate substitute f ( x) to find and f / ( x) f ( x) f ( x) 0 f / ( x) into the formula choose a suitable starting value for x0 use a calculator to iterate Tip: It saves a lot of errors if, before you type the formula into your calculator, you write the formula with ANS replacing every x. Newton-Raphson Iteration e.g. Use the Newton-Raphson method with x 0 2 to find the root of the equation x x 1 0 3 correct to 4 d.p. Solution: Let Differentiate: x n 1 x n f ( x) x 3 x 1 f / ( x) 3 x 2 1 f ( xn ) / f ( xn ) 3 x n 1 x n 3 xn 1 2, ENTER 3 ANS ANS 1 ANS 3ANS 2 1 x 1 6180 ( 4 d.p.) Using a calculator we need: Then, xn xn 1 2 Newton-Raphson Iteration The Newton-Raphson method will fail if f / ( x) 0 i.e. at a stationary point It will also sometimes fail if the initial value is close to a stationary point.