Tutorials › AP Calculus › Deriving the Trapezoidal Rule from Linear Interpolation

Riemann Sums and Definite Integrals · Tutorial 438 of 999

Deriving the Trapezoidal Rule from Linear Interpolation

Learn why joining adjacent endpoint values with straight lines leads to the trapezoidal rule, and how to calculate and check the resulting estimate.

Beginner 9 min read

What You'll Learn

  • Write the line that interpolates between two endpoint values.
  • Derive the trapezoid contribution from width and endpoint heights.
  • Add contributions across a partition, including unequal-width subintervals.
  • Use the simplified composite formula when all subintervals have equal width.
  • Distinguish signed contributions from ordinary geometric area when values cross zero.
  • Identify common errors involving the factor of one-half and interval widths.

From Endpoint Values to Trapezoids

A function may curve between the points where its values are known. A numerical estimate can be made by replacing each short piece of the graph with a straight segment joining its endpoint values. The region between that segment and the horizontal axis is a trapezoid when the endpoint values are above the axis.

This replacement is called linear interpolation. It gives a direct reason for the trapezoidal rule: on each subinterval, use the area under the interpolating line, then add the contributions from all the subintervals. The result is an estimate for a curved graph, and it is exact when the function itself is linear on each subinterval.

Definition: On an interval \([x_{i-1},x_i]\), linear interpolation replaces the function values at the endpoints with the straight line passing through \((x_{i-1},f(x_{i-1}))\) and \((x_i,f(x_i))\). The trapezoidal rule adds the signed areas under these interpolating line segments.

Deriving the Formula on One Subinterval

Let the subinterval run from \(x_{i-1}\) to \(x_i\), with width \(h_i=x_i-x_{i-1}>0\). Write \(y_{i-1}=f(x_{i-1})\) and \(y_i=f(x_i)\). The line that connects the endpoint values is

$$ L_i(x)=y_{i-1}+\frac{y_i-y_{i-1}}{h_i}(x-x_{i-1}). $$

This equation has the required endpoint values. Substituting \(x=x_{i-1}\) makes the last term zero, so \(L_i(x_{i-1})=y_{i-1}\). Substituting \(x=x_i\) gives \(x_i-x_{i-1}=h_i\), and therefore \(L_i(x_i)=y_{i-1}+(y_i-y_{i-1})=y_i\).

If both endpoint values are nonnegative, the area under this line is the area of a trapezoid. Its parallel sides have lengths \(y_{i-1}\) and \(y_i\), and the perpendicular distance between them is \(h_i\). The area is the width multiplied by the average of the two heights:

$$ A_i=h_i\frac{y_{i-1}+y_i}{2} =\frac{x_i-x_{i-1}}{2}\bigl(f(x_{i-1})+f(x_i)\bigr). $$

The same expression gives the signed area under the interpolating line if an endpoint value is negative. Signed area counts portions below the horizontal axis as negative. If the line crosses the axis, the formula gives the net contribution, not the total ordinary area of the two pieces.

Key result: The trapezoidal contribution on one subinterval is its width times the average of its two endpoint values. The average is essential: using the sum of the endpoint values alone doubles the result.

A Second View of the Derivation

The formula can also be justified by splitting the interpolating region into a rectangle and a triangle. Begin with a rectangle of width \(h_i\) and signed height \(y_{i-1}\). The change from the left endpoint height to the right endpoint height is \(y_i-y_{i-1}\), so the extra triangular contribution is \(\frac12h_i(y_i-y_{i-1})\). The triangle's contribution is signed: it is negative when the line slopes downward.

$$ \begin{aligned} A_i &=h_i y_{i-1}+\frac{1}{2}h_i(y_i-y_{i-1})\\ &=\frac{1}{2}h_i(2y_{i-1}+y_i-y_{i-1})\\ &=\frac{1}{2}h_i(y_{i-1}+y_i). \end{aligned} $$

This derivation explains why the endpoint values are averaged. The interpolating line changes steadily from one endpoint height to the other, so its average height over the interval is the average of those endpoint heights. Multiplying that average by the width gives the area contribution.

Adding Contributions Across a Partition

Suppose the interval is divided at \(x_0,x_1,\ldots,x_n\), where \(x_0<x_1<\cdots<x_n\). Each subinterval can have its own width \(h_i=x_i-x_{i-1}\). Applying the one-subinterval formula and adding all the pieces gives the composite trapezoidal estimate:

$$ T=\sum_{i=1}^{n}\frac{x_i-x_{i-1}}{2} \bigl(f(x_{i-1})+f(x_i)\bigr). $$

The sum combines adjacent trapezoids. An interior function value appears twice in the expanded sum: once as the right endpoint of one subinterval and once as the left endpoint of the next. For equal-width subintervals, this gives a useful simplified form.

$$ T=\frac{h}{2} \bigl(f(x_0)+2f(x_1)+2f(x_2)+\cdots+2f(x_{n-1})+f(x_n)\bigr), \qquad h=\frac{x_n-x_0}{n}. $$

This simplified form requires all subintervals to have the same width \(h\). If the widths differ, use the sum with the individual widths instead.

Why the interior values have weight two: Each interior point is shared by two neighboring trapezoids, so its height is counted in both contributions. The two outer endpoint values each belong to only one trapezoid.

Worked Example: One Interpolated Segment

Worked Example: One Interpolated Segment

Suppose a function has value \(2\) at \(x=1\) and value \(6\) at \(x=4\). Estimate the signed area under the straight-line interpolation on this interval.

First find the width: \(h=4-1=3\). The endpoint heights are \(y_0=2\) and \(y_1=6\). The interpolating line is

$$ L(x)=2+\frac{6-2}{4-1}(x-1) =2+\frac{4}{3}(x-1). $$

Check the endpoints: \(L(1)=2+\frac43(0)=2\), and \(L(4)=2+\frac43(3)=2+4=6\). The trapezoidal contribution is

$$ A=\frac{3}{2}(2+6) =\frac{3}{2}(8) =12. $$

As a check using a rectangle and a triangle, the rectangle contributes \(3(2)=6\), and the triangle contributes \(\frac12(3)(6-2)=6\). Their sum is \(6+6=12\), matching the formula. If the horizontal axis is measured in seconds and the function in meters per second, the area has units of meters.

Worked Example: Unequal Subinterval Widths

Worked Example: Unequal Subinterval Widths

A rate is measured at \(x=0,1,3,4\), with values \(1,3,2,5\), respectively. Use linear interpolation on each subinterval to estimate the signed accumulated amount.

The subinterval widths are \(1-0=1\), \(3-1=2\), and \(4-3=1\). Calculate each trapezoid separately:

$$ \begin{aligned} A_1&=\frac{1}{2}(1+3)=2,\\ A_2&=\frac{2}{2}(3+2)=5,\\ A_3&=\frac{1}{2}(2+5)=\frac{7}{2}=3.5. \end{aligned} $$

Add the contributions: \(T=2+5+3.5=10.5\). Thus the estimate is \(10.5\) rate-units times \(x\)-units. To check, the interpolating lines on the three subintervals are \(L_1(x)=1+2x\), \(L_2(x)=3-\frac12(x-1)\), and \(L_3(x)=2+3(x-3)\). Substitution at each interval's endpoints gives the stated pairs of values \((1,3)\), \((3,2)\), and \((2,5)\); their trapezoidal contributions are exactly \(2\), \(5\), and \(3.5\).

Worked Example: Equal-Width Subintervals

Worked Example: Equal-Width Subintervals

A function is sampled at \(x=0,2,4,6,8\), with respective values \(0,2,3,3,1\). Use the composite trapezoidal rule.

There are four subintervals, each of width \(h=2\). Use the equal-width formula:

$$ \begin{aligned} T &=\frac{2}{2}\bigl(0+2(2)+2(3)+2(3)+1\bigr)\\ &=1(0+4+6+6+1)\\ &=17. \end{aligned} $$

Checking by calculating each trapezoid separately gives \(\frac22(0+2)=2\), \(\frac22(2+3)=5\), \(\frac22(3+3)=6\), and \(\frac22(3+1)=4\). Their sum is \(2+5+6+4=17\). The matching results confirm that the shared interior heights were counted twice in the simplified formula.

Signed Contributions When a Segment Crosses the Axis

The trapezoidal expression still applies when the interpolating line crosses the horizontal axis, but its meaning needs care. Consider a line with endpoint values \(-2\) and \(4\) across a width of \(3\). The signed trapezoidal contribution is

$$ \frac{3}{2}(-2+4)=3. $$

For a direct check, the line rises by \(6\) over a width of \(3\), so its slope is \(2\). Starting at height \(-2\), it reaches zero after \(1\) unit of horizontal distance. The triangular region below the axis has area \(\frac12(1)(2)=1\), counted as \(-1\). The triangular region above the axis has area \(\frac12(2)(4)=4\). Their signed total is \(-1+4=3\), as the formula gives. The total ordinary geometric area would instead be \(1+4=5\).

Common Mistakes

Pitfall: Forgetting to divide the sum of the endpoint heights by \(2\). For endpoint values \(2\) and \(6\) across a width of \(3\), the incorrect calculation \(3(2+6)=24\) is twice the correct contribution. The correction is \(3(2+6)/2=12\).

Another common error is applying the equal-width formula to a partition whose widths differ. For example, the subintervals in the unequal-width example have widths \(1,2,1\); there is no single \(h\) that can be factored out for all three trapezoids. Use each width in its own term.

Finally, a trapezoidal estimate uses the straight segment between sampled endpoint values. If the original function curves between those points, the interpolating line does not generally match the graph there. The estimate is exact for a function that is linear on every subinterval; otherwise it is an approximation. The direction and size of its error depend on the function's behavior, not on the area formula alone.

Check Your Understanding

Use the interpolation formula and show the endpoint or arithmetic checks in your work.

  1. What is the trapezoidal contribution for endpoint values \(3\) and \(7\) across a subinterval of width \(2\)?
  2. Write the equation of the line interpolating between \((2,1)\) and \((5,4)\), and verify its endpoint values.
  3. For values \(2,4,1\) at \(x=0,1,3\), calculate the composite trapezoidal estimate using the individual widths.
  4. Why does an interior value have weight two in the equal-width composite formula?
  5. For endpoint values \(-3\) and \(1\) across width \(4\), calculate the signed trapezoidal contribution. Explain why it need not equal the total ordinary area.

Test yourself: AP Calculus practice exams

Ready to check what you know? Work an AP-style practice exam, then open the full solutions.

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