From a Trapezoidal Estimate to an Error Guarantee
The composite trapezoidal rule approximates a definite integral by adding the areas of trapezoids across equal subintervals. The estimate itself is useful, but it does not say how far the estimate could be from the exact integral. A second-derivative bound supplies a guaranteed maximum error, provided the function satisfies the required conditions.
That guarantee also answers a practical question: how many subintervals should be used to make the error no greater than a chosen tolerance? The key is that the bound decreases in proportion to the square of the number of subintervals.
The Composite Trapezoidal Error Bound
Suppose \(f\) has a continuous second derivative on \([a,b]\), and suppose a number \(K\) is known such that \(|f''(x)|\le K\) throughout the interval. Then the composite trapezoidal rule satisfies the following bound:
The value \(K\) must be an upper bound for the absolute value of the second derivative everywhere on the interval, not merely at the endpoints or at a few sample points. A larger valid \(K\) still gives a valid error bound, although it may require more subintervals to meet a requested tolerance.
Because the bound contains \(n^2\) in the denominator, doubling the number of equal subintervals divides the guaranteed maximum error by four. The bound also depends strongly on the interval length: with \(K\) fixed, its numerator includes \((b-a)^3\).
Why the Bound Works
On each small subinterval, the trapezoidal rule integrates the straight line joining the function’s endpoint values. The difference between the function and that line is controlled by the second derivative. Adding the resulting local bounds gives a bound for the whole interval.
Write its endpoints as \(u\) and \(v\), with \(v-u=h\), and let \(L(x)\) be the line through \((u,f(u))\) and \((v,f(v))\). The trapezoid’s area is \(\int_u^v L(x)\,dx\).
For an interior point \(x\), the interpolation remainder gives \(f(x)-L(x)=\frac{f''(\xi)}{2}(x-u)(x-v)\) for some \(\xi\) between \(u\) and \(v\). Thus \(|f(x)-L(x)|\le \frac{K}{2}(x-u)(v-x)\).
Integrating the nonnegative product gives \(\int_u^v (x-u)(v-x)\,dx=h^3/6\). Therefore the absolute error on this subinterval is at most \(Kh^3/12\).
There are \(n\) subintervals, so the total absolute error is at most \(nKh^3/12\). Substituting \(h=(b-a)/n\) gives \(K(b-a)^3/(12n^2)\).
For completeness, the interpolation remainder in Step 2 follows from Rolle’s theorem. Fix an interior point \(x\) and set \(c=(f(x)-L(x))/((x-u)(x-v))\). The function \(g(t)=f(t)-L(t)-c(t-u)(t-v)\) is zero at \(u\), \(x\), and \(v\). Applying Rolle’s theorem twice shows that \(g''(\xi)=0\) for some \(\xi\) between \(u\) and \(v\). Since \(L''(t)=0\) and the second derivative of \((t-u)(t-v)\) is \(2\), this gives \(f''(\xi)-2c=0\), which is the stated remainder formula. The endpoint cases have \(f(x)-L(x)=0\), so they satisfy the same inequality.
Worked Example: Bounding the Error for a Quadratic
Worked Example: Bounding the Error for a Quadratic
Use \(n=3\) equal subintervals to approximate \(\int_{-1}^{2}x^2\,dx\). Find the trapezoidal estimate, the actual error, and the error bound.
Here \(f(x)=x^2\), so \(f''(x)=2\) and we may take \(K=2\). The interval length is \(b-a=2-(-1)=3\), and \(h=3/3=1\). The nodes are \(-1,0,1,2\), where the function values are \(1,0,1,4\), respectively.
The exact integral is \(\int_{-1}^{2}x^2\,dx=[x^3/3]_{-1}^{2}=8/3-(-1/3)=3\). Thus the absolute error is \(|3-3.5|=0.5\).
The calculated error equals the bound, so this example also checks that the stated bound holds for these values.
Choosing a Sufficient Number of Subintervals
Suppose the desired absolute error is at most a positive tolerance \(\varepsilon\). It is sufficient to choose \(n\) so that the error bound is no greater than \(\varepsilon\):
When \(K>0\), solve this inequality for \(n\). Since \(n\) is a positive integer, round the resulting threshold up to the next integer:
This choice guarantees that the error is no larger than the tolerance. It does not generally tell us the actual error, nor does it prove that a smaller number of subintervals would fail. It identifies the smallest integer that satisfies this particular error-bound inequality.
Worked Example: Choosing Subintervals for a Tolerance
Worked Example: Choosing Subintervals for a Tolerance
How many equal subintervals are sufficient for the composite trapezoidal rule to approximate \(\int_0^1 \cos x\,dx\) with error at most \(0.01\)?
For \(f(x)=\cos x\), \(f''(x)=-\cos x\). On \([0,1]\), \(|f''(x)|=|\cos x|\le 1\), so \(K=1\) is valid. The interval length is \(1\), and \(\varepsilon=0.01\). Therefore, the bound requires
The least integer at least \(2.887\) is \(3\). Substituting \(n=3\) back into the bound gives \(\frac{1}{12(3)^2}=\frac{1}{108}\approx 0.00926<0.01\). Thus \(3\) subintervals are sufficient by the theorem.
For comparison, \(n=2\) gives a bound of \(\frac{1}{48}\approx 0.02083\), which exceeds the tolerance. That means the bound does not certify two subintervals; it does not, by itself, prove that the actual error with two subintervals is greater than \(0.01\).
Worked Example: Using a Derivative Bound on a Longer Interval
Worked Example: Using a Derivative Bound on a Longer Interval
For \(f(x)=\ln(1+x)\) on \([0,2]\), find a sufficient number of equal subintervals to guarantee an error no greater than \(0.005\).
The derivatives are \(f'(x)=1/(1+x)\) and \(f''(x)=-1/(1+x)^2\). For \(0\le x\le 2\), \(|f''(x)|=1/(1+x)^2\le 1\), so take \(K=1\). The interval length is \(2\). Substituting these values and \(\varepsilon=0.005\) gives
Round up to \(n=12\). Substitution into the error bound gives \(\frac{8}{12(12)^2}=\frac{8}{1728}=\frac{1}{216}\approx 0.00463<0.005\). For \(n=11\), the bound is \(\frac{8}{12(11)^2}=\frac{8}{1452}=\frac{2}{363}\approx 0.00551>0.005\). Therefore, \(12\) is the smallest integer that meets the requested tolerance using this bound.
A Common Mistake: Rounding Down
A frequent error is to find the real-number threshold for \(n\) and then round it to the nearest integer, or down to the nearest integer. But the inequality requires \(n\) to be at least that threshold. Rounding down can violate the guarantee.
In the cosine example, the threshold is approximately \(2.887\). Choosing \(n=2\) because it is the nearest lower integer gives the bound \(1/48\approx 0.02083\), which is not at most \(0.01\). The correction is to use the ceiling: \(n=\lceil 2.887\rceil=3\). Checking the bound after rounding confirms that \(1/108\approx 0.00926\le 0.01\).
Why the Bound Matters
A numerical estimate is most useful when its accuracy can be assessed. The second-derivative bound turns information about a function’s curvature into a guaranteed limit on the trapezoidal error. It also makes the effect of subdivision precise: for fixed \(K\) and interval, the bound falls as \(1/n^2\).
The bound is conservative. It may be larger than the actual error, as a bound must allow for every function satisfying its assumptions. A small bound guarantees accuracy within the stated tolerance; a bound larger than the tolerance means only that this guarantee has not been obtained. In applications, \(K\) must be justified over the entire interval, and the units of the bound match the units of the integral: \(K\) has units of function value per squared input unit, so \(K(b-a)^3\) has units of function value times input unit.
Check Your Understanding
Use the theorem and the distinction between an error bound and actual error to answer these questions.
- State the differentiability condition and the inequality required for \(K\).
- For an interval of length \(4\), with \(K=3\) and \(n=6\), what error bound does the theorem give?
- For interval length \(1\), \(K=2\), and tolerance \(0.02\), what is the least subdivision count certified by the bound?
- If the bound is greater than a requested tolerance, what can and cannot be concluded about the actual error?
- Why must a real-valued threshold for \(n\) be rounded up rather than down?