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=(ba)/n , xi=a+ih , yi=f(xi) ,

abf(x)dxh2(y0+2y1++2yn1+yn).

Error / Accuracy

If f is continuous,

E=(ba)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)=1432=38=0.375.

Exact: 1/30.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 ↩︎