A-level Mathematics

9.3 Newton–Raphson and other recurrence relations — Learn

Prerequisites: differentiating powers, exponentials and logarithms from Section 7.3; the tangent to a curve from Section 7.5; rearranging an equation into the form x=g(x)x = g(x) from Section 9.2; bracketing a root by change of sign from Section 9.1.

By the end of this section you can: use the Newton–Raphson formula to find a root to a required accuracy; explain where the formula comes from; recognise a recurrence relation that is Newton–Raphson in disguise; and explain three ways the method can fail.

1. From a tangent to a formula

Section 9.2 found a root by rearranging an equation and iterating. That works, but it can be slow. The Newton–Raphson method uses the tangent instead.

Suppose rr is a root of f(x)=0f(x) = 0, so the graph crosses the axis at rr. Pick a first estimate x0x_0 near rr. Draw the tangent to the curve at the point (x0,f(x0))(x_0, f(x_0)). Near that point the tangent follows the curve closely, so it meets the axis near rr. Call that meeting point x1x_1.

The tangent through (x0,f(x0))(x_0, f(x_0)) has gradient f′(x0)f'(x_0), so its equation is

y−f(x0)=f′(x0)(x−x0).y - f(x_0) = f'(x_0)(x - x_0).

At the point where the tangent meets the axis, y=0y = 0 and x=x1x = x_1. Substitute both values:

−f(x0)=f′(x0)(x1−x0).-f(x_0) = f'(x_0)(x_1 - x_0).

Divide both sides by f′(x0)f'(x_0) and add x0x_0:

x1=x0−f(x0)f′(x0).x_1 = x_0 - \frac{f(x_0)}{f'(x_0)}.

Repeat the same step with x1x_1 in place of x0x_0. The Newton–Raphson formula is

xn+1=xn−f(xn)f′(xn).x_{n+1} = x_n - \frac{f(x_n)}{f'(x_n)}.

Each step needs the value of the function and the value of its derivative at the current estimate. The method is also called the Newton–Raphson iteration.

2. Using the formula

Example 1. Use Newton–Raphson with x0=0.7x_0 = 0.7 to find a root of x3+x−1=0x^3 + x - 1 = 0 to four decimal places.

Write f(x)=x3+x−1f(x) = x^3 + x - 1 and differentiate:

f′(x)=3x2+1.f'(x) = 3x^2 + 1.

Now apply the formula. Keep the full value in the calculator at every step.

nn xnx_n f(xn)f(x_n) f′(xn)f'(x_n) xn+1x_{n+1}
00 0.70.7 0.0430.043 2.472.47 0.68259110.6825911
11 0.68259110.6825911 0.00063120.0006312 2.39779182.3977918 0.68232790.6823279
22 0.68232790.6823279 0.00000020.0000002 2.39671412.3967141 0.68232780.6823278

The values settle after three steps. The root is 0.68230.6823 to four decimal places. Compare this with Section 9.1, where the same root needed four halving steps to reach two decimal places.

3. A recurrence relation in disguise

Some recurrences look unlike Newton–Raphson but turn out to be the same method. Check a recurrence by writing it as x−f(x)f′(x)x - \dfrac{f(x)}{f'(x)} and looking for ff.

Example 2. Show that the recurrence xn+1=12(xn+5xn)x_{n+1} = \dfrac{1}{2}\left(x_n + \dfrac{5}{x_n}\right) is Newton–Raphson applied to x2−5=0x^2 - 5 = 0. Use it with x0=2x_0 = 2 to find x3x_3.

Take f(x)=x2−5f(x) = x^2 - 5, so f′(x)=2xf'(x) = 2x. Then

x−f(x)f′(x)=x−x2−52x=2x2−x2+52x=x2+52x=12(x+5x).x - \frac{f(x)}{f'(x)} = x - \frac{x^2 - 5}{2x} = \frac{2x^2 - x^2 + 5}{2x} = \frac{x^2 + 5}{2x} = \frac{1}{2}\left(x + \frac{5}{x}\right).

This is the given recurrence, so the recurrence is Newton–Raphson for x2−5=0x^2 - 5 = 0. The root it finds is 5\sqrt{5}.

Now iterate from x0=2x_0 = 2:

x1=12(2+52)=2.25,x_1 = \frac{1}{2}\left(2 + \frac{5}{2}\right) = 2.25, x2=12(2.25+52.25)=2.236111,x3=12(2.236111+52.236111)=2.236068.x_2 = \frac{1}{2}\left(2.25 + \frac{5}{2.25}\right) = 2.236111, \qquad x_3 = \frac{1}{2}\left(2.236111 + \frac{5}{2.236111}\right) = 2.236068.

The value x3=2.236068x_3 = 2.236068 agrees with 5=2.2360680…\sqrt{5} = 2.2360680\ldots to six decimal places. Newton–Raphson reaches the value in three steps because it uses the gradient, not only the height.

4. Exponential and logarithmic equations

The same formula works for any differentiable function. Bring every term to one side before you start, so the equation reads f(x)=0f(x) = 0.

Example 3. Use Newton–Raphson with x0=1.5x_0 = 1.5 to find a root of ex=3xe^x = 3x to four decimal places.

Rearrange to ex−3x=0e^x - 3x = 0 and write f(x)=ex−3xf(x) = e^x - 3x. Then f′(x)=ex−3f'(x) = e^x - 3. Substitute x0=1.5x_0 = 1.5:

f(1.5)=e1.5−4.5=−0.0183109,f′(1.5)=e1.5−3=1.4816891.f(1.5) = e^{1.5} - 4.5 = -0.0183109, \qquad f'(1.5) = e^{1.5} - 3 = 1.4816891.

Apply the formula:

x1=1.5−−0.01831091.4816891=1.5+0.0123581=1.5123581.x_1 = 1.5 - \frac{-0.0183109}{1.4816891} = 1.5 + 0.0123581 = 1.5123581.

Repeat with x1x_1:

x2=1.5123581−0.00034361.5374181=1.5121346,x3=1.5121346−0.00000011.5364040=1.5121346.x_2 = 1.5123581 - \frac{0.0003436}{1.5374181} = 1.5121346, \qquad x_3 = 1.5121346 - \frac{0.0000001}{1.5364040} = 1.5121346.

The root is 1.51211.5121 to four decimal places.

The equation ex=3xe^x = 3x has a second root near x=0.6191x = 0.6191, because f(0.6)>0f(0.6) > 0 and f(0.7)<0f(0.7) < 0. Starting from x0=0.5x_0 = 0.5 finds that root instead. The starting value decides which root the method reaches.

5. When Newton–Raphson fails

Three things can go wrong. Each one has a clear cause.

A stationary point at the starting value. If f′(xn)=0f'(x_n) = 0, the formula divides by zero. The tangent is horizontal, so it never meets the axis. For f(x)=x2−4f(x) = x^2 - 4, the starting value x0=0x_0 = 0 gives f′(0)=0f'(0) = 0. The method breaks down at the first step.

The iterates settle into a cycle. The formula can jump back and forth without reaching the root. For f(x)=x3−2x+2f(x) = x^3 - 2x + 2 from x0=0x_0 = 0:

x1=1.0,x2=0.0,x3=1.0.x_1 = 1.0, \qquad x_2 = 0.0, \qquad x_3 = 1.0.

The values repeat 1,0,1,0,…1, 0, 1, 0, \ldots for ever. The method never settles, even though the formula was applied correctly.

The gradient leads the estimate far away. A step can overshoot. For f(x)=ex−3xf(x) = e^x - 3x with a starting value far from a root, the first tangent can cross the axis a long way from the root. The next step then starts from a poor value. A sketch of the curve shows the danger before you iterate.

Watch out. Three mistakes are common.

Dividing by a zero derivative. If f′(xn)=0f'(x_n) = 0, the step is undefined. Re-check: work out f′(x0)f'(x_0) before you begin. Choose a starting value where the derivative is not zero.

Assuming the method always works. Newton–Raphson can cycle, overshoot or find a different root from the one you expected. Re-check: bracket the root by change of sign first, so you know which root you are aiming for.

Rounding every iterate. Rounding each value to three decimal places can change the value the method settles on. Re-check: keep the full value in the calculator and round only the value you write down.

6. Try it: the tangent and the next estimate

Predict first. The figure shows a curve, a movable starting value x0x_0 and the tangent at that point. Before you move the slider, predict whether the first estimate x1x_1 lies to the left or to the right of a root. Write down your prediction.

Test. Choose each equation and move the starting-value slider. Watch the first estimate, the list of iterates and the message about what the method is doing.

Explain. Write two sentences. The first explains why the tangent gives a better estimate than the starting value. The second describes what happens when the starting value sits at a stationary point.

Progress check

Return to the chapter problem. The drone's height is h(t)=40e−t/4−2th(t) = 40e^{-t/4} - 2t.

  1. Differentiate to find h′(t)h'(t).
  2. Use Newton–Raphson with t0=5t_0 = 5 to find t1t_1 to four decimal places.
  3. Continue to find t2t_2 and t3t_3. Give the landing time to three decimal places.

You should now be able to

Settings

Colour scheme

Applies to every book you read here.

Reading theme

Applies to every book you read here.