Skip to content

Trapezoid rule and Simpson's rule

5 min read

Short answer

Trapezoid: ∫abf≈h2[f0+2f1+⋯+2fn−1+fn]\int_a^bf\approx\dfrac h2\big[f_0+2f_1+\cdots+2f_{n-1}+f_n\big]. Simpson (even nn): h3[f0+4f1+2f2+4f3+⋯+4fn−1+fn]\dfrac h3\big[f_0+4f_1+2f_2+4f_3+\cdots+4f_{n-1}+f_n\big]. The trapezoid error shrinks like h2h^2, Simpson's like h4h^4, so Simpson is much more accurate for smooth functions.

Trapezoid compared with SimpsonTrapezoidReplaces f by linesegmentsWeights 1, 2, 2, …, 2,1Error ∝ h²SimpsonReplaces f byparabolasWeights 1, 4, 2, 4, …,4, 1Error ∝ h⁴ (exact forcubics)
Halving h cuts the trapezoid error by 4 and Simpson's by 16.

Why Simpson works so well

Fitting a parabola through three points integrates exactly any polynomial up to degree 3 (the odd cubic part cancels by symmetry). The leading error term involves f(4)f^{(4)}, so functions that are cubic or lower are integrated exactly.

Practical use

Use trapezoid for tabulated, noisy data and Simpson for smooth functions. Doubling nn and comparing results gives a free error estimate.

Worked example

Approximate ∫02x2 dx\int_0^2x^2\,dx with n=2n=2 (h=1h=1) using both rules. The exact value is 83\tfrac83.

Values: f(0)=0f(0)=0, f(1)=1f(1)=1, f(2)=4f(2)=4. Trapezoid: 12[0+2(1)+4]=3\tfrac12[0+2(1)+4]=3 (error 0.330.33). Simpson: 13[0+4(1)+4]=83=2.667\tfrac13[0+4(1)+4]=\tfrac83=2.667 (exact).

Try it yourself

Apply the trapezoid rule with n=4n=4 to ∫01x dx\int_0^1x\,dx.

Show the answer

h=0.25h=0.25: 0.252[0+2(0.25)+2(0.5)+2(0.75)+1]=0.125⋅4=0.5\tfrac{0.25}{2}[0+2(0.25)+2(0.5)+2(0.75)+1]=0.125\cdot4=0.5, exact because ff is linear.

Keep going with practice

Vidi's integration lessons use the same sums of function values that define the integral.