MathsNumerical methods › The Newton-Raphson method

The Newton-Raphson method

The Newton-Raphson method uses the tangent at xn to calculate xn+1 = xn − f(xn)/f'(xn). Near a simple root, with a suitable starting value and sufficiently smooth derivatives, convergence is usually quadratic. A step is undefined when f'(xn) = 0, and poor starting values can lead to another root or to divergence.

Newton-Raphson and the trapezium rule, part 1 of 2. Part 2 is The trapezium rule.

Builds on Locating roots and iteration and Tangents, turning points and curve behaviour.

IN THIS TOPIC

  • Run Newton-Raphson, reading each step as the tangent meeting the x-axis.
  • State why no next iterate exists when f'(xn) = 0, and what a nearly horizontal tangent does to the sequence.
  • Turn a question in context into an equation, and give the root back with its units.
  • State how fast the iterates converge near a simple root, where the correct digits roughly double each step.

COMMON MISCONCEPTION

Newton-Raphson always finds the root, whatever the starting value.

The starting value matters. Where f'(xn) = 0 and f(xn) is not zero the tangent is horizontal, so it never meets the x-axis and no next iterate exists. Where f' is merely small the tangent is shallow and the next iterate lands far away: x3 − 3x + 1 started at 1.04 gives 5.1, and the sequence can then converge to a root the question did not ask for.

The tangent step

The Newton-Raphson method uses the derivative to improve an estimate of a root. From an estimate xn, take the tangent to the curve at that point and find where it meets the x-axis; that value is the next estimate. The formula is given in the formulae booklet as

xn+1=xnf(xn)f(xn)x_{n+1} = x_{n} − \frac{f(x_{n})}{f'(x_{n})}IN THE FORMULAE BOOKLET

Near a simple root, one at which f is zero and f' is not, with a suitable starting value and sufficiently smooth derivatives, convergence is usually quadratic: the number of correct digits roughly doubles at each step. At a repeated root, where f' is also zero at the root, convergence is slower than that. If an iterate lands exactly on the root, f(xn) = 0 and the sequence stays there.

A cubic crossing the axis with two tangent lines riding it down: the tangent drawn at 1.5 meets the axis at the computed 1.3478, the dashed tangent there lands on 1.3252, and each Newton-Raphson step roughly doubles the number of correct digits on its way to 1.3247.
FIG. 1Two tangent steps on x³ − x − 1: from 1.5 the tangent meets the axis at 1.3478, from there at 1.3252, and the next step gives 1.3247.

WORKED EXAMPLE

Three steps to four decimal places

Use Newton-Raphson on f(x) = x3 − x − 1 with x0 = 1.5.

f(1.5) = 0.875 and f'(1.5) = 5.75, so x1 = 1.5 − 0.875/5.75 = 1.3478.

Repeating: x2 = 1.3252, x3 = 1.3247, and the digits have stopped moving at 4 decimal places.

The root is 1.3247, after three steps. Fixed-point iteration of xn+1 = (xn + 1)1/3 needs roughly twice as many steps on the same equation.

Two points of technique. Differentiate f before starting, since f' is required at every step; an incorrect derivative changes the length of each step, so the sequence converges more slowly than it should or fails to converge at all. Keep the full calculator value from step to step and round once at the end: near a simple root each iterate carries roughly twice as many correct digits as the last, so rounding to four decimal places as you go discards the digits the next step would have corrected.

GUIDED PRACTICE

A square root by Newton-Raphson

Apply Newton-Raphson to f(x) = x2 − 7 with x0 = 2.5, finding x1 and x2, before opening the working.

Show the working

f' = 2x, so the formula reads xn+1 = xn − (xn2 − 7)/(2xn).

x1 = 2.5 − (−0.75)/5 = 2.65, and x2 = 2.6458 to 4 decimal places.

√7 = 2.64575… , so two steps agree with it to 4 decimal places. Iterations of this kind are one standard way of computing square roots numerically.

Undefined steps and unintended roots

No further Newton-Raphson step can be calculated from an iterate for which f'(xn) = 0. If f(xn) = 0, the root has already been found; otherwise the formula is undefined at that iterate, because the tangent there is horizontal and does not meet the x-axis. Take f(x) = x3 − 3x + 1, whose derivative 3x2 − 3 is zero at x = 1, where f(1) = −1. Starting at x0 = 1 gives no x1, and that is what a question asking why the method fails from this starting value requires you to say.

A cubic with three roots. At its turning point the tangent is horizontal, drawn running level and never reaching the axis, so no next estimate exists. A little to the right the tangent is merely shallow: it does meet the axis, but so far away that the drawing cannot hold the point, and the sequence continues from somewhere unrelated to where it started.
FIG. 2Two cases on one cubic. The tangent at the turning point is horizontal, so no next estimate exists. A little to the right the tangent is shallow: it does meet the axis, past 5 and outside this picture, so the next iterate is far from the starting value.

The second case produces a number rather than an error. Where f' is small the tangent is shallow, so it meets the axis a long way from xn. Starting the same cubic at 1.04 gives a first iterate of 5.1. If the curve has other roots, the sequence may converge to one of those instead, and the calculation gives no indication that it has: the sequence converges and the arithmetic is correct, but the limit is not the root the question asked for.

Two checks cover both cases. Start from an interval established by a sign change, so that the root required is bracketed. Then substitute the limit back into f and confirm that it lies in that interval; a value outside the interval is a different root.

INDEPENDENT PRACTICE

Two starting values, one with no next step

Return to f(x) = x3 − x − 1, with the root in (1, 2) found in the worked example above. Explain why Newton-Raphson cannot be started at x0 = 1/√3, and find x1 from x0 = 1.2.

Show the working

f'(x) = 3x2 − 1, and 3 × 1/3 − 1 = 0, so f'(1/√3) = 0 and f(1/√3) is not zero. The tangent there is horizontal and does not meet the x-axis, so the formula divides by zero and no first iterate exists.

From x0 = 1.2: f(1.2) = −0.472 and f'(1.2) = 3.32, so x1 = 1.2 + 0.472/3.32 = 1.3422. It lies inside (1, 2), the interval in which the root was located.

An equation from a model

A numerical method is used when the equation has no solution in terms of the functions available. A quantity is modelled, a question is asked of the model, and the resulting equation cannot be rearranged for the unknown. A context adds a step at each end: forming the equation from the situation before any iteration, and reporting the root afterwards as a quantity with units.

WORKED EXAMPLE

The next dose, from a model

A drug is given at t = 0 and its concentration in the blood t hours later is modelled by C = 5t e−0.4t milligrams per litre. The next dose is due when C has fallen back to 2 mg per litre. Find when that is.

The equation is 5t e−0.4t = 2, and t cannot be made the subject, because the unknown appears both inside and outside the exponential. Take f(t) = 5t e−0.4t − 2 and find a root of f.

The equation has two roots. The concentration rises to 4.60 mg per litre at t = 2.5 and decreases after it, so it passes 2 twice, and the dose is due at the second crossing. f(7) = 0.12835 > 0 and f(7.5) = −0.13298 < 0, so a root lies in (7, 7.5), which is the crossing on the decreasing part of the curve.

f'(t) = 5e−0.4t(1 − 0.4t) by the product rule, so f'(7) = −0.54729.

From t0 = 7: t1 = 7 − 0.12835/(−0.54729) = 7.2345, then t2 = 7.2397 and t3 = 7.2397.

The root is 7.2397, inside (7, 7.5), so it is the second crossing rather than the first. The next dose is due 7.24 hours after the first, which is 7 hours and 14 minutes to the nearest minute.

Give the answer to 3 significant figures rather than as 7.2397 hours. The iteration is accurate about the model, but the model is a fit to measurements, and four decimal places claim a precision the data do not support.

The starting value was chosen from the context rather than from the algebra: the equation has two roots, the question specifies which one, and a sign change either side of that root supplies a starting value near it.

Strips with straight tops has moved to the next part of this lesson.

ASSESSMENT FOCUS

  • Quote the Newton-Raphson formula, show the substitution, and give iterates to more places than the final answer requires.
  • Where f'(x₀) = 0 and f(x₀) is not zero, no first iterate exists. State the reason: the tangent is horizontal, so it does not meet the x-axis and the formula divides by zero.
  • Where a question gives an interval, state at the end that the answer lies in it. That confirms the iteration converged to the root asked for.
  • Where a question specifies an iterative method, an exact method does not answer the question set.
  • In context, identify which root is required before starting, and give the answer in the units of the model.
  • Round once, at the end. Rounding each iterate as you go can change the final figure of the answer.

CHECK YOURSELF

Show that x = e−x has a root between 0.5 and 0.6, and find it to 5 decimal places using Newton-Raphson on f(x) = x − e−x with x0 = 0.6.

Show a hint

f(0.5) and f(0.6) first; f' = 1 + e−x.

Show the answer

f(0.5) = −0.1065 < 0 and f(0.6) = 0.0512 > 0 with f continuous, so a root lies between them.

x1 = 0.6 − 0.0512/1.5488 = 0.56695, and x2 = x3 = 0.56714.

The root is 0.56714. Two steps give five decimal places, which is the quadratic convergence expected near this simple root, and 0.56714 lies inside (0.5, 0.6), so it is the root located by the sign change.

Newton-Raphson takes the tangent at xn to the x-axis; near a simple root, with a suitable starting value and a sufficiently smooth f, convergence is usually quadratic.

Where f'(xn) = 0 and f(xn) is not zero, the next step is undefined; where f'(xn) is small, the next iterate is far away and the sequence may converge to a different root or diverge.

WORKBOOK

Printable practice for this topic: original exam-style questions with room to work, and a fully worked answer book. Free to use; please do not redistribute or sell.

15 questions on this topicAnswer them one at a time and mark yourself against the worked answer.Practise this topic

Or read them with their worked answers on the newton-raphson method questions page.

CHECK YOUR PROGRESS

Rate how confident you feel with each objective for this lesson. Ratings are saved in this browser, on this device, unless you sign in.

  • Run Newton-Raphson, reading each step as the tangent meeting the x-axis.
  • State why no next iterate exists when f'(xn) = 0, and what a nearly horizontal tangent does to the sequence.
  • Turn a question in context into an equation, and give the root back with its units.
  • State how fast the iterates converge near a simple root, where the correct digits roughly double each step.

Open the full revision checklist to see every objective in the course in one place.