Euler Hall — free maths guides

The trapezoidal rule

Apply the trapezoidal rule from a table or a formula. The idea in plain words, a worked example, and a check with the answers shown — part of the free Calculus II guides.

Straight tops instead of flat ones

The Riemann sum approximates a curve with rectangles: a flat top at the sample's height. The trapezoidal rule makes one change that costs nothing and improves everything: join the two sampled heights with a straight line.

The area of one piece is then the area of a trapezoid:

Δx2(f(xi−1)+f(xi)),\frac{\Delta x}{2}\left(f(x_{i-1}) + f(x_i)\right),

whereΔx\Delta x is the piece's width and the two heights are the values at its ends.

Adding the pieces up, every interior sample is shared by two neighbouring trapezoids and therefore counted twice, while each end is counted once:

Read that weighting before moving on. Ends once, middles twice. That single sentence is the whole rule, and it is what separates it from the two endpoint sums you already know.

It did not need any new idea. Take the left-endpoint sumLnL_n and the right-endpoint sumRnR_n. Their average is exactlyTnT_n:

Tn=Ln+Rn2.T_n = \frac{L_n + R_n}{2}.

The left sum overstates on a rising curve, the right sum understates, and their average is the straight-line estimate. That is why the trapezoidal rule is nearly always better than either, and why it costs nothing extra to compute.

Why averaging the two endpoint sums is exact for a line

On one piece[xi−1,xi][x_{i-1},x_i], the trapezoid's area isΔx⋅f(xi−1)+f(xi)2\Delta x \cdot \frac{f(x_{i-1})+f(x_i)}{2}. That is exact whenff is a straight line, because the region under a line is exactly a trapezoid — no approximation at all.

For a curve, the straight top is either above the curve (if it is concave up) or below it (if concave down), so the estimate is one-sided. The error is proportional to how much the curve bends, which is whatf′′f'' measures — and that is where the error bound comes from later.

Why the ends count once. Pieceii contributesΔx2f(xi−1)\frac{\Delta x}{2}f(x_{i-1}) andΔx2f(xi)\frac{\Delta x}{2}f(x_i). Summing over every piece, each interior nodexjx_j appears once from the piece to its left and once from the piece to its right:Δx2+Δx2=Δx\frac{\Delta x}{2}+\frac{\Delta x}{2}=\Delta x. The two ends appear once each:Δx2\frac{\Delta x}{2}. FactoringΔx2\frac{\Delta x}{2} back out gives the 1, 2, 2, …, 2, 1 pattern.

The weighting is not a convention to memorise; it falls out of sharing the nodes between neighbouring pieces.

Worked example: a table with four pieces

Estimate∫04f(x) dx\int_0^4 f(x)\,dx from the samplesf(0)=1f(0)=1,f(1)=3f(1)=3,f(2)=2f(2)=2,f(3)=5f(3)=5,f(4)=4f(4)=4.

HereΔx=1\Delta x = 1 and there are four pieces, so:

Check against the two endpoint sums:L4=1+3+2+5=11L_4 = 1+3+2+5 = 11 andR4=3+2+5+4=14R_4 = 3+2+5+4 = 14, and indeed11+142=12.5\frac{11+14}{2} = 12.5. ✓

A note on what a table costs you. Both sums use only the printed values, which is the point: if the function exists only as a table, no antiderivative is available and every route to the answer runs through arithmetic on the samples.

By the end you can
  • Apply the trapezoidal rule from a table or a formula
  • Explain why the ends are weighted once and the interior twice
  • Relate T_n to the average of the left and right sums
Check yourself
  1. 1. Estimate∫04x dx\int_0^4 x\,dx withn=4n=4 byT4T_4. Is it exact? Why?
  2. 2. Estimate∫01x2 dx\int_0^1 x^2\,dx withn=2n=2 byT2T_2, and compare with13\frac13.
  3. 3. A table givesf(1)=2f(1)=2,f(2)=5f(2)=5,f(3)=3f(3)=3. Estimate∫13f\int_1^3 f by the trapezoidal rule.
Answers

1.Δx=1\Delta x=1, values0,1,2,3,40,1,2,3,4:T4=12(0+2+4+6+4)=8T_4=\frac12(0+2+4+6+4)=8. The exact value is[x22]04=8\left[\frac{x^2}{2}\right]_0^4=8, so it is exact — the trapezoidal rule is exact for every straight line, because each piece IS a trapezoid. 2. Values0,14,10,\frac14,1:T2=12(0+12+1)=34T_2=\frac12\left(0+\frac12+1\right)=\frac34. The exact value is13\frac13, so the estimate is high by512\frac{5}{12}. 3.Δx=1\Delta x=1:T2=12(2+2⋅5+3)=152=7.5T_2=\frac12(2+2\cdot5+3)=\frac{15}{2}=7.5.

Work out where to start — free, no accountAnswer six real questions — free, no account