Mathematics.

numerical integration

Simpson's Rule

Numerical Analysis18 minDifficulty3 out of 10

You should know: numerical integration

Overview

Simpson's rule approximates a definite integral by fitting a quadratic (parabolic) curve through each group of three consecutive sample points, rather than a straight line as in the trapezoidal rule. This extra curvature makes it exact for any polynomial up to degree 3 and gives a truncation error of O(h⁴) — far smaller than the trapezoidal rule's O(h²) for the same step size. The composite version divides [a, b] into an even number n of equal subintervals and applies alternating weights of 4 and 2 to interior nodes, with weight 1 at the endpoints. Because of its high accuracy per function evaluation, Simpson's rule is a standard default quadrature routine in numerical software.

Intuition

Where the trapezoidal rule connects sample points with straight edges, Simpson's rule bends a gentle parabola through each trio of neighboring points, hugging curved data far better than a straight line can. Because a parabola can match not just the height and slope of a smooth curve but also its curvature at the sample points, the resulting piecewise-parabolic approximation tracks the true function much more closely — and since the error term now depends on the fourth derivative rather than the second, Simpson's rule is exact even for cubics and converges dramatically faster as the step size shrinks.

Formal Definition

Definition

On a pair of subintervals [x₀, x₂] of width 2h, fit a parabola through (x₀,f₀), (x₁,f₁), (x₂,f₂) and integrate it exactly:

x0x2f(x)dxh3[f0+4f1+f2]\int_{x_0}^{x_2} f(x)\,dx \approx \dfrac{h}{3}\big[f_0 + 4f_1 + f_2\big]
Simple (single-panel-pair) Simpson's rule
abf(x)dxh3[f0+4 ⁣ ⁣i odd ⁣ ⁣fi+2 ⁣ ⁣i even,0<i<n ⁣ ⁣fi+fn]\int_a^b f(x)\,dx \approx \dfrac{h}{3}\Big[f_0 + 4\!\!\sum_{i \text{ odd}}\!\! f_i + 2\!\!\sum_{i \text{ even}, 0<i<n}\!\! f_i + f_n\Big]
Composite Simpson's rule (n even)
E=(ba)h4180f(4)(ξ),ξ(a,b)E = -\dfrac{(b-a)h^4}{180}f^{(4)}(\xi), \quad \xi \in (a,b)
Error term (f four-times continuously differentiable)

Worked Examples

  1. Step size h = (1−0)/4 = 0.25; nodes x = 0, 0.25, 0.5, 0.75, 1.

    h=0.25h = 0.25
  2. Function values f(x) = 1/(1+x²).

    f0=1,  f1=0.941176,  f2=0.8,  f3=0.64,  f4=0.5f_0=1,\; f_1=0.941176,\; f_2=0.8,\; f_3=0.64,\; f_4=0.5
  3. Apply Simpson's formula (h/3)[f₀ + 4(f₁+f₃) + 2f₂ + f₄].

    0.253[1+4(0.941176+0.64)+2(0.8)+0.5]=0.083333[1+6.324706+1.6+0.5]=0.083333(9.424706)=0.785392\tfrac{0.25}{3}\big[1 + 4(0.941176+0.64) + 2(0.8) + 0.5\big] = 0.083333\,[1 + 6.324706 + 1.6 + 0.5] = 0.083333(9.424706) = 0.785392
  4. Compare with the exact value π/4 ≈ 0.785398.

    0111+x2dx=π40.785398\int_0^1 \dfrac{1}{1+x^2}\,dx = \dfrac{\pi}{4} \approx 0.785398

Answer: Simpson's estimate ≈ 0.785392 vs. exact π/4 ≈ 0.785398 (error ≈ 0.000006, far tighter than the trapezoidal rule's error of 0.0026 on the same nodes).

Practice Problems

Difficulty 3/10

Use Simpson's rule with n = 2 to approximate ∫₀² x³ dx, and compare with the exact value.

Difficulty 5/10

A car's velocity (m/s) at 0, 1, 2, 3, 4 seconds is 0, 3, 8, 15, 24 (v(t) = t² + 2t). Use Simpson's rule with n = 4 to estimate distance traveled.

Difficulty 4/10

Simpson's rule is exact (zero truncation error) for polynomials up to and including degree:

Quiz

Simpson's rule fits which type of curve through each set of three consecutive points?
The truncation error of composite Simpson's rule is of order:
Composite Simpson's rule requires the number of subintervals n to be:

Summary

  • Simpson's rule fits a parabola through each set of three consecutive points: (h/3)[f₀+4f₁+f₂] per panel pair.
  • It is exact for polynomials up to degree 3 and has O(h⁴) truncation error, far better than the trapezoidal rule's O(h²).
  • The composite rule needs an even number of subintervals and alternates weights 4 and 2 on interior nodes.

References