Tutorials › AP Statistics › When Trapezoidal Samples Miss Oscillation

Numerical and BC Integration Methods · Tutorial 538 of 999

When Trapezoidal Samples Miss Oscillation

Learn why node values alone may conceal substantial oscillation, and how a bound on curvature can provide a meaningful error guarantee.

Advanced 9 min read

What You'll Learn

  • Write the composite trapezoidal estimate for equally spaced nodes.
  • Calculate an exact integral that the sampled node values fail to reveal.
  • Explain why identical node data can correspond to very different integrals.
  • State and apply the composite trapezoidal error bound.
  • Identify when a trapezoidal estimate needs additional information to support an accuracy claim.

Why a Smooth Graph Can Still Fool a Numerical Estimate

The trapezoidal rule estimates an integral by joining sampled values with straight line segments and adding the areas of the resulting trapezoids. If the function changes gradually between sample points, this can be an effective approximation. But a smooth function can also oscillate rapidly between those points. Its sampled values may then give little indication of what happens between them.

This is an important limitation: a numerical estimate is based on both the sampled values and assumptions about the integrand. The samples alone do not generally certify that an estimate is accurate.

The Composite Trapezoidal Rule

Let \(f\) be continuous on \([a,b]\), and divide the interval into \(n\) equal subintervals, where \(n\) is a positive integer. The step size and nodes are

$$ h=\frac{b-a}{n}, \qquad x_j=a+jh \quad (j=0,1,\ldots,n). $$

The composite trapezoidal estimate for \(\int_a^b f(x)\,dx\) is

$$ T_n = \frac{h}{2} \left[ f(x_0)+2\sum_{j=1}^{n-1}f(x_j)+f(x_n) \right]. $$

The endpoints receive half-weight in the formula, and each interior sample receives full weight. Equivalently, on each subinterval the rule uses the trapezoid whose parallel sides have heights given by the function values at that subinterval’s endpoints.

Definition: The trapezoidal error is the difference between the estimate and the exact integral, \(T_n-\int_a^b f(x)\,dx\). Its magnitude is \(\left|T_n-\int_a^b f(x)\,dx\right|\).

Worked Example: Three Oscillations Hidden at Every Node

Worked Example: Three Oscillations Hidden at Every Node

Estimate \(\int_0^1\sin(3\pi x)\,dx\) using three equal subintervals, then compare the estimate with the exact integral.

First, \(n=3\), \(a=0\), and \(b=1\), so the step size is

$$ h=\frac{1-0}{3}=\frac13. $$

The nodes are \(x_0=0\), \(x_1=\frac13\), \(x_2=\frac23\), and \(x_3=1\). At each node, the sine value is zero:

$$ \begin{aligned} f(0)&=\sin(0)=0,\\ f\left(\frac13\right)&=\sin(\pi)=0,\\ f\left(\frac23\right)&=\sin(2\pi)=0,\\ f(1)&=\sin(3\pi)=0. \end{aligned} $$

Therefore the trapezoidal estimate is

$$ T_3 = \frac{1/3}{2} \left[ 0+2(0+0)+0 \right] =0. $$

But the exact integral is

$$ \begin{aligned} \int_0^1\sin(3\pi x)\,dx &=\left[-\frac{\cos(3\pi x)}{3\pi}\right]_0^1\\ &=\frac{-\cos(3\pi)+\cos(0)}{3\pi}\\ &=\frac{-(-1)+1}{3\pi} =\frac{2}{3\pi} \approx 0.2122. \end{aligned} $$

The estimate is zero even though the integral is positive. The reason is that each sample lands at a zero of the sine function; the nodes fail to register the positive and negative parts between them.

Why Node Values Alone Cannot Guarantee Accuracy

The example is not just an unusual calculation. It shows a basic limitation of finite sampling. Consider \(f_A(x)=A\sin(3\pi x)\) on \([0,1]\), where \(A\) is any positive constant. At the same four nodes, every value is still zero, so \(T_3=0\) for every \(A\). Yet

$$ \int_0^1 f_A(x)\,dx = A\int_0^1\sin(3\pi x)\,dx = \frac{2A}{3\pi}. $$

For any chosen positive number \(M\), taking \(A=\frac{3\pi M}{2}\) makes the exact integral equal to \(M\), while the estimate remains zero. Thus the same node values can be consistent with integrals of arbitrarily large size. These functions are all smooth; smoothness by itself does not prevent the problem.

Key takeaway: A finite list of function values determines the trapezoidal estimate, but does not, by itself, bound the difference between that estimate and the integral. An accuracy guarantee needs additional information about how the function behaves between nodes.

A Curvature Bound Gives an Error Guarantee

One useful kind of additional information is a bound on the function’s second derivative. Curvature matters because the trapezoidal rule replaces each piece of the graph by a straight line. If the graph bends sharply between nodes, that line can differ substantially from the function.

Theorem: If \(f\) has a continuous second derivative on \([a,b]\), and \(\left|f''(x)\right|\leq M\) throughout the interval, then the composite trapezoidal estimate with \(n\) equal subintervals satisfies $$ \left|T_n-\int_a^b f(x)\,dx\right| \leq \frac{M(b-a)^3}{12n^2}. $$

Why the Error Bound Works

Here is a derivation. On one subinterval \([x_j,x_{j+1}]\), let \(L(x)\) be the line joining the endpoint values of \(f\). The area under \(L\) is exactly the trapezoid’s area on that subinterval. The linear interpolation remainder says that, for each interior \(x\), there is a point \(\xi_x\) in the subinterval such that

$$ f(x)-L(x) = \frac{f''(\xi_x)}{2}(x-x_j)(x-x_{j+1}). $$

Since \(|f''(\xi_x)|\leq M\), and the two factors have opposite signs inside the subinterval, this gives

$$ |f(x)-L(x)| \leq \frac{M}{2}(x-x_j)(x_{j+1}-x). $$

Write \(t=x-x_j\), so \(0\leq t\leq h\) and \(x_{j+1}-x=h-t\). The difference between the exact area and the trapezoid’s area is at most

$$ \begin{aligned} \int_{x_j}^{x_{j+1}}|f(x)-L(x)|\,dx &\leq \frac{M}{2}\int_0^h t(h-t)\,dt\\ &=\frac{M}{2}\left[\frac{ht^2}{2}-\frac{t^3}{3}\right]_0^h\\ &=\frac{M}{2}\left(\frac{h^3}{2}-\frac{h^3}{3}\right) =\frac{Mh^3}{12}. \end{aligned} $$

There are \(n\) subintervals. Adding their error bounds gives \(nMh^3/12\). Since \(h=(b-a)/n\), this is

$$ \frac{nM}{12}\left(\frac{b-a}{n}\right)^3 = \frac{M(b-a)^3}{12n^2}. $$

This proves the stated bound. The important condition is the available bound \(M\) on \(|f''|\). If the function oscillates more rapidly, its second derivative may be much larger, so the bound may be large even when the step size is small.

Worked Example: Estimating an Error Using Curvature

Worked Example: Estimating an Error Using Curvature

Use two subintervals to estimate \(\int_0^1\sin(\pi x)\,dx\), and use the error bound to assess the estimate.

The step size is \(h=(1-0)/2=1/2\), and the nodes are \(0\), \(1/2\), and \(1\). The function values are

$$ \sin(0)=0, \qquad \sin\left(\frac{\pi}{2}\right)=1, \qquad \sin(\pi)=0. $$

Thus

$$ T_2 = \frac{1/2}{2}[0+2(1)+0] = \frac12. $$

The exact integral and the actual error are

$$ \int_0^1\sin(\pi x)\,dx = \left[-\frac{\cos(\pi x)}{\pi}\right]_0^1 = \frac{2}{\pi}, \qquad \left|T_2-\frac{2}{\pi}\right| = \frac{2}{\pi}-\frac12 \approx 0.1366. $$

To apply the theorem, differentiate twice:

$$ f'(x)=\pi\cos(\pi x), \qquad f''(x)=-\pi^2\sin(\pi x). $$

On \([0,1]\), \(|\sin(\pi x)|\leq 1\), so \(|f''(x)|\leq\pi^2\). We may take \(M=\pi^2\). The error bound is therefore

$$ \left|T_2-\int_0^1 f(x)\,dx\right| \leq \frac{\pi^2(1-0)^3}{12(2)^2} = \frac{\pi^2}{48} \approx 0.2056. $$

The actual error, approximately \(0.1366\), is less than the bound, approximately \(0.2056\). This check confirms that the bound applies correctly here; it is a guarantee, not necessarily the exact error.

A Common Mistake: Treating a Small Estimate as Proof of a Small Integral

A tempting but incorrect conclusion from the first example is: “All four samples are zero, so the integral must be zero.” The calculation only establishes that the trapezoidal estimate is zero:

$$ T_3 = \frac{1/3}{2}[0+2(0+0)+0] =0. $$

It does not establish that the function is zero between the nodes. In fact, direct integration gives \(\int_0^1\sin(3\pi x)\,dx=2/(3\pi)\), not zero. The correction is to distinguish the estimate from the integral and seek information—such as a second-derivative bound—that controls their difference.

This issue matters in practice whenever a graph or function is sampled at a fixed spacing. If the spacing is coarse relative to the oscillation, important changes can occur between measurements. A plausible-looking numerical output is not, on its own, evidence that those changes are negligible.

Check Your Understanding

Use the definitions and error bound to explain what the samples establish—and what they do not.

  1. For \(f(x)=\sin(3\pi x)\) on \([0,1]\) with three equal subintervals, list the node values and calculate \(T_3\).
  2. Evaluate \(\int_0^1\sin(3\pi x)\,dx\). Why does its value differ from the trapezoidal estimate?
  3. For \(f_A(x)=A\sin(3\pi x)\), what is the trapezoidal estimate on the same nodes, and what is the exact integral?
  4. State the assumptions and formula for the composite trapezoidal error bound.
  5. For \(f(x)=\sin(\pi x)\) on \([0,1]\), identify a valid value of \(M\) for the error bound and explain what \(M\) measures.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers all of AP Calculus AB & BC: full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon