Approximating an Integral from Equally Spaced Values
A definite integral can represent a total accumulated quantity, such as distance from velocity or mass from a density. Sometimes the function is known only at selected input values, or evaluating an exact antiderivative is inconvenient. A numerical quadrature rule uses function values at chosen points to estimate the integral.
The composite trapezoidal rule is built from a sequence of adjacent trapezoid estimates. Its key bookkeeping feature is that the two endpoint values receive half-weights, while each interior value receives a full weight. The rule applies when the nodes divide the interval into equal-width panels.
There are \(n\) panels but \(n+1\) nodes: the endpoints and the points between them. The common width \(h\) is positive because \(b>a\). The formula uses the values of \(f\) at those nodes; it does not require evaluating \(f\) between nodes in order to calculate \(T_n\).
Why the Endpoint and Interior Weights Differ
On one panel \([x_i,x_{i+1}]\), the trapezoid estimate is the panel width multiplied by the average of the two endpoint heights: \( \frac{h}{2}\left[f(x_i)+f(x_{i+1})\right] \). The composite rule adds these estimates for all \(n\) adjacent panels. This addition explains the weights: an endpoint belongs to just one panel, but an interior node is shared by two neighboring panels.
This argument also gives a practical check: a calculation using the weighted formula should agree with the sum of the individual panel estimates. The formula estimates the integral; it is not, in general, an exact identity for the integral.
A Reliable Calculation Procedure
Before substituting values, determine which values are endpoints and which are interior. A useful procedure is:
Record \(n\), and confirm that the given data contain \(n+1\) node values.
Calculate \(h=(b-a)/n\), or verify the spacing in a supplied table.
Use one-half for each endpoint and weight one for every interior value in the equivalent \(h[\cdots]\) form.
Evaluate the weighted sum, then compare it with the sum of the separate panel estimates when practical.
Worked Examples
Worked Example: Approximate the Integral of \(x^2\)
Use four equal panels to approximate \(\int_0^2 x^2\,dx\). First, \(n=4\), so the panel width is
The nodes are \(x_i=0+i/2\), giving \(0,\frac12,1,\frac32,2\). Evaluating \(f(x)=x^2\) gives the values \(0,\frac14,1,\frac94,4\). There are five values, as required for four panels.
Apply the endpoint and interior weights:
Check by adding the four panel estimates. Each panel has width \(1/2\), so its trapezoid estimate is \(1/4\) times the sum of its endpoint values:
The panel check agrees with the weighted formula. The result is an approximation to the integral, not a claim that the integral itself equals \(11/4\).
Worked Example: Use Function Values at the Nodes
Approximate \(\int_0^1 \frac{1}{1+x^2}\,dx\) using four equal panels. Here \(h=(1-0)/4=1/4\), and the nodes are \(0,\frac14,\frac12,\frac34,1\). The corresponding function values are
Use the half-weights at the endpoints and full weights at the three interior nodes:
For an independent check, calculate each panel separately. Every panel has width \(1/4\), so the multiplier is \(h/2=1/8\):
To add these fractions, use denominator \(6800\):
Thus the approximation is \(\frac{5323}{6800}\), or \(0.782794\) to six decimal places. The panel calculations agree with the composite formula.
Worked Example: An Exact Check with a Linear Function
Use three equal panels to approximate \(\int_1^3 (2x+1)\,dx\). The width is \(h=(3-1)/3=2/3\), and the nodes are \(1,\frac53,\frac73,3\). The function values are
There are two interior values. Substitution gives
Check against the exact integral using the antiderivative \(x^2+x\):
The trapezoidal value agrees with the exact value in this example. This check verifies the arithmetic; it does not mean every function will give an exact result with the rule.
Common Weighting Mistake
A frequent error is to use the same coefficient for every node, as though the composite rule were simply the panel width times half the sum of all the listed values. For the first example, that incorrect calculation would be
This is not the composite trapezoidal rule: it gives the interior values only one occurrence, although each belongs to two adjacent panel estimates. The correction is to double the interior values inside the \(h/2\) formula, or equivalently to use \(h\) times the interior sum and half of each endpoint value. For the same data, the correct result is \(11/4=2.75\).
Another practical safeguard is to count the entries before calculating. With \(n\) panels, there must be \(n+1\) node values: two endpoints and \(n-1\) interior values. If the spacing is not equal, the common-\(h\) formula above does not apply as written.
Using the Rule Carefully
The composite trapezoidal rule turns a list of equally spaced function values into one estimate for an integral. Its weights follow directly from adding the panel estimates: endpoints occur once, and interior nodes occur twice. Keeping that structure visible helps prevent both missing values and incorrect weights.
When applying the rule, report the interval, number of panels, width, and approximation clearly. Keep exact fractions during the calculation when they are manageable, and round only the final decimal if one is needed. The rule provides an estimate; establishing how accurate that estimate is requires additional error analysis.
Check Your Understanding
Answer these questions using the definitions and examples above.
- If an interval is divided into seven equal panels, how many nodes are there, and how many interior nodes?
- Write the composite trapezoidal formula for \(n\) panels, identifying the endpoint and interior weights.
- For nodes \(x_0,\ldots,x_n\), why does each interior function value receive twice the coefficient of an endpoint in the \(h/2\) form?
- What is the common panel width when \([a,b]\) is divided into \(n\) equal panels?
- Explain why using the same weight for every node gives an incorrect composite trapezoidal calculation.