Estimate an integral with the trapezoidal rule
Approximate ∫₀¹ e^(−x²) dx using the trapezoidal rule with 4 sub-intervals, then bound the error and compare to the true value.
concept: Trapezoidal Rule
Problem
Approximate the integral
using the composite trapezoidal rule with sub-intervals. Then bound the error and compare to the true value.
Approach
The composite trapezoidal rule on with equal sub-intervals is
Geometrically: connect adjacent sample points with straight chords, sum the areas of the resulting trapezoids. Endpoints get weight 1, interior points get weight 2.
Walkthrough
, , , so .
Sample points: .
With :
f(0.00) = e^0 = 1.000000
f(0.25) = e^-0.0625 ≈ 0.939413
f(0.50) = e^-0.25 ≈ 0.778801
f(0.75) = e^-0.5625 ≈ 0.569783
f(1.00) = e^-1 ≈ 0.367879 Sum the interior values (weight 2) and the endpoints (weight 1):
The composite trapezoidal rule has the error bound
Compute :
On , evaluate at the candidates: and . The maximum magnitude is , at .
The true value is
Our trapezoidal estimate was . The actual error is
which is comfortably below the bound of .
Actual error , within the predicted bound of .
Remarks
The error scales as . Doubling shrinks the bound by a factor of 4. To get error below on this integral, you'd need roughly sub-intervals — workable but not great.
For this price, Simpson's rule gives you accuracy for a few extra multiplications per sample. On smooth integrands like , Gaussian quadrature does even better — 6–8 nodes will match what trapezoidal needs hundreds of nodes for.