Numerical Integration: Trapezoid and Simpson's Rule
Apply the Trapezoid Rule and Simpson's Rule to approximate definite integrals. Understand when these approximations are needed (non-elementary integrands) and analyze the error in each method.
A lesson of Calculus, in Integration and the Fundamental Theorem, about 10 minutes.
By the end of this lesson, you will be able to apply the Trapezoid Rule and Simpson's Rule to approximate definite integrals, state the error bounds, and choose the appropriate method based on accuracy needed.
Why Numerical Integration?
Many functions have no closed-form antiderivative: $e^{-x^2}$, $\sin(x^2)$, $\dfrac{\sin x}{x}$. For these, numerical methods provide accurate approximations.
Trapezoid Rule
Replace each subinterval with a trapezoid (two sample points per subinterval).
$$T_n = \frac{\Delta x}{2}[f(x_0) + 2f(x_1) + 2f(x_2) + \cdots + 2f(x_{n-1}) + f(x_n)]$$
Error bound: $|E_T| \leq \dfrac{M(b-a)^3}{12n^2}$ where $M = \max|f''(x)|$ on $[a,b]$.
Simpson's Rule
Use parabolas through three points per pair of subintervals (requires $n$ even).
$$S_n = \frac{\Delta x}{3}[f(x_0) + 4f(x_1) + 2f(x_2) + 4f(x_3) + \cdots + 4f(x_{n-1}) + f(x_n)]$$
Pattern of coefficients: $1, 4, 2, 4, 2, \ldots, 4, 2, 4, 1$.
Error bound: $|E_S| \leq \dfrac{M(b-a)^5}{180n^4}$ where $M = \max|f^{(4)}(x)|$ on $[a,b]$.
Simpson's Rule is far more accurate for smooth functions.
Example 1 — Trapezoid Rule
Approximate $\int_0^1 e^{-x^2},dx$ using $n = 4$.
$\Delta x = 0.25$; points: $0, 0.25, 0.5, 0.75, 1$
$f$ values: $1, 0.9394, 0.7788, 0.5698, 0.3679$
$T_4 = \frac{0.25}{2}[1 + 2(0.9394) + 2(0.7788) + 2(0.5698) + 0.3679]$
$= 0.125[1 + 1.8788 + 1.5576 + 1.1396 + 0.3679] = 0.125 \times 5.9439 \approx 0.7430$
Actual: $\approx 0.7468$ (error $\approx 0.004$)
Example 2 — Simpson's Rule
Same integral, $n = 4$.
$S_4 = \frac{0.25}{3}[1 + 4(0.9394) + 2(0.7788) + 4(0.5698) + 0.3679]$
$= \frac{0.25}{3}[1 + 3.7576 + 1.5576 + 2.2792 + 0.3679]$
$= \frac{0.25}{3}(8.9623) \approx 0.7469$
Error $\approx 0.0001$ — much better than Trapezoid with the same $n$.
Comparison: Trapezoid vs. Simpson's
| Method | Error order | Good for |
|---|---|---|
| Trapezoid | $O(n^{-2})$ | Quick approximation |
| Simpson's |