A numerical integral is a claim about everything a function does between two endpoints, even though a computer evaluates it at only finitely many points. Quadrature replaces the function by a simpler object whose integral we can calculate. The crucial questions are which simpler object we chose, how its samples are weighted, and what assumptions control the part we did not observe.
The composite trapezoid rule integrates a piecewise linear interpolant. Simpson's rule integrates a quadratic interpolant over each pair of subintervals, yet is also exact on cubic polynomials. We will derive both formulas, prove their error bounds with the correct signs and constants, and use one exact example to distinguish an error certificate from an estimate based on refinement.
Count subintervals before writing weights
Let , and write the desired integral as . Divide the interval into equal subintervals, with
There are sample points, including both endpoints. This distinction prevents a common off-by-one error in both the step size and the weights. The trapezoid rule allows every integer ; the composite Simpson rule below requires to be even.
The initial derivations assume exact function values and exact arithmetic. We will return to the effect of evaluation error separately.
Common mistake
(Counting sample points instead of subintervals)
Using the number of samples as gives the wrong step size: five sample points mean subintervals and . The error also affects Simpson's rule, which needs an even number of subintervals, so five samples are admissible but six are not.
Integrate straight lines to get the trapezoid rule
On one subinterval , the line through the two endpoint values has integral . Add these integrals over all subintervals. An interior sample belongs to two adjacent lines, while an endpoint belongs to only one.
Definition 7.7.1
(The composite trapezoid and Simpson formulas)
The composite trapezoid approximation is
For even , the composite Simpson approximation is
An empty sum is zero. In particular, the last sum is empty when .
The trapezoid weights are positive and sum to . Thus the rule integrates constant functions correctly. It also integrates linear functions exactly, because their linear interpolants are the functions themselves. Neither fact means it is exact on a general curved graph.
Derive Simpson's weights, including cubic exactness
Consider three nodes . With , they become . Their quadratic Lagrange basis polynomials are , and . Their integrals over are . Multiplying by the coordinate factor gives the one-panel formula
The formula is therefore exact on all quadratics. It is also exact on : that function is odd about the midpoint, so both its integral and the weighted endpoint sum vanish. Every cubic is a quadratic plus a multiple of , proving cubic exactness.
Joining the disjoint panels , , and so on gives the composite weights. Odd-indexed nodes are panel midpoints and have weight 4; interior even-indexed nodes are shared panel endpoints and have weight 2. This is why an even number of subintervals is part of this particular rule's definition.
There is also an exact algebraic identity, on the same nested grids:
It follows by comparing endpoint, odd-node and even-node coefficients. This identity between weighted sums is exact; interpreting such cancellation as an estimate of an unknown integration error requires an additional argument.
A derivative bound gives an actual error certificate
Theorem 7.7.2
(Composite trapezoid error bound)
If and throughout the interval, then
If moreover , then .
Proof
(The trapezoid error is a signed second-derivative average)
On a single interval , put . Its endpoint values vanish, , and integration by parts twice gives
The nonnegative weight has integral . Thus the absolute error is at most . Summing over the subintervals of width gives .
The same identity gives a sign conclusion: if , then . The trapezoid approximation overestimates the integral of a convex twice-differentiable function.
Theorem 7.7.3
(Composite Simpson error bound)
If , throughout the interval, and is even, then
If moreover , then .
Proof
(A fourth-derivative kernel for one Simpson panel)
On the reference interval , let mean integral minus the Simpson weighted sum. Taylor's formula with integral remainder, based at , writes as a cubic plus
Here is the function's argument; terms with vanish. Since annihilates cubics, applying and interchanging the integrals yields . Directly integrating the truncated cubic and inserting its three sampled values gives
This kernel is nonpositive on , and its integral is . Therefore .
For an actual panel , use . Its fourth derivative is , while the integral acquires another factor . The local absolute error is at most . There are panels, giving .
The kernel also proves that implies . Simpson's sign is controlled by the fourth derivative here, not by convexity alone.
Proof X-ray
Where the fourth derivative, the sign and the constant come from
Three steps carry the argument. First, cubic exactness lets us subtract the degree-three Taylor polynomial, so only the integral remainder with is left. Second, the kernel has a single sign on ; this turns into the bound and fixes the sign of the error whenever has one sign. Third, the scaling contributes from the derivative and one more from the integral, so each panel carries ; summing panels costs one power of and leaves . Without cubic exactness the first step fails and the argument yields only a third-order result.
These are guaranteed bounds under the stated derivative assumptions, not conclusions drawn only from the sample values.
The kernel proof explains why merely bounding a quadratic interpolation remainder and ignoring its cancellation would miss the fourth-order result. Cubic exactness removes another term, and the signed weight identifies the remaining derivative and constant.
Common mistake
(Convexity does not give the sign of Simpson's error)
For a convex function the trapezoid rule overestimates, because the sign of is controlled by . Simpson's error is controlled by instead, so a convex function with is underestimated by Simpson's rule. Check the derivative that actually appears in the error formula.
Compute a refinement table exactly
Worked example 7.7.4
(Integrate x to the fourth power on [0,1])
For , the exact integral is . The derivative bounds and are valid on .
| Rule | Approximation | Absolute error | Derivative-based bound |
|---|---|---|---|
For example, . The composite Simpson error is exactly at its stated bound because the fourth derivative is the constant 24. Halving the step reduces this error by exactly .
The trapezoid bounds are valid but conservative. Its two observed errors have a ratio close to 4, not exactly 4: the error can contain terms beyond its leading second-order term. A worst-case bound is not an equality for every function or grid.
Worked example 7.7.5
(A cubic with )
Take on with , so and the even-index sum in is empty. The exact value is . The trapezoid value is , with : an overestimate, as predicts, and within the bound . Simpson gives , exact because gives . The identity checks: and .
To plan a mesh for absolute error at most , rearrange the bounds before evaluating the samples. The trapezoid condition is . Simpson requires together with even . This is a certified sufficient choice only when the derivative bounds themselves have been justified over the whole interval.
Worked example 7.7.6
(Planning a mesh for )
Let on and . On , , so are valid. The trapezoid condition is , so with samples. The Simpson condition is ; since and , the smallest even is , with samples. As a check, gives the bound , while gives .
Refinement estimates have an extra assumption
Suppose, for a sufficiently smooth fixed function on these uniform grids, the Simpson error has a nonzero leading term . After halving the step, its leading term is divided by 16. Subtracting the two approximations gives the estimate
This is useful when the asymptotic expansion describes the current mesh. It is not a guaranteed bound solely because the function is smooth or the two answers are close. The analogous leading-order trapezoid estimate uses divisor 3. If the leading coefficient vanishes or the grid is too coarse for the leading term to dominate, the observed ratios can differ.
For , the Simpson error consists exactly of its fourth-order term, so . That exact success on a polynomial is not a certificate for an arbitrary function.
Counterexample mode
Two agreeing grid answers can both miss a positive integral
On , define
This is a smooth nonnegative polynomial. It is zero at every node used by and , so both approximations and their difference are zero. But it is positive between those finitely many zeros, so its integral is strictly positive. Multiplying the function by any positive constant leaves both sampled answers zero while scaling its actual integral.
A derivative-bound certificate is not contradicted: multiplying the function also multiplies its derivative bound. The mistake is treating an unproved numerical error estimate as if it were an independent derivative bound.
Separate integration error from evaluation error
Both rules have positive weights whose sum is . If every supplied value differs from the exact by at most , the resulting weighted sum differs from the exact-value rule by at most . The triangle inequality therefore bounds total error by the stated quadrature bound plus , before accounting for arithmetic roundoff in forming the sum.
The distinction matters when refining. Adding more nodes can reduce interpolation error while leaving evaluation error unchanged or increasing accumulated floating-point work. A theorem about in exact arithmetic does not by itself certify the output of a floating-point program. Reusing the old evaluations on a refined nested grid saves work, but does not change any of these mathematical assumptions.
Exercises with solutions
Quick check
(Integrate on using and . Verify the trapezoid bound using , and explain Simpson's result without a fourth-derivative estimate.)
Solution · Answer
The exact integral is . The trapezoid value is , giving error . Its bound is , attained exactly. Simpson gives because it integrates every quadratic exactly.
Quick check
(For on , find the smallest trapezoid and the smallest even Simpson guaranteed by the displayed derivative bounds to give absolute error at most . Compare the numbers of sample values.)
Solution · Answer
The trapezoid bound is , so suffices and is the smallest integer allowed by this bound. It needs 101 samples.
The Simpson bound is . At it is , while at it is . Since the bound decreases with , 8 is the smallest even choice that it certifies, using 9 samples. This compares sufficient derivative-based guarantees for this function, not a universal fixed speedup.
Quick check
(A student claims that Simpson always overestimates a convex smooth function. Test on with , giving both a derivative argument and the exact error.)
Solution · Answer
Here , so the function is convex. But , so the Simpson kernel identity gives : the rule underestimates. Directly, and , hence . Convexity controls the trapezoid sign; the fourth derivative controls the Simpson sign in this theorem.
Quick check
(On an interval of length , a known bound gives . Every supplied sample has absolute error at most . What total error bound follows before summation roundoff? Does a tiny refinement difference remove the evaluation-error term?)
Solution · Answer
The positive weights sum to 2, so evaluation error contributes at most . The triangle inequality gives total error at most before arithmetic roundoff. A tiny refinement difference does not remove this term: errors can persist in both weighted sums, and agreement is not an independent bound on the exact sampled values.
Answer warning: The interactive below reveals results for the exercises above, including the minimum meshes in the fourth-power exercise. Try the exercises before opening it.