3 The Newton-Raphson method

You may recall (e.g. HELM booklet  13.3) that the Newton-Raphson method (often simply called Newton’s method) for approximating a zero of the function f is given by

x n + 1 = x n f ( x n ) f ( x n )

where f denotes the first derivative of f and where x 0 is an initial guess to the zero of f . A graphical way of interpreting how this method works is shown in Figure 14.

Figure 14

No alt text was set. Please request alt text from the person who provided you with this resource.

At each approximation to the zero of f we extrapolate so that the tangent to the curve meets the x -axis. This point on the x -axis is the new approximation to the zero of f . As is clear from both the figure and the mathematical statement of the method above, we require that f ( x n ) 0 for n = 0 , 1 , 2 , .

Example 26

Let us consider the example we met earlier in Example 24. We know that the single positive zero of

f ( x ) = x tanh ( 1 2 x ) 1

lies between 1.5 and 2 . Use the Newton-Raphson method to approximate the zero of f .

Solution

We must work out the derivative of f to use Newton-Raphson. Now

f ( x ) = tanh ( 1 2 x ) + x 1 2 sech 2 ( 1 2 x )

on differentiating a product and recalling that d d x tanh ( x ) = sech 2 ( x ) . (To evaluate sech on a calculator recall that sech ( x ) = 1 cosh ( x ) .)

We must choose a starting value x 0 for the iteration and, given that we know the zero to be between 1.5 and 2, we take x 0 = 1.75 . The first iteration of Newton-Raphson gives

x 1 = x 0 f ( x 0 ) f ( x 0 ) = 1.75 f ( 1.75 ) f ( 1.75 ) = 1.75 0.231835 1.145358 = 1.547587 ,

where 6 decimal places are shown. The second iteration gives

x 2 = x 1 f ( x 1 ) f ( x 1 ) = 1.547587 f ( 1.547587 ) f ( 1.547587 ) = 1.547587 0.004585 1.09687 = 1 . 543407 .

Clearly this method lends itself to implementation on a computer and, for example, using a spreadsheet package, it is not hard to compute a few more iterations. Here is output from Microsoft Excel where we have included the two lines of hand-calculation above:

n x n f ( x n ) f ( x n ) x n + 1 ̲ ̲ ̲ ̲ ̲ 0 1.75 0.231835 1.145358 1.547587 1 1.547587 0.004585 1.09687 1.543407 2 1.543407 2.52 E 06 1.095662 1.543405 3 1.543405 7.69 E 13 1.095661 1.543405 4 1.543405 0 1.095661 1.543405

and all subsequent lines are equal to the last line here. The method has converged (very quickly!) to 1.543405, to six decimal places.

Earlier, in Example 25, we found that the bisection method would require 19 iterations to achieve 6 decimal place accuracy. The Newton-Raphson method gave an answer good to this number of places in just two or three iterations.

Task!

Use the starting value x 0 = 0 in an implementation of the Newton-Raphson method for approximating the zero of

f ( x ) = cos ( x ) x .

(If you are doing these calculations by hand then just perform two or three iterations. Don’t forget to use radians.)

The derivative of f is f ( x ) = sin ( x ) 1 . The first iteration is

x 1 = x 0 f ( x 0 ) f ( x 0 ) = 0 1 0 0 1 = 1

and the second iteration is

x 2 = x 1 f ( x 1 ) f ( x 1 ) = 1 cos ( 1 ) 1 sin ( 1 ) 1 = 1 0.459698 1.841471 = 0.750364 ,

and so on. There is little to be gained in our understanding by doing more iterations by hand, but using a spreadsheet we find that the method converges rapidly:

n x n f ( x n ) f ( x n ) x n + 1 ̲ ̲ ̲ ̲ ̲ 0 0 1 1 1 1 1 0.4597 1.84147 0.750364 2 0.750364 0.01892 1.6819 0.739113 3 0.739113 4.6 E 05 1.67363 0.739085 4 0.739085 2.8 E 10 1.67361 0.739085 5 0.739085 0 1.67361 0.739085

It is often necessary to find zeros of polynomials when studying transfer functions. Here is a Task involving a polynomial.

Task!

The function f ( x ) = x 3 + 2 x + 4  has a single zero near x 0 = 1 . Use this value of x 0 to perform two iterations of the Newton-Raphson method.

Using the starting value x 0 = 1 you should find that f ( x 0 ) = 1 and f ( x 0 ) = 5 . This leads to

x 1 = x 0 f ( x 0 ) f ( x 0 ) = 1 1 5 = 1 . 2 .

The second iteration should give you x 2 = x 1 f ( x 1 ) f ( x 1 ) = 1.2 0.128 6.32 = 1 . 17975 .

Subsequent iterations will home in on the zero of f . Using a computer spreadsheet gives:

n x n f ( x ) f ( x ) x n + 1 ̲ ̲ ̲ ̲ ̲ 0 1 1 5 1.2 1 1.2 0.128 6.32 1.17975 2 1.17975 0.00147 6.175408 1.17951 3 1.17951 2 E 07 6.173725 1.17951 4 1.17951 0 6.173725 1.17951

where we have recomputed the hand calculations for the first two iterations.

We see that the method converges to the value 1.17951 .