All courses › Numerical Methods › Simpson's rule

Simpson's rule

Simpson's rule approximates the integral by fitting a parabola through each pair of intervals, instead of a straight line. It integrates polynomials up to degree 3 exactly, and the error is O(h4)O(h^4) — halving hh roughly cuts the error to a sixteenth.

∫x0x2f dx≈h3(f0+4f1+f2)\int_{x_0}^{x_2} f\,dx \approx \frac{h}{3}\big(f_0 + 4f_1 + f_2\big)Simpson's rule over one double interval

Symbols

hhstep size between neighbouring points
f0,f1,f2f_0, f_1, f_2function values at the endpoints and midpoint

Example

∫03x2 dx\int_0^3 x^2\,dx with h=1.5h = 1.5:

h3(f0+4f1+f2)=9\frac{h}{3}(f_0 + 4f_1 + f_2) = 9 — exact, since the degree is 2≤32 \leq 3.

Simpson's rule needs an even number of intervals (an odd number of points).
Practise interpolation and integration for free →

← Trapezoidal rule · Polynomial interpolation →

Part of Numerical Methods: Interpolation and integration.