Trapezoidal Rule

Summary

The trapezoidal rule approximates the area under y=f(x) by trapezoids. The composite rule is second-order accurate for smooth f .

Prerequisites

Integrals, Riemann Sum

Formula / Iteration Rule

With h=(b−a)/n , xi=a+ih , yi=f(xi) ,

∫abf(x)dx≈h2(y0+2y1+⋯+2yn−1+yn).

Error / Accuracy

If f″ is continuous,

E=−(b−a)12h2f″(ξ)

for some ξ∈(a,b) . Thus the error is O(h2) .

Worked Example

∫01x2dx with n=2 , h=1/2 :

1/22(0+2⋅(1/2)2+1)=14⋅32=38=0.375.

Exact: 1/3≈0.333 .

Common Failure Modes

Visual Explanation

![[TrapezoidalRule.mp4]]

Connections

References

Composite trapezoidal quadrature is standard.[1]


  1. NIST DLMF, §3.5 Quadrature, https://dlmf.nist.gov/3.5 ↩︎