Skip to main content
Examonaut

Topic 9 · Lesson 3 of 4

Newton–Raphson and the trapezium rule

The Newton–Raphson method

Simple iteration can be slow. Newton–Raphson is usually much faster, and the idea is to follow tangents. Start at x0x_0. The tangent to y=f(x)y = f(x) at (x0,f(x0))(x_0, f(x_0)) is a good straight-line copy of the curve nearby, and it is easy to find where a straight line crosses the axis. Take that crossing as the next estimate x1x_1, and repeat, as the diagram shows.

xy22.5351015x₀x₁x₂y = f(x)

The tangent at xnx_n has gradient f′(xn)f'(x_n) and passes through (xn,f(xn))(x_n, f(x_n)). It meets the xx-axis after a horizontal distance of f(xn)f′(xn)\frac{f(x_n)}{f'(x_n)} (rise divided by gradient), so

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

This formula is in the formula booklet.

How to use Newton–Raphson

  1. Step 1: Write f(x)f(x) with everything on one side (f(x)=0f(x) = 0) and find f′(x)f'(x).
  2. Step 2: Substitute x0x_0 into the formula to get x1x_1; repeat.
  3. Step 3: Stop when successive values agree to the required accuracy, and if asked, confirm with a sign change.

When Newton–Raphson fails. If xnx_n is at or near a stationary point, f′(xn)f'(x_n) is zero or tiny: the tangent is nearly flat, the formula divides by almost nothing, and the next estimate is thrown a long way off, possibly towards a different root. If f′(xn)=0f'(x_n) = 0 exactly, the method cannot continue at all. A poor starting value can also lead to a different root from the one you wanted.

Worked example

Newton–Raphsonexam standard

Use Newton–Raphson with x0=2x_0 = 2 to find a root of x3−2x−5=0x^3 - 2x - 5 = 0 to 4 decimal places.

Show solution
  1. f(x)=x3−2x−5f(x) = x^3 - 2x - 5, f′(x)=3x2−2f'(x) = 3x^2 - 2.
  2. x1=2−f(2)f′(2)=2−−110=2.1x_1 = 2 - \frac{f(2)}{f'(2)} = 2 - \frac{-1}{10} = 2.1.
  3. x2=2.1−f(2.1)f′(2.1)=2.1−0.06111.23=2.094 568x_2 = 2.1 - \frac{f(2.1)}{f'(2.1)} = 2.1 - \frac{0.061}{11.23} = 2.094\,568.
  4. x3=2.094 551…x_3 = 2.094\,551\ldots Two steps after x1x_1 the values agree to 4 decimal places: the root is 2.0946. Simple iteration takes more steps than this to reach the same accuracy.

Worked example

Newton–Raphson with trigonometrytop grade

The equation 2sin⁡x=x2\sin x = x has a root α\alpha between 1.5 and 2.5.
a) Use Newton–Raphson with x0=2x_0 = 2 to find x1x_1 and x2x_2 to 4 decimal places. b) Explain why x0=1.05x_0 = 1.05 would be a poor starting value.

Show solution
  1. Rearrange to f(x)=2sin⁡x−x=0f(x) = 2\sin x - x = 0 (radians), so f′(x)=2cos⁡x−1f'(x) = 2\cos x - 1.
  2. f(2)=2sin⁡2−2=−0.1814f(2) = 2\sin 2 - 2 = -0.1814 and f′(2)=2cos⁡2−1=−1.8323f'(2) = 2\cos 2 - 1 = -1.8323, so x1=2−−0.1814−1.8323=1.9010x_1 = 2 - \frac{-0.1814}{-1.8323} = 1.9010.
  3. f(1.9010)=−0.0090f(1.9010) = -0.0090, f′(1.9010)=−1.6485f'(1.9010) = -1.6485, so x2=1.9010−−0.0090−1.6485=1.8955x_2 = 1.9010 - \frac{-0.0090}{-1.6485} = 1.8955.
  4. b) f′(x)=0f'(x) = 0 when cos⁡x=12\cos x = \frac{1}{2}, at x=π3=1.047x = \frac{\pi}{3} = 1.047. Near there the tangent is almost horizontal, so f(x0)f′(x0)\frac{f(x_0)}{f'(x_0)} is huge and x1x_1 would be thrown far away from α\alpha.

The trapezium rule

To estimate an integral you can't do exactly, split the area into vertical strips of equal width hh and treat each strip as a trapezium, with straight tops joining points on the curve. A trapezium with parallel sides y0y_0 and y1y_1 and width hh has area h2(y0+y1)\frac{h}{2}(y_0 + y_1). Adding nn of them, every inside height is counted twice and the two ends once:

∫aby dx≈h2[y0+2(y1+y2+⋯+yn−1)+yn],h=b−an\int_a^b y\,dx \approx \frac{h}{2}\big[y_0 + 2(y_1 + y_2 + \cdots + y_{n-1}) + y_n\big], \qquad h = \frac{b - a}{n}

This is in the formula booklet. Note that nn strips need n+1n + 1 heights ("ordinates").

Over or under? Look at the shape, as in the diagram for y=2xy = 2^x. If the curve is convex (bending upwards), the straight tops lie above it and the rule gives an overestimate. If it is concave, it gives an underestimate. More strips give a better estimate.

xyO0.511.521234y = 2ˣh = 0.5

Try it: change the number of strips and watch the trapezium rule close in on the exact value, and see why a convex curve gives an over-estimate.

Try it: simulation

Integration and area

Loading the simulation…

Worked example

Trapezium rule with boundstop grade

a) Use the trapezium rule with 4 strips to estimate ∫022x dx\int_0^2 2^x\,dx. b) State, with a reason, whether this is an over- or underestimate. c) Use rectangles to find a lower bound, and so give an interval containing the true value.

Show solution
  1. a) h=2−04=0.5h = \frac{2 - 0}{4} = 0.5. Heights at x=0,0.5,1,1.5,2x = 0, 0.5, 1, 1.5, 2: 11, 1.41421.4142, 22, 2.82842.8284, 44.
  2. Estimate: 0.52[1+2(1.4142+2+2.8284)+4]=0.25×17.485=4.371\frac{0.5}{2}\big[1 + 2(1.4142 + 2 + 2.8284) + 4\big] = 0.25 \times 17.485 = 4.371.
  3. b) y=2xy = 2^x is convex (its second derivative, 2x(ln⁡2)22^x(\ln 2)^2, is positive), so the trapezia lie above the curve: an overestimate.
  4. c) The curve is increasing, so rectangles using the left height of each strip lie under the curve: 0.5(1+1.4142+2+2.8284)=3.6210.5(1 + 1.4142 + 2 + 2.8284) = 3.621.
  5. So 3.62<∫022x dx<4.373.62 < \int_0^2 2^x\,dx < 4.37. (The exact value is 3ln⁡2=4.328\frac{3}{\ln 2} = 4.328, inside the interval and close to the trapezium estimate.)

Numerical methods in context

In modelling, numerical methods answer questions that algebra can't. For example, if a population is modelled by P=200e0.1t−5t2P = 200e^{0.1t} - 5t^2 and you need the time when P=500P = 500, solve f(t)=200e0.1t−5t2−500=0f(t) = 200e^{0.1t} - 5t^2 - 500 = 0 with Newton–Raphson, then check with a sign change. Always interpret the answer (a time in years, rounded sensibly) and remember that the model's error is usually much bigger than the numerical error.

Practise this topic

Both are part of Premium.