Lemma
← All topics
Pure mathematics

Numerical methods

Getting answers when algebra runs out.

Introduction

Most equations cannot be solved exactly: try x3+x−1=0x^3 + x - 1 = 0 or e−x=xe^{-x} = x. Numerical methods find approximate answers to any accuracy you like. This topic covers locating a root by a change of sign, improving it by iteration xn+1=g(xn)x_{n+1} = g(x_n) or the Newton–Raphson method, and approximating areas with the trapezium rule. You also need to know when each method fails.

Why it matters

Every calculator, spreadsheet and engineering program solves equations numerically. When your calculator gives 2=1.414213562\sqrt2 = 1.414213562, it has run something very like Newton–Raphson. Weather forecasts, bridge designs and computer games all rely on these ideas.

Intuitive explanation

IntuitionChange of sign

If a continuous graph is below the axis at one point and above it at another, it must cross the axis in between. So if f(a)f(a) and f(b)f(b) have opposite signs, there is a root between aa and bb.

IntuitionNewton–Raphson follows tangents

From a guess x0x_0, draw the tangent to the curve and see where it hits the xx-axis. That is the next guess. Near a root the curve looks almost straight, so each guess is much better than the last: the number of correct digits roughly doubles each step.

IntuitionIteration bounces between curves

To solve x=g(x)x = g(x), keep feeding the output back in. On a graph you bounce between y=xy = x and y=g(x)y = g(x), forming a staircase or cobweb. It converges if gg is not too steep near the root: ∣g′(x)∣<1|g'(x)| < 1.

Formal definitions

DefinitionChange of sign rule

If ff is continuous on [a,b][a, b] and f(a)f(b)<0f(a)f(b) < 0, then f(x)=0f(x) = 0 has at least one root in (a,b)(a, b).

DefinitionFixed-point iteration

Rearrange f(x)=0f(x) = 0 as x=g(x)x = g(x) and generate xn+1=g(xn)x_{n+1} = g(x_n) from a starting value x0x_0.

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

Notation

  • x0x_0 (or x1x_1) is the starting value; xnx_n is the nnth iterate.
  • "Correct to 3 d.p." means you must show the true root lies in the interval [α−0.0005,α+0.0005)[\alpha - 0.0005, \alpha + 0.0005), usually by a change of sign.
  • h=b−anh = \frac{b - a}{n} is the strip width in the trapezium rule.

Key formulae

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

Key results

TheoremConvergence of iteration

If ∣g′(x)∣<1|g'(x)| < 1 near the root α\alpha and x0x_0 is close enough, xn+1=g(xn)x_{n+1} = g(x_n) converges to α\alpha. If ∣g′(α)∣>1|g'(\alpha)| > 1 it diverges. If 0<g′(α)<10 < g'(\alpha) < 1 you see a staircase; if −1<g′(α)<0-1 < g'(\alpha) < 0 a cobweb.

PropositionWhen things go wrong
  • Change of sign fails with a repeated root (the curve touches the axis), with two roots close together, or at an asymptote such as 1x\frac1x (sign change but no root).
  • Newton–Raphson fails if f′(xn)=0f'(x_n) = 0 (horizontal tangent) or diverges from a poor start.
  • Trapezium rule overestimates when the curve is convex (bends upward) and underestimates when it is concave.

Deriving Newton–Raphson

ProofFrom the tangent line

The tangent at (xn,f(xn))(x_n, f(x_n)) is y−f(xn)=f′(xn)(x−xn)y - f(x_n) = f'(x_n)(x - x_n). It meets y=0y = 0 when x=xn−f(xn)f′(xn)x = x_n - \dfrac{f(x_n)}{f'(x_n)}. That point is xn+1x_{n+1}.

∎
ProofThe trapezium rule

Each strip is approximately a trapezium of width hh and parallel sides yiy_{i} and yi+1y_{i+1}, with area h2(yi+yi+1)\frac h2(y_i + y_{i+1}). Adding all strips counts each interior ordinate twice and the end ones once.

∎
ProofWhy ∣g′(α)∣<1|g'(\alpha)| < 1 makes iteration converge

Suppose ∣g′(x)∣≤k<1|g'(x)| \le k < 1 on an interval II around α=g(α)\alpha = g(\alpha), and xn∈Ix_n \in I. By the mean value theorem there is a ξn\xi_n between xnx_n and α\alpha with

xn+1−α=g(xn)−g(α)=g′(ξn)(xn−α).x_{n+1} - \alpha = g(x_n) - g(\alpha) = g'(\xi_n)(x_n - \alpha).

So ∣xn+1−α∣≤k∣xn−α∣|x_{n+1} - \alpha| \le k|x_n - \alpha|: the next iterate is closer, so it is still in II. By induction ∣xn−α∣≤kn∣x0−α∣→0|x_n - \alpha| \le k^n|x_0 - \alpha| \to 0. As xn→αx_n \to \alpha, ξn→α\xi_n \to \alpha too, so xn+1−αxn−α→g′(α)\frac{x_{n+1} - \alpha}{x_n - \alpha} \to g'(\alpha): each error is about g′(α)g'(\alpha) times the last. If g′(α)>0g'(\alpha) > 0 the errors keep their sign (a staircase); if g′(α)<0g'(\alpha) < 0 they alternate (a cobweb).

∎
ProofNewton–Raphson converges quadratically

Let α\alpha be a root with f′(α)≠0f'(\alpha) \ne 0, and en=xn−αe_n = x_n - \alpha. By Taylor's theorem with remainder,

0=f(α)=f(xn)−enf′(xn)+12en2f′′(ξn)0 = f(\alpha) = f(x_n) - e_nf'(x_n) + \tfrac12e_n^2f''(\xi_n)

for some ξn\xi_n between α\alpha and xnx_n. Divide by f′(xn)f'(x_n) and rearrange:

xn−f(xn)f′(xn)−α=f′′(ξn)2f′(xn)en2,i.e.en+1=f′′(ξn)2f′(xn) en2.x_n - \frac{f(x_n)}{f'(x_n)} - \alpha = \frac{f''(\xi_n)}{2f'(x_n)}e_n^2, \qquad\text{i.e.}\qquad e_{n+1} = \frac{f''(\xi_n)}{2f'(x_n)}\,e_n^2.

Near the root the error is squared each step (times about f′′(α)2f′(α)\frac{f''(\alpha)}{2f'(\alpha)}), so the number of correct digits roughly doubles. The formula also shows the failures: a tiny f′(xn)f'(x_n) makes the step huge, and at a repeated root f′(α)=0f'(\alpha) = 0 and the argument breaks (the convergence becomes merely linear: see Q55).

∎
ProofThe error of the trapezium rule

Take one strip [0,h][0, h] and let E=h2(f(0)+f(h))−∫0hf(x) dxE = \frac h2\big(f(0) + f(h)\big) - \int_0^hf(x)\,dx. Integrating by parts with u=fu = f, v=x−h2v = x - \frac h2:

∫0hf dx=[(x−h2)f]0h−∫0h(x−h2)f′ dx,soE=∫0h(x−h2)f′(x) dx.\int_0^hf\,dx = \Big[\left(x - \tfrac h2\right)f\Big]_0^h - \int_0^h\left(x - \tfrac h2\right)f'\,dx, \quad\text{so}\quad E = \int_0^h\left(x - \tfrac h2\right)f'(x)\,dx.

Integrate by parts again, now with v=12x(x−h)v = \frac12x(x - h), which vanishes at both ends:

E=−∫0h12x(x−h)f′′(x) dx=∫0h12x(h−x)f′′(x) dx=f′′(ξ)∫0h12x(h−x) dx=h312f′′(ξ),E = -\int_0^h\tfrac12x(x - h)f''(x)\,dx = \int_0^h\tfrac12x(h - x)f''(x)\,dx = f''(\xi)\int_0^h\tfrac12x(h - x)\,dx = \frac{h^3}{12}f''(\xi),

using the mean value theorem for integrals (the weight 12x(h−x)\frac12x(h - x) is never negative). Adding n=b−ahn = \frac{b - a}{h} strips:

Tn−∫abf dx=(b−a)h212f′′(η)for some η∈(a,b).T_n - \int_a^bf\,dx = \frac{(b - a)h^2}{12}f''(\eta)\quad\text{for some }\eta \in (a, b).

So the error is proportional to h2h^2 (halving hh quarters it), and its sign is the sign of f′′f'': convex curves are overestimated.

∎

Methods

MethodShowing a root is correct to a given accuracy

To show α=1.325\alpha = 1.325 to 3 d.p., evaluate f(1.3245)f(1.3245) and f(1.3255)f(1.3255), show they have opposite signs, state that ff is continuous, and conclude the root lies in [1.3245,1.3255][1.3245, 1.3255], so rounds to 1.3251.325.

MethodRearranging into x=g(x)x = g(x)

Isolate an xx in any convenient way. Different rearrangements behave differently: one may converge and another diverge. Check with ∣g′(x)∣|g'(x)| near the root.

MethodTrapezium rule in a table

List xx values and yy values in a table, keep at least 4 or 5 significant figures, then apply the formula once at the end.

Examples

ExampleA quick sign change

f(x)=x3−2x−5f(x) = x^3 - 2x - 5: f(2)=−1f(2) = -1 and f(3)=16f(3) = 16. ff is continuous, so there is a root between 2 and 3.

Full worked examples are in the Worked examples tab.

Common mistakes

Common mistakeNot stating continuity

A sign change only proves a root if the function is continuous on the interval. Say so.

Common mistakeRadians

Any trig function in a numerical method must be evaluated in radians.

Common mistakeWrong number of ordinates

nn strips need n+1n + 1 ordinates y0,…,yny_0, \dots, y_n.

Common mistakeRounding too early

Keep full calculator values between iterations; round only the final answer.

Applications

  • Engineering: solving equations for stresses and flows that have no closed form.
  • Finance: finding an interest rate from repayments (IRR) is a root-finding problem.
  • Science: areas under experimental curves (distance from a velocity–time graph) by the trapezium rule.

Connections

Summary

  • Continuous ff with f(a)f(b)<0f(a)f(b) < 0: a root in (a,b)(a, b). Watch for repeated roots and asymptotes.
  • Iteration xn+1=g(xn)x_{n+1} = g(x_n) converges if ∣g′∣<1|g'| < 1 near the root; staircase or cobweb diagrams.
  • Newton–Raphson xn+1=xn−f(xn)/f′(xn)x_{n+1} = x_n - f(x_n)/f'(x_n); fails when f′(xn)=0f'(x_n) = 0.
  • Trapezium rule h2[y0+2(middle)+yn]\frac h2[y_0 + 2(\text{middle}) + y_n]; over-estimates for convex curves.

Worked examples

Try each one yourself first, then open the solution.

Example 1Showing a root lies in an interval

Show that f(x)=ex−3xf(x) = e^x - 3x has a root between x=1.5x = 1.5 and x=1.6x = 1.6.

Show the solution
  1. 1Evaluate at both ends

    f(1.5)=4.4817−4.5=−0.0183f(1.5) = 4.4817 - 4.5 = -0.0183 and f(1.6)=4.9530−4.8=0.1530f(1.6) = 4.9530 - 4.8 = 0.1530.

  2. 2Sign change

    One is negative and one is positive.

  3. 3Conclude

    ff is continuous, so there is a root in (1.5,1.6)(1.5, 1.6).

Answer

f(1.5)<0<f(1.6)f(1.5) < 0 < f(1.6)

Example 2When a sign change misleads

f(x)=1x−2f(x) = \dfrac{1}{x - 2}. Explain why f(1)<0<f(3)f(1) < 0 < f(3) does not show a root in (1,3)(1, 3).

Show the solution
  1. 1Check the values

    f(1)=−1f(1) = -1 and f(3)=1f(3) = 1: there is a sign change.

  2. 2Check continuity

    ff has a vertical asymptote at x=2x = 2, so it is not continuous on [1,3][1, 3].

  3. 3Conclude

    1x−2\frac{1}{x - 2} is never zero. The sign change is caused by the asymptote, not a root.

Answer

Not continuous: an asymptote at x=2x = 2, and no root

Example 3Running an iteration

Use xn+1=2xn+53x_{n+1} = \sqrt[3]{2x_n + 5} with x0=2x_0 = 2 to find x1,x2,x3x_1, x_2, x_3 to 4 decimal places.

Show the solution
  1. 1x1x_1

    93=2.0801\sqrt[3]{9} = 2.0801.

  2. 2x2x_2

    2(2.0801)+53=9.16023=2.0924\sqrt[3]{2(2.0801) + 5} = \sqrt[3]{9.1602} = 2.0924.

  3. 3x3x_3

    9.18483=2.0942\sqrt[3]{9.1848} = 2.0942.

  4. 4Interpret

    The values converge to the root of x3−2x−5=0x^3 - 2x - 5 = 0, which is 2.09462.0946 to 4 d.p.

Answer

2.0801,2.0924,2.09422.0801, 2.0924, 2.0942

Example 4Choosing a rearrangement that converges

x3−2x−5=0x^3 - 2x - 5 = 0 can be rearranged to x=x3−52x = \dfrac{x^3 - 5}{2} or x=2x+53x = \sqrt[3]{2x + 5}. Near the root α≈2.09\alpha \approx 2.09, which iteration converges?

Show the solution
  1. 1First rearrangement

    g(x)=x3−52g(x) = \frac{x^3 - 5}{2}, g′(x)=3x22≈6.6g'(x) = \frac{3x^2}{2} \approx 6.6 at 2.092.09. ∣g′∣>1|g'| > 1: diverges.

  2. 2Second rearrangement

    g(x)=(2x+5)1/3g(x) = (2x + 5)^{1/3}, g′(x)=23(2x+5)−2/3≈0.15g'(x) = \frac23(2x + 5)^{-2/3} \approx 0.15. ∣g′∣<1|g'| < 1: converges.

  3. 3Shape

    0<g′<10 < g' < 1, so the diagram is a staircase.

Answer

x=2x+53x = \sqrt[3]{2x + 5} converges (staircase)

Example 5Newton–Raphson

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

Show the solution
  1. 1Formula

    f′(x)=3x2+1f'(x) = 3x^2 + 1, so xn+1=xn−xn3+xn−13xn2+1x_{n+1} = x_n - \dfrac{x_n^3 + x_n - 1}{3x_n^2 + 1}.

  2. 2Iterate

    x1=1−14=0.75x_1 = 1 - \frac14 = 0.75, x2=0.6860x_2 = 0.6860, x3=0.6823x_3 = 0.6823, x4=0.6823x_4 = 0.6823.

  3. 3Conclude

    The root is 0.68230.6823 to 4 d.p. (Check: f(0.68225)<0<f(0.68235)f(0.68225) < 0 < f(0.68235).)

Answer

0.68230.6823

Example 6When Newton–Raphson fails

Explain why x0=1x_0 = 1 is a bad starting value for Newton–Raphson on f(x)=x3−3x+1f(x) = x^3 - 3x + 1.

Show the solution
  1. 1Compute f′(1)f'(1)

    f′(x)=3x2−3f'(x) = 3x^2 - 3, so f′(1)=0f'(1) = 0.

  2. 2Consequence

    The formula divides by f′(x0)=0f'(x_0) = 0: the tangent is horizontal and never meets the xx-axis.

Answer

f′(1)=0f'(1) = 0: a stationary point

Example 7Trapezium rule

Use the trapezium rule with 4 strips to estimate ∫021+x2 dx\displaystyle\int_0^2 \sqrt{1 + x^2}\,dx to 3 decimal places.

Show the solution
  1. 1Strip width

    h=2−04=0.5h = \frac{2 - 0}{4} = 0.5.

  2. 2Table
    xx00.511.52
    yy11.118031.414211.802782.23607
  3. 3Apply the rule

    0.52[1+2(1.11803+1.41421+1.80278)+2.23607]=0.25×11.90611=2.977\tfrac{0.5}{2}\big[1 + 2(1.11803 + 1.41421 + 1.80278) + 2.23607\big] = 0.25 \times 11.90611 = 2.977.

  4. 4Over or under?

    y=1+x2y = \sqrt{1 + x^2} is convex, so this is an overestimate (true value 2.9582.958).

Answer

2.9772.977 (overestimate)

Beyond the specification

University-level ideas and the deeper mathematics behind this topic. Not needed for exams, but this is where the subject really opens up.

Why a sign change finds a root, and how fast methods converge (university)

The change-of-sign rule is the intermediate value theorem (IVT). It looks obvious, but it is a genuine theorem about the real numbers.

TheoremIntermediate value theorem

If ff is continuous on [a,b][a, b] and f(a)<0<f(b)f(a) < 0 < f(b), then f(c)=0f(c) = 0 for some c∈(a,b)c \in (a, b).

ProofUsing completeness

Let S={x∈[a,b]:f(x)<0}S = \{x \in [a, b] : f(x) < 0\}. It contains aa and is bounded above by bb, so by the completeness axiom it has a least upper bound c=sup⁡Sc = \sup S.

  • If f(c)<0f(c) < 0: by continuity f<0f < 0 on some [c,c+δ)[c, c + \delta), so SS contains points beyond cc. Contradiction.
  • If f(c)>0f(c) > 0: by continuity f>0f > 0 on some (c−δ,c](c - \delta, c], so c−δc - \delta is already an upper bound of SS, smaller than cc. Contradiction.

So f(c)=0f(c) = 0. ■\blacksquare

∎
CounterexampleThe rationals have holes

On the rational numbers, f(x)=x2−2f(x) = x^2 - 2 has f(1)=−1<0<2=f(2)f(1) = -1 < 0 < 2 = f(2), yet no rational cc has f(c)=0f(c) = 0. The IVT fails because {x∈Q:x2<2}\{x \in \mathbb Q : x^2 < 2\} has no rational supremum. Completeness is exactly what rules this out in R\mathbb R.

The proof suggests an algorithm. Bisection halves the interval each time, keeping the half with a sign change (see Q49). After nn steps the root is pinned to an interval of width b−a2n\frac{b - a}{2^n}: about 3.33.3 steps per decimal digit, slow but guaranteed for any continuous ff.

DefinitionOrder of convergence

A sequence xn→αx_n \to \alpha converges with order pp if ∣en+1∣≈C∣en∣p|e_{n+1}| \approx C|e_n|^p for some constant C>0C > 0.

  • p=1p = 1 (with C<1C < 1): linear. Bisection (C=12C = \frac12) and fixed-point iteration (C=∣g′(α)∣C = |g'(\alpha)|).
  • p=2p = 2: quadratic. Newton–Raphson at a simple root.
TheoremThe secant method has golden order

Replace f′(xn)f'(x_n) in Newton–Raphson by the gradient of the chord through the last two points:

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

A Taylor expansion gives en+1≈f′′(α)2f′(α)enen−1e_{n+1} \approx \frac{f''(\alpha)}{2f'(\alpha)}e_ne_{n-1}. Trying ∣en+1∣≈C∣en∣p|e_{n+1}| \approx C|e_n|^p forces p2=p+1p^2 = p + 1, so

p=1+52≈1.618,p = \frac{1 + \sqrt5}{2} \approx 1.618,

the golden ratio. It is slower than Newton per step, but needs no derivative and only one new function value per step, so in practice it is often faster.

History

The bisection idea is in Bolzano's 1817 proof of the IVT, one of the first rigorous proofs in analysis. Before then, "a continuous curve that goes from below the axis to above it must cross it" was simply taken as obvious.

Newton–Raphson in the complex plane and in many dimensions (university)

Newton–Raphson makes sense for complex numbers: zn+1=zn−f(zn)f′(zn)z_{n+1} = z_n - \frac{f(z_n)}{f'(z_n)}. The natural question, first asked by Arthur Cayley in 1879, is: for each starting point, which root do we end up at? The set of starting points that lead to a given root is its basin of attraction.

TheoremCayley's theorem for z2−1z^2 - 1

For f(z)=z2−1f(z) = z^2 - 1, Newton–Raphson converges to 11 from every z0z_0 with Re⁡z0>0\operatorname{Re} z_0 > 0, and to −1-1 from every z0z_0 with Re⁡z0<0\operatorname{Re} z_0 < 0.

ProofA change of variable

The iteration is N(z)=z2+12zN(z) = \frac{z^2 + 1}{2z}. Then

N(z)−1=(z−1)22z,N(z)+1=(z+1)22z,soN(z)−1N(z)+1=(z−1z+1)2.N(z) - 1 = \frac{(z - 1)^2}{2z}, \qquad N(z) + 1 = \frac{(z + 1)^2}{2z}, \qquad\text{so}\qquad \frac{N(z) - 1}{N(z) + 1} = \left(\frac{z - 1}{z + 1}\right)^2.

Put w=z−1z+1w = \frac{z - 1}{z + 1}. In terms of ww, Newton–Raphson is just squaring: wn=w02nw_n = w_0^{2^n}. Now ∣w∣<1|w| < 1 exactly when zz is closer to 11 than to −1-1, i.e. Re⁡z>0\operatorname{Re} z > 0. Then wn→0w_n \to 0, which means zn→1z_n \to 1. Symmetrically, Re⁡z0<0\operatorname{Re} z_0 < 0 gives ∣w0∣>1|w_0| > 1, wn→∞w_n \to \infty and zn→−1z_n \to -1. On the imaginary axis ∣w∣=1|w| = 1 for ever, and the iterates never settle. ■\blacksquare

∎
ParadoxThree roots make a fractal

Cayley could not solve the cubic case z3−1z^3 - 1, and wrote that it "presents considerable difficulty". It was only understood a century later, with computer pictures: the three basins are fractals. Every boundary point of one basin is also a boundary point of both others, so near any boundary all three colours are packed together at every scale. The real 2-cycle at ±15\pm\frac{1}{\sqrt5} for x3−xx^3 - x (Q58) is a glimpse of this.

DefinitionNewton's method for systems

To solve F(x)=0\mathbf F(\mathbf x) = \mathbf 0 for F:Rn→Rn\mathbf F : \mathbb R^n \to \mathbb R^n, replace the tangent line by the tangent (linear) approximation F(xn)+J(xn)(x−xn)\mathbf F(\mathbf x_n) + J(\mathbf x_n)(\mathbf x - \mathbf x_n), where JJ is the Jacobian matrix of partial derivatives Jij=∂Fi∂xjJ_{ij} = \frac{\partial F_i}{\partial x_j}. Setting it to zero:

xn+1=xn−J(xn)−1F(xn).\mathbf x_{n+1} = \mathbf x_n - J(\mathbf x_n)^{-1}\mathbf F(\mathbf x_n).

In practice one solves the linear system Jδ=−FJ\boldsymbol\delta = -\mathbf F rather than inverting JJ. Convergence is again quadratic near a root where JJ is invertible.

ExampleTwo equations

Solve x2+y2=4x^2 + y^2 = 4, xy=1xy = 1, i.e. F=(x2+y2−4, xy−1)\mathbf F = (x^2 + y^2 - 4,\ xy - 1), with J=(2x2yyx)J = \begin{pmatrix}2x & 2y\\ y & x\end{pmatrix}. From (2,0.5)(2, 0.5): F=(0.25,0)\mathbf F = (0.25, 0), and solving Jδ=−FJ\boldsymbol\delta = -\mathbf F gives δ=(−0.0667,0.0167)\boldsymbol\delta = (-0.0667, 0.0167), so (1.9333,0.5167)(1.9333, 0.5167). The exact solution (1.9319,0.5176)(1.9319, 0.5176) is already close.

Mathematical curiosity

Applying Newton–Raphson to f′(x)=0f'(x) = 0 gives Newton's method for optimisation, xn+1=xn−f′(xn)f′′(xn)x_{n+1} = x_n - \frac{f'(x_n)}{f''(x_n)} (Q36 is an example). In many dimensions f′′f'' becomes the Hessian matrix. Training large machine-learning models uses cheaper relatives of this idea, because a Hessian with a billion rows is far too big to store.

Beyond the trapezium rule: Euler–Maclaurin, Romberg and Gauss (university)

The error formula (b−a)h212f′′(η)\frac{(b - a)h^2}{12}f''(\eta) is the first term of something much more precise.

TheoremThe Euler–Maclaurin formula

For smooth ff, the trapezium estimate T(h)T(h) of I=∫abf dxI = \int_a^bf\,dx satisfies

T(h)−I=h212[f′(b)−f′(a)]−h4720[f′′′(b)−f′′′(a)]+h630240[f(5)(b)−f(5)(a)]−⋯T(h) - I = \frac{h^2}{12}\big[f'(b) - f'(a)\big] - \frac{h^4}{720}\big[f'''(b) - f'''(a)\big] + \frac{h^6}{30240}\big[f^{(5)}(b) - f^{(5)}(a)\big] - \cdots

The coefficients are B2k(2k)!\frac{B_{2k}}{(2k)!}, where B2=16B_2 = \frac16, B4=−130,…B_4 = -\frac{1}{30}, \dots are the Bernoulli numbers. Only even powers of hh appear. (The series usually diverges, but truncating it gives an excellent approximation.)

Two consequences:

Mathematical curiosityPeriodic functions are integrated superbly

If ff is smooth and periodic with period b−ab - a, then f(k)(b)=f(k)(a)f^{(k)}(b) = f^{(k)}(a) for every kk, so every term vanishes: the error falls faster than any power of hh. That is why the trapezium rule was exact for ∫02πcos⁡2x dx\int_0^{2\pi}\cos^2x\,dx with only 33 strips (Q57). It is the method of choice for periodic integrals, and the reason the discrete Fourier transform works so well.

TheoremRomberg integration

Since T(h)=I+c1h2+c2h4+⋯T(h) = I + c_1h^2 + c_2h^4 + \cdots, combine two estimates to kill the h2h^2 term:

T(1)(h)=4T(h/2)−T(h)3=I+O(h4).T^{(1)}(h) = \frac{4T(h/2) - T(h)}{3} = I + O(h^4).

This is exactly Simpson's rule (Q60). Repeat with T(2)=16T(1)(h/2)−T(1)(h)15T^{(2)} = \frac{16T^{(1)}(h/2) - T^{(1)}(h)}{15} to kill h4h^4, and so on. The resulting triangle of estimates is Romberg integration: a handful of trapezium sums can give ten correct digits.

ExampleRomberg on ∫0141+x2 dx=π\int_0^1\frac{4}{1 + x^2}\,dx = \pi

T1=3T_1 = 3, T2=3.1T_2 = 3.1, T4=3.131176T_4 = 3.131176, T8=3.138988T_8 = 3.138988. First column: 3.133333, 3.141569, 3.1415933.133333,\ 3.141569,\ 3.141593. Second: 3.142118, 3.1415943.142118,\ 3.141594. Third: 3.1415863.141586. The best entries agree with π=3.1415927\pi = 3.1415927 to about 6 digits, from only 99 function values.

The trapezium and Simpson rules sample at equally spaced points. Choosing the points cleverly does much better.

TheoremGaussian quadrature
∫−11f(x) dx≈f(−13)+f(13)\int_{-1}^1f(x)\,dx \approx f\left(-\tfrac{1}{\sqrt3}\right) + f\left(\tfrac{1}{\sqrt3}\right)

is exact for every cubic, using only two function values. Check: for 1,x,x2,x31, x, x^2, x^3 the rule gives 2,0,23,02, 0, \frac23, 0, matching the exact integrals. More generally, with nn points at the roots of the Legendre polynomial PnP_n and suitable weights, the rule is exact for all polynomials of degree up to 2n−12n - 1, the best possible.

ProofWhy 2n−12n - 1 is the limit

No nn-point rule ∑wif(xi)\sum w_if(x_i) can be exact for the polynomial p(x)=∏(x−xi)2p(x) = \prod(x - x_i)^2, of degree 2n2n: the rule gives 00, but p≥0p \ge 0 and is not identically zero, so ∫p>0\int p > 0. ■\blacksquare

∎

Why does this work?

Why does this work?Why does iteration converge when ∣g′∣<1|g'| < 1?

If α=g(α)\alpha = g(\alpha) is the root, the mean value theorem gives xn+1−α=g(xn)−g(α)=g′(ξ)(xn−α)x_{n+1} - \alpha = g(x_n) - g(\alpha) = g'(\xi)(x_n - \alpha) for some ξ\xi between them. If ∣g′∣≤k<1|g'| \le k < 1 near α\alpha, the error shrinks by a factor kk each step, so ∣xn−α∣≤kn∣x0−α∣→0|x_n - \alpha| \le k^n|x_0 - \alpha| \to 0.

Why does this work?Why is Newton–Raphson so fast?

Newton–Raphson is fixed-point iteration with g(x)=x−f(x)f′(x)g(x) = x - \frac{f(x)}{f'(x)}, and g′(α)=f(α)f′′(α)f′(α)2=0g'(\alpha) = \frac{f(\alpha)f''(\alpha)}{f'(\alpha)^2} = 0. With g′(α)=0g'(\alpha) = 0 the error is roughly squared each step (quadratic convergence), so the number of correct digits doubles.

Beyond the syllabus

Beyond the syllabusThe Banach fixed-point theorem

Let (X,d)(X, d) be a complete metric space and T:X→XT: X \to X a contraction: d(Tx,Ty)≤k d(x,y)d(Tx, Ty) \le k\,d(x, y) for some k<1k < 1. Then TT has exactly one fixed point, and iterating TT from any starting point converges to it.

The same theorem, applied in a space of functions, proves that differential equations y′=f(x,y)y' = f(x, y) have unique solutions (Picard–Lindelöf), and is a first step into functional analysis, where functions are treated as points in infinite-dimensional spaces.

Beyond the syllabusBrouwer's fixed-point theorem

Any continuous map from a closed disc to itself has a fixed point, even if it is not a contraction. Stir a cup of coffee and (if the surface stays a disc) some point ends where it started. The proof needs topology (homology or a combinatorial lemma by Sperner).

Mathematical curiosities

Mathematical curiosityNewton fractals

Run Newton–Raphson on z3=1z^3 = 1 in the complex plane and colour each starting point by which of the three cube roots it reaches. The boundaries between the colours are fractals: near every boundary point, all three colours appear.

Further exploration

Further explorationInvestigations
  • Iterate xn+1=rxn(1−xn)x_{n+1} = rx_n(1 - x_n) for r=2.8,3.2,3.5,3.9r = 2.8, 3.2, 3.5, 3.9. Watch a fixed point split into cycles, then chaos (the logistic map).
  • Show Newton–Raphson for x2=ax^2 = a gives xn+1=12(xn+axn)x_{n+1} = \frac12\left(x_n + \frac a{x_n}\right), the Babylonian method.
Now practise60 questions from Very easy to Extreme →