§ 01When Exact Integration Fails
Not every integrand has a nice antiderivative. Functions like e−x², sin(x2), and √(1 + cos² x) cannot be expressed in terms of elementary functions, yet their definite integrals have perfectly well-defined numerical values. Numerical integration methods compute those values to any desired precision without ever finding an antiderivative.
Even when an exact antiderivative exists, numerical methods are often used in engineering and science because the integrand is given as a table of measured values rather than a formula. In those cases, no symbolic method applies at all.
Both methods on this page share the same setup: divide the interval [a, b] into n equal subintervals of width h = (b−a)/n, label the endpoints x0 = a, x1, x2, …, xn = b, and evaluate f at each node.
n must be even for Simpson's Rule. It can be any positive integer for the Trapezoid Rule.
§ 02The Trapezoid Rule — Derivation and Formula
On each subinterval [xi−1, xi], replace the curve with the straight line connecting (xi−1, f(xi−1)) to (xi, f(xi)). The area under that line segment is the area of a trapezoid:
Summing all n trapezoids, the endpoint values f(x0) and f(xn) appear once each; every interior value f(xi) appears in two adjacent trapezoids and therefore carries coefficient 2.
A compact shorthand: Tn = (h/2)[f(x0) + f(xn)] + h∑i=1n−1 f(xi). In plain English: half the step-size times (endpoints once, interior points twice).
Example 1 — Trapezoid Rule with n = 4
| i | xi | f(xi) = 1/xi | Coefficient | Contribution |
|---|---|---|---|---|
| 0 | 1.000 | 1.0000 | 1 | 1.0000 |
| 1 | 1.500 | 0.6667 | 2 | 1.3333 |
| 2 | 2.000 | 0.5000 | 2 | 1.0000 |
| 3 | 2.500 | 0.4000 | 2 | 0.8000 |
| 4 | 3.000 | 0.3333 | 1 | 0.3333 |
| Sum | 4.4667 | |||
Example 2 — Trapezoid Rule with n = 6 on a Tabulated Function
| x | 0 | 0.5 | 1.0 | 1.5 | 2.0 | 2.5 | 3.0 |
|---|---|---|---|---|---|---|---|
| f(x) | 1.0 | 1.8 | 2.3 | 2.1 | 1.6 | 1.2 | 0.9 |
§ 03Simpson’s Rule — Derivation and Formula
The Trapezoid Rule fits straight lines between nodes. Simpson's Rule does better: it fits a quadratic (parabolic arc) through each pair of consecutive subintervals. Since a parabola matches the curve at three points instead of two, the approximation is significantly more accurate for the same n.
On the subinterval [x0, x2], the unique parabola through (x0, f0), (x1, f1), (x2, f2) integrates to give area (h/3)[f0 + 4f1 + f2]. Applying this to every consecutive pair of subintervals and summing:
The 1-4-2-4-2-…-4-1 pattern is the signature of Simpson's Rule. Interior odd-indexed points always carry coefficient 4; interior even-indexed points always carry coefficient 2; the two endpoints carry coefficient 1.
Example 3 — Simpson's Rule with n = 4
| i | xi | f(xi) | Coeff (1,4,2,4,1) | Contribution |
|---|---|---|---|---|
| 0 | 1.000 | 1.0000 | 1 | 1.0000 |
| 1 | 1.500 | 0.6667 | 4 | 2.6667 |
| 2 | 2.000 | 0.5000 | 2 | 1.0000 |
| 3 | 2.500 | 0.4000 | 4 | 1.6000 |
| 4 | 3.000 | 0.3333 | 1 | 0.3333 |
| Sum | 6.6000 | |||
Example 4 — Simpson's Rule with n = 6
This integrand has no elementary antiderivative: numerical integration is the only practical approach.
| i | xi | f(xi) = e−xi² | Coeff | Contribution |
|---|---|---|---|---|
| 0 | 0.0 | 1.000000 | 1 | 1.000000 |
| 1 | 0.5 | 0.778801 | 4 | 3.115203 |
| 2 | 1.0 | 0.367879 | 2 | 0.735759 |
| 3 | 1.5 | 0.105399 | 4 | 0.421598 |
| 4 | 2.0 | 0.018316 | 2 | 0.036631 |
| 5 | 2.5 | 0.001930 | 4 | 0.007722 |
| 6 | 3.0 | 0.000123 | 1 | 0.000123 |
| Sum | 5.317036 | |||
§ 04Error Bounds — Guaranteed Accuracy
Numerical methods give approximations, but mathematics also provides hard upper bounds on how wrong those approximations can be. The error bounds below guarantee that the true error cannot exceed the stated value: regardless of the specific function values.
where M2 = max|f′′(x)| on [a, b]. The error shrinks as 1/n², doubling n quarters the error.
where M4 = max|f(4)(x)| on [a, b]. The error shrinks as 1/n4, doubling n reduces error by a factor of 16. This is why Simpson's Rule is dramatically more efficient than the Trapezoid Rule for smooth functions.
Example 5 — Trapezoid Error Bound
On [1, 3], f′′ is decreasing, so max is at x = 1: M2 = 2/13 = 2.
Example 6 — Simpson's Error Bound
On [0,1], max|f(4)| = e1 = e ≈ 2.718. So M4 = e.
§ 05Comparison, Accuracy and When to Use Each Method
| Property | Trapezoid Rule | Simpson's Rule |
|---|---|---|
| Geometric shape used | Straight lines (trapezoids) | Parabolic arcs |
| Coefficient pattern | 1, 2, 2, …, 2, 1 | 1, 4, 2, 4, …, 4, 1 |
| Multiplier | h/2 | h/3 |
| n restriction | Any positive integer | Must be even |
| Exact for | Linear functions (degree ≤ 1) | Polynomials of degree ≤ 3 |
| Error order | O(h²) — error ∝ 1/n² | O(h4) — error ∝ 1/n4 |
| Derivative needed for error bound | f′′ (second derivative) | f(4) (fourth derivative) |
| Best suited for | Tabulated data with any spacing; quick estimates; linear-ish integrands | Smooth functions; when high accuracy is needed with fewer intervals |
For a smooth function, Simpson's Rule with n = 8 will typically outperform the Trapezoid Rule with n = 100. When the integrand is given only as a table of values with no formula, both rules apply, but the Trapezoid Rule is simpler and has no parity requirement on n.
Example 7 — Comparing Both Methods on the Same Integral
| i | xi | cos(xi) |
|---|---|---|
| 0 | 0 | 1.000000 |
| 1 | π/8 ≈ 0.3927 | 0.923880 |
| 2 | π/4 ≈ 0.7854 | 0.707107 |
| 3 | 3π/8 ≈ 1.1781 | 0.382683 |
| 4 | π/2 ≈ 1.5708 | 0.000000 |
Example 8 — Finding the Minimum n for a Given Accuracy
Since f(4)(x) = 24 (a polynomial of degree exactly 4), and the Simpson error bound involves f(4), you might expect exact results for lower degree polynomials. Indeed, for f = x3, f(4) = 0 and Simpson's Rule is exact with any even n.
§ 0610-Question Quiz
Test your understanding of both numerical methods, coefficient patterns, and error bounds.