From Panel Areas to Weights
The composite trapezoidal rule approximates an integral by dividing an interval into panels and replacing the function on each panel by the straight line through its endpoint values. The familiar endpoint and interior weights are not arbitrary: they result from integrating those lines and adding the contributions.
The key detail is that adjacent panels share a node. A value at an interior node contributes to both neighboring panels, while each endpoint contributes to only one. This difference accounts for the weights in the composite formula.
Grid and Piecewise Linear Interpolant
Let \(a<b\), and divide \([a,b]\) into \(n\) equal panels, where \(n\) is a positive integer. The grid points are \(x_i=a+ih\), for \(i=0,1,\ldots,n\), with panel width \(h=(b-a)/n\). Write \(y_i=f(x_i)\) for the sampled function values.
At \(x=x_i\), the first coefficient is \(1\) and the second is \(0\), so \(L_i(x_i)=y_i\). At \(x=x_{i+1}\), those coefficients are \(0\) and \(1\), so \(L_i(x_{i+1})=y_{i+1}\). Between the endpoints, this formula describes the straight line connecting the sampled values.
The piecewise linear interpolant is made by using \(L_i\) on every panel. Its integral is the sum of the integrals of the separate panel interpolants. If \(f\) is integrable on \([a,b]\), this gives an approximation to \(\int_a^b f(x)\,dx\); the construction itself only requires the chosen grid values.
Integrating One Panel
To find the contribution from a single panel, use the scaled coordinate \(t=(x-x_i)/h\). As \(x\) moves from \(x_i\) to \(x_{i+1}\), \(t\) moves from \(0\) to \(1\), and \(dx=h\,dt\). In this coordinate, the interpolant is \(L_i(x)=(1-t)y_i+ty_{i+1}\).
This is the trapezoidal contribution from one panel: its width multiplied by the average of the two endpoint heights. The calculation also explains why each endpoint of a single panel receives half of that panel's width as its coefficient.
Summing the Panels Gives the Weights
Add the panel contributions for \(i=0,1,\ldots,n-1\). Each panel contributes \(h/2\) times the sum of its two endpoint values. In the resulting sum, \(y_0\) appears only in the first panel and \(y_n\) only in the last panel. Every other value \(y_i\), where \(1\le i\le n-1\), is shared by the panels on its left and right, so it appears twice.
Replacing \(y_i\) by \(f(x_i)\) gives the composite trapezoidal approximation to the integral of \(f\). The expression is called composite because it combines the trapezoidal contributions from all the panels. The derivation establishes the weights directly: the endpoints have coefficient \(h/2\), and each interior node has coefficient \(h\).
Complete Derivation in Steps
Join the two sampled values at the ends of each panel with a straight line.
The panel integral is \(h/2\) times the sum of its endpoint values.
Linearity of integration makes the integral of the piecewise interpolant the sum of its panel integrals.
Each endpoint occurs once in the panel sum; each interior value occurs in two adjacent panels.
This argument justifies the formula: the weights record how many panel contributions include each grid value. It also shows the scope of the result. The rule is exactly the integral of the piecewise linear interpolant on the specified uniform grid. It is not, in general, an exact formula for the integral of a curved function.
Worked Examples
Worked Example: Deriving the Approximation for \(f(x)=x^2\)
Approximate the integral of \(f(x)=x^2\) on \([0,2]\) using four equal panels. First, \(n=4\) and \(h=(2-0)/4=1/2\). The nodes and values are:
The global weights are \(h/2=1/4\) at the two endpoints and \(h=1/2\) at the three interior nodes. Therefore,
Check by adding the four panel contributions separately:
Their sum is \((1+5+13+25)/16=44/16=11/4\), matching the global-weight calculation. For comparison, the exact integral is \([x^3/3]_0^2=8/3\), so this example also illustrates that the rule need not give the exact integral of a nonlinear function.
Worked Example: A Linear Function on Two Panels
Use two equal panels to approximate \(\int_1^2(3x-2)\,dx\). Here \(n=2\), \(h=(2-1)/2=1/2\), and the nodes are \(x_0=1\), \(x_1=3/2\), and \(x_2=2\). The sampled values are
Applying the derived weights gives
Check directly from the two panel contributions. Each is \(h/2=1/4\) times the sum of its endpoint values, so they are \((1/4)(1+5/2)=7/8\) and \((1/4)(5/2+4)=13/8\). Their sum is \(20/8=5/2\). Since the function is linear, each panel interpolant is the function itself. The exact integral confirms the result:
Worked Example: Recovering Weights from Three Panel Contributions
Suppose a piecewise linear interpolant on \([0,3]\) has unit-width panels and node values \(y_0=2\), \(y_1=0\), \(y_2=4\), and \(y_3=1\). Integrating each panel gives
Adding these values gives \(1+2+5/2=11/2\). The global formula gives the same result:
The check is the direct sum of the panel integrals, which agrees with the weighted expression. In particular, \(y_1\) and \(y_2\) each receive coefficient \(1\): each appears twice with panel coefficient \(1/2\). The endpoint values each retain coefficient \(1/2\).
A Common Weighting Mistake
A frequent mistake is to assign the same half-panel coefficient to every node after summing the panels. That overlooks the fact that each interior node belongs to two panels. For the values in the preceding example, this incorrect calculation would be
which does not equal the panel sum \(11/2\). The correction is to add the panel contributions before collecting coefficients:
The zero value at the first interior node does not contribute numerically in this example, but it still has weight \(1\). The coefficient comes from its occurrence in both adjacent panels, not from the particular value recorded there.
Why the Derivation Is Useful
The derivation lets you rebuild the composite formula rather than memorize a pattern. Begin with a panel: its straight-line interpolant integrates to half the panel width times the sum of its endpoint values. Then sum the panels and count how often each node occurs. The endpoint weights follow from one occurrence, and the interior weights follow from two.
This way of reasoning is also a reliable check when applying the rule: expand the weighted expression or add the panel contributions, and confirm that every node has been counted with the appropriate multiplicity. The conclusion here concerns the weights and the integral of the piecewise linear interpolant; questions about the size or direction of the approximation error require additional results.
Check Your Understanding
Use the panel-integral derivation to answer these questions. For calculation questions, show the panel contributions as well as the collected weights.
- Why does an endpoint value appear once in the panel sum, while an interior value appears twice?
- For a uniform grid of width \(h\), what is the integral of the linear interpolant on one panel with endpoint values \(u\) and \(v\)?
- Write the composite weights for a grid with four panels, identifying the coefficients of the two endpoints and the three interior nodes.
- For unit-width panels and node values \(1,3,2\), calculate the sum of the two panel contributions and then collect the global weights.
- Does integrating the piecewise linear interpolant necessarily give the exact integral of the original function? Explain what the derivation guarantees.