Lemma
← All topics
Further mathematics

Further numerical methods

Sharper integrals and step-by-step solutions to differential equations.

Introduction

Some integrals and differential equations cannot be solved exactly. This optional Further Maths topic gives better numerical integration than the trapezium rule (the mid-ordinate rule and Simpson's rule) and step-by-step methods for differential equations (Euler's method and its improvement).

Why it matters

∫01ex2 dx\int_0^1 e^{x^2}\,dx has no elementary antiderivative, yet engineers need its value. Weather forecasts and spacecraft trajectories come from solving differential equations step by step on computers, using refined versions of exactly these methods.

Intuitive explanation

IntuitionSimpson's rule fits parabolas

The trapezium rule joins points with straight lines. Simpson's rule fits a parabola through each set of three consecutive points, so it follows curves much more closely and is far more accurate for the same number of strips.

IntuitionEuler's method follows the slope

A differential equation tells you the slope at every point. Start at a known point, walk a short distance hh along the slope, recompute the slope, and repeat. Small steps keep you close to the true curve.

Formal definitions

DefinitionMid-ordinate rule

∫aby dx≈h(y12+y32+⋯+yn−12)\displaystyle\int_a^b y\,dx \approx h\left(y_{\frac12} + y_{\frac32} + \dots + y_{n - \frac12}\right), using the heights at the midpoints of the strips.

DefinitionSimpson's rule (nn even)
∫aby dx≈h3[y0+4(y1+y3+… )+2(y2+y4+… )+yn]\int_a^b y\,dx \approx \frac h3\Big[y_0 + 4(y_1 + y_3 + \dots) + 2(y_2 + y_4 + \dots) + y_n\Big]
DefinitionEuler's method

For dydx=f(x,y)\frac{dy}{dx} = f(x, y):  yr+1=yr+hf(xr,yr)\ y_{r+1} = y_r + hf(x_r, y_r),  xr+1=xr+h\ x_{r+1} = x_r + h.

DefinitionImproved Euler (one form)

yr+1=yr+h2[f(xr,yr)+f(xr+1,yr+hf(xr,yr))]y_{r+1} = y_r + \frac h2\left[f(x_r, y_r) + f(x_{r+1}, y_r + hf(x_r, y_r))\right].

Notation

  • hh is the step or strip width.
  • yr≈y(xr)y_r \approx y(x_r).

Comparison

MethodError behaviour
Trapeziumerror roughly ∝h2\propto h^2
Mid-ordinateerror roughly ∝h2\propto h^2, often half the trapezium error
Simpsonerror roughly ∝h4\propto h^4
Eulerglobal error roughly ∝h\propto h

Key results

TheoremSimpson is exact for cubics

Simpson's rule gives the exact integral for any polynomial of degree at most 3.

Why Euler works

IntuitionTangent-line steps

Near xrx_r, y(xr+h)≈y(xr)+hy′(xr)y(x_r + h) \approx y(x_r) + hy'(x_r) (the tangent line). The equation gives y′(xr)=f(xr,yr)y'(x_r) = f(x_r, y_r). Each step uses the tangent at the current point.

ProofSimpson's rule from a parabola

Shift the two strips to [−h,h][-h, h] and fit p(x)=A+Bx+Cx2p(x) = A + Bx + Cx^2 through (−h,y0)(-h, y_0), (0,y1)(0, y_1), (h,y2)(h, y_2). Then A=y1A = y_1 and 2Ch2=y0−2y1+y22Ch^2 = y_0 - 2y_1 + y_2. Integrating,

∫−hhp dx=2Ah+2Ch33=2hy1+h3(y0−2y1+y2)=h3(y0+4y1+y2).\int_{-h}^hp\,dx = 2Ah + \frac{2Ch^3}{3} = 2hy_1 + \frac h3(y_0 - 2y_1 + y_2) = \frac h3\left(y_0 + 4y_1 + y_2\right).

The BxBx term integrates to zero, so BB was never needed. Adding up the pairs of strips gives the composite rule with weights 1,4,2,4,…,4,11, 4, 2, 4, \dots, 4, 1.

∎
ProofEuler's method converges

Let yy be the true solution of y′=f(x,y)y' = f(x, y), er=y(xr)−yre_r = y(x_r) - y_r the error, and suppose ∣fy∣≤L|f_y| \le L and ∣y′′∣≤M|y''| \le M. Taylor's theorem gives y(xr+1)=y(xr)+hf(xr,y(xr))+τry(x_{r+1}) = y(x_r) + hf(x_r, y(x_r)) + \tau_r with ∣τr∣≤Mh22|\tau_r| \le \frac{Mh^2}{2} (the local truncation error). Subtracting the Euler step and using the mean value theorem on ff:

∣er+1∣≤(1+hL)∣er∣+Mh22.|e_{r+1}| \le (1 + hL)|e_r| + \frac{Mh^2}{2}.

With e0=0e_0 = 0 this gives ∣er∣≤Mh22⋅(1+hL)r−1hL≤Mh2L(eL(xr−x0)−1)|e_r| \le \frac{Mh^2}{2}\cdot\frac{(1 + hL)^r - 1}{hL} \le \frac{Mh}{2L}\left(e^{L(x_r - x_0)} - 1\right), using (1+hL)r≤erhL(1 + hL)^r \le e^{rhL}. So the global error is at most a constant times hh: local errors of size h2h^2, accumulated over 1h\frac1h steps and amplified by at most eL(x−x0)e^{L(x - x_0)}. Q53 shows the bound has the right order: for y′=yy' = y the error really is about e2h\frac{e}{2}h.

∎
ProofThe improved Euler method is second order

Expand everything in powers of hh, writing ff, fxf_x, fyf_y for values at (x,y)(x, y). The exact solution satisfies y(x+h)=y+hf+h22(fx+ffy)+O(h3)y(x + h) = y + hf + \frac{h^2}{2}(f_x + ff_y) + O(h^3), since y′′=fx+fyy′y'' = f_x + f_yy'. The method gives

y+h2[f+f(x+h,y+hf)]=y+h2[2f+hfx+hffy+O(h2)],y + \frac h2\left[f + f(x + h, y + hf)\right] = y + \frac h2\left[2f + hf_x + hff_y + O(h^2)\right],

which agrees up to the h2h^2 term. So the local error is O(h3)O(h^3) and the global error O(h2)O(h^2): halving hh quarters the error (Q47).

∎

Methods

MethodTables

Lay out xrx_r, yry_r and f(xr,yr)f(x_r, y_r) in a table, keeping at least 5 significant figures throughout.

Examples

ExampleEuler, one step

dydx=x+y\frac{dy}{dx} = x + y, y(0)=1y(0) = 1, h=0.1h = 0.1: y1=1+0.1(0+1)=1.1y_1 = 1 + 0.1(0 + 1) = 1.1.

See the Worked examples tab.

Common mistakes

Common mistakeOdd nn in Simpson's rule

Simpson's rule needs an even number of strips.

Common mistakeWeights in the wrong order

Odd-numbered ordinates get weight 4, even-numbered interior ones weight 2.

Applications

  • Scientific computing: all ODE solvers refine Euler's idea.
  • Statistics: areas under the normal curve.

Connections

Summary

  • Mid-ordinate: h∑ymidh\sum y_{\text{mid}}. Simpson: h3[y0+4(odd)+2(even)+yn]\frac h3[y_0 + 4(\text{odd}) + 2(\text{even}) + y_n], nn even.
  • Euler: yr+1=yr+hf(xr,yr)y_{r+1} = y_r + hf(x_r, y_r). Smaller hh, better accuracy.

Worked examples

Try each one yourself first, then open the solution.

Example 1Simpson's rule

Use Simpson's rule with 4 strips to estimate ∫121x dx\displaystyle\int_1^2\frac1x\,dx, and compare with the exact value.

Show the solution
  1. 1Ordinates

    h=0.25h = 0.25: y=1,0.8,0.66667,0.57143,0.5y = 1, 0.8, 0.66667, 0.57143, 0.5.

  2. 2Apply

    0.253[1+4(0.8+0.57143)+2(0.66667)+0.5]=0.69325\frac{0.25}{3}\left[1 + 4(0.8 + 0.57143) + 2(0.66667) + 0.5\right] = 0.69325.

  3. 3Compare

    Exact ln⁡2=0.69315\ln 2 = 0.69315: error about 0.00010.0001.

Answer

0.69330.6933

Example 2Euler's method

dydx=x+y\dfrac{dy}{dx} = x + y, y(0)=1y(0) = 1. Use Euler's method with h=0.1h = 0.1 to estimate y(0.3)y(0.3).

Show the solution
  1. 1Step 1

    y1=1+0.1(0+1)=1.1y_1 = 1 + 0.1(0 + 1) = 1.1.

  2. 2Step 2

    y2=1.1+0.1(0.1+1.1)=1.22y_2 = 1.1 + 0.1(0.1 + 1.1) = 1.22.

  3. 3Step 3

    y3=1.22+0.1(0.2+1.22)=1.362y_3 = 1.22 + 0.1(0.2 + 1.22) = 1.362.

Answer

y(0.3)≈1.362y(0.3) \approx 1.362 (exact 1.39971.3997)

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.

Designing Runge–Kutta methods (university)

The improved Euler method samples the slope twice; RK4 (Q51) samples it four times. Where do such formulas come from?

The general form. An ss-stage explicit Runge–Kutta method computes

ki=f(x+cih, y+h∑j<iaijkj),ynew=y+h∑ibiki,k_i = f\left(x + c_ih,\ y + h\sum_{j < i}a_{ij}k_j\right), \qquad y_{\text{new}} = y + h\sum_i b_ik_i,

and is recorded in a Butcher tableau of the numbers cic_i, aija_{ij}, bib_i. Improved Euler has c=(0,1)c = (0, 1), a21=1a_{21} = 1, b=(12,12)b = \left(\frac12, \frac12\right); the midpoint method has a21=12a_{21} = \frac12, b=(0,1)b = (0, 1).

Order conditions. Expanding in powers of hh as in the proof above and matching with the Taylor series of the true solution gives equations for the coefficients. For order pp:

orderconditions (with ci=∑jaijc_i = \sum_ja_{ij})
1∑bi=1\sum b_i = 1
2∑bici=12\sum b_ic_i = \frac12
3∑bici2=13\sum b_ic_i^2 = \frac13,  ∑biaijcj=16\ \sum b_ia_{ij}c_j = \frac16
4four more, e.g. ∑bici3=14\sum b_ic_i^3 = \frac14

For p=2p = 2 with two stages there is a one-parameter family (improved Euler and the midpoint method are two members). John Butcher showed that the conditions correspond to rooted trees, one for each way the derivatives of ff can be nested: 1,1,2,4,9,20,48,…1, 1, 2, 4, 9, 20, 48, \dots new conditions at orders 1,2,3,…1, 2, 3, \dots. There are 88 conditions for order 44, which four stages can just satisfy; order 55 needs 1717 conditions and at least six stages. These "Butcher barriers" explain why RK4 is so popular: it is the highest order you can get for the number of stages.

Simpson in disguise. If ff depends only on xx, the ODE is just an integral, and RK4 becomes h6[f(x)+4f(x+h2)+f(x+h)]\frac h6\left[f(x) + 4f\left(x + \frac h2\right) + f(x + h)\right]: Simpson's rule. Similarly improved Euler becomes the trapezium rule and the midpoint method the mid-ordinate rule. Every quadrature rule you have met is a Runge–Kutta method for the simplest ODE.

Adaptive step size. Practical solvers (such as ode45 in MATLAB or solve_ivp in Python) use embedded pairs: two methods of orders 44 and 55 sharing the same kik_i. Their difference estimates the local error, and the step is shrunk where the solution changes fast and enlarged where it is smooth. This is the answer to Q49: near the blow-up of tan⁡x\tan x an adaptive solver automatically takes tiny steps.

Stability, stiffness and the complex plane (university)

Q36, 54, 55 and 60 showed methods failing not from inaccuracy but from instability. The standard way to study this is to apply a method to the test equation y′=λyy' = \lambda y with complex λ\lambda (complex λ\lambda covers oscillations as well as decay, since systems y′=Ay\mathbf y' = A\mathbf y decouple into such equations along eigenvectors).

The amplification factor. A one-step method gives yr+1=R(z)yry_{r+1} = R(z)y_r with z=λhz = \lambda h. Its region of absolute stability is {z:∣R(z)∣≤1}\{z : |R(z)| \le 1\}:

  • Euler: R=1+zR = 1 + z, the disc of radius 11 centred at −1-1.
  • Improved Euler: R=1+z+z22R = 1 + z + \frac{z^2}{2}, a slightly larger oval region meeting the real axis at [−2,0][-2, 0] (Q54).
  • RK4: R=1+z+z22+z36+z424R = 1 + z + \frac{z^2}2 + \frac{z^3}{6} + \frac{z^4}{24}, reaching about −2.79-2.79 on the real axis and ±2.83i\pm2.83i on the imaginary axis.
  • Backward Euler: R=11−zR = \frac{1}{1 - z}, stable outside the disc of radius 11 centred at +1+1: the whole left half-plane and more (Q55).
  • Trapezium rule (implicit): R=1+z/21−z/2R = \frac{1 + z/2}{1 - z/2}, stable exactly on the left half-plane.

A-stability. A method is A-stable if its region contains the whole left half-plane Re⁡z≤0\operatorname{Re}z \le 0: every decaying solution is computed as decaying, whatever the step size. No explicit Runge–Kutta method can be A-stable, because its RR is a polynomial, and polynomials are unbounded. Implicit methods have rational RR and can be.

Stiffness. A system is stiff when it has some very fast-decaying components alongside the slow ones you care about. In a chemical reaction one species may settle in microseconds while the interesting chemistry takes hours. An explicit method must keep λh\lambda h inside its small stability region for the fastest λ\lambda, forcing microsecond steps for hours of simulated time. An A-stable implicit method can step at the pace of the slow components. The price is solving an equation (usually by Newton's method) every step.

Dahlquist's barriers. For multistep methods like the formula of Q60 (which use several previous values), Germund Dahlquist proved two famous limits (1956, 1963):

  1. A stable kk-step method has order at most about k+2k + 2; the extra roots of its characteristic equation (like μ2\mu_2 in Q60) must not grow.
  2. An A-stable multistep method has order at most 22, and the trapezium rule is the most accurate one.

Convergence = consistency + stability. Dahlquist's equivalence theorem (the ODE counterpart of the Lax equivalence theorem for PDEs) says a multistep method converges as h→0h \to 0 exactly when it is consistent (it has order at least 11) and zero-stable (no root of its characteristic polynomial at h=0h = 0 has size above 11, and roots of size exactly 11 are simple). Accuracy alone is never enough.

Geometric integration: keeping planets in orbit (university)

Simulate a planet, a pendulum or a molecule for a long time and a new issue appears: the method may be accurate over a few steps, yet slowly violate a law the true motion obeys exactly, such as conservation of energy.

Euler spirals outward. For the harmonic oscillator x˙=v\dot x = v, v˙=−x\dot v = -x, the energy E=x2+v2E = x^2 + v^2 is constant. Euler's method gives xr+1=xr+hvrx_{r+1} = x_r + hv_r, vr+1=vr−hxrv_{r+1} = v_r - hx_r, so

xr+12+vr+12=(1+h2)(xr2+vr2).x_{r+1}^2 + v_{r+1}^2 = (1 + h^2)(x_r^2 + v_r^2).

The energy grows by a factor 1+h21 + h^2 every step, about ehTe^{hT} over a time TT: the simulated orbit spirals outwards for ever, however small hh is. Backward Euler spirals inwards. Neither is acceptable for a simulation of the solar system over millions of years.

Symplectic Euler. Change one letter: update vv with the new xx,

xr+1=xr+hvr,vr+1=vr−hxr+1.x_{r+1} = x_r + hv_r, \qquad v_{r+1} = v_r - hx_{r+1}.

Now the quantity xr2+vr2+hxrvrx_r^2 + v_r^2 + hx_rv_r is exactly the same at every step (check by substituting). This "modified energy" differs from EE by O(h)O(h), so the true energy oscillates slightly but never drifts. The orbit stays closed.

Why it works. Hamiltonian systems (frictionless mechanics) have flows that preserve area in phase space (Liouville's theorem), or more precisely a structure called the symplectic form. Euler's map has determinant 1+h2≠11 + h^2 \ne 1, so it expands areas; the symplectic Euler map has determinant exactly 11. A deep result of backward error analysis says that a symplectic method applied to a Hamiltonian system is, up to exponentially small errors, the exact solution of a slightly different Hamiltonian system. So it inherits conserved quantities, stable orbits and long-time behaviour that non-symplectic methods destroy.

Verlet. The central difference scheme of Q57,

θr+1=2θr−θr−1+h2F(θr),\theta_{r+1} = 2\theta_r - \theta_{r-1} + h^2F(\theta_r),

is equivalent to a symmetric version of symplectic Euler (Störmer–Verlet, or leapfrog). It is second order, symplectic and time-reversible, needs one force evaluation per step, and is the workhorse of molecular dynamics, where simulations run for billions of steps. Its two-step form looks like Q60's unstable formula, but for oscillations both characteristic roots lie on the unit circle, which is exactly the situation where such methods behave well.

Beyond. The same philosophy (design methods that respect the structure of the problem: conservation laws, symmetries, positivity, constraints) runs through modern numerical analysis, from Lie group integrators for spinning rigid bodies to structure-preserving schemes for fluid flow and general relativity.

Why does this work?

Why does this work?Why is Simpson's rule so accurate?

It integrates a parabola through each three points exactly. By symmetry it also integrates cubics exactly (the cubic error term is odd about the midpoint and cancels). So its error comes from the fourth derivative, and halving the strip width divides the error by about 16.

Beyond the syllabus

Beyond the syllabusRunge–Kutta methods

Euler's method samples the slope once per step and has error proportional to hh. The classical fourth-order Runge–Kutta method samples it four times, k1=f(x,y)k_1 = f(x, y), k2=f(x+h2,y+h2k1)k_2 = f\left(x + \frac h2, y + \frac h2k_1\right), k3=f(x+h2,y+h2k2)k_3 = f\left(x + \frac h2, y + \frac h2k_2\right), k4=f(x+h,y+hk3)k_4 = f(x + h, y + hk_3), and uses yn+1=yn+h6(k1+2k2+2k3+k4)y_{n+1} = y_n + \frac h6(k_1 + 2k_2 + 2k_3 + k_4), with error proportional to h4h^4. It is Simpson's rule in disguise.

Mathematical curiosities

Mathematical curiosityStiffness

Some equations, such as y′=−1000(y−cos⁡x)y' = -1000(y - \cos x), force explicit methods to take absurdly small steps to stay stable, even though the solution itself is smooth. Implicit methods (which solve an equation at each step) overcome this, and are used in chemistry and circuit simulation.

Further exploration

Further explorationInvestigations
  • Apply Euler's method to y′=yy' = y, y(0)=1y(0) = 1 with step 1n\frac1n to estimate y(1)y(1). Show the estimate is (1+1n)n\left(1 + \frac1n\right)^n, which tends to ee.
Now practise60 questions from Very easy to Extreme →