Numerical Integration
Trapezoidal Rule
The trapezoidal rule approximates a definite integral by fitting a trapezoid under the curve: T = (h/2)(f(a) + f(b)), h = b - a. Example: f(x)=x², [0,1] gives T=1/2; true value=1/3, error=1/6.
The true integral of x^n over [a,b] is (b^(n+1)-a^(n+1))/(n+1), always rational for integer endpoints and non-negative integer n.
Example
trapezoidal-rule
For a single panel over [a,b] with h=b-a: T = (h/2)(f(a) + f(b))