When Exact Integration Fails
Some integrals cannot be expressed in terms of elementary functions — for example, ∫e^(−x²)dx. Numerical methods approximate the integral to any desired accuracy using only function evaluations.
The Trapezoid Rule
Instead of rectangles (Riemann sums), use trapezoids. For n subintervals of width h = (b−a)/n:
Simpson's Rule
Simpson's Rule uses parabolas instead of straight lines — dramatically more accurate for smooth functions. Requires n to be even:
The pattern of coefficients is 1, 4, 2, 4, 2, ..., 4, 1.
Error Bounds
Trapezoid error ≤ (b−a)³/(12n²) · max|f''|. Simpson's error ≤ (b−a)⁵/(180n⁴) · max|f⁴|. Simpson's is far more accurate — the error decreases as n⁴ rather than n².
Frequently Asked Questions
When Exact Integration Fails
Many integrals cannot be expressed in closed form. The Gaussian integral ∫e^(−x²)dx, the error function, Fresnel integrals, and elliptic integrals have no elementary antiderivative. This is not a gap in technique — it is a proved theorem. For these, numerical methods are the only option.
Why the Trapezoid Rule Works
Instead of rectangles (Riemann sums), connect adjacent points with straight lines. Each strip is a trapezoid with area = ½(f(xᵢ) + f(xᵢ₊₁))·h. Summing n trapezoids gives: T = h/2·[f(x₀) + 2f(x₁) + 2f(x₂) + ... + 2f(xₙ₋₁) + f(xₙ)]. The first and last points get coefficient 1; all interior points get 2.
Why Simpson's Rule Is So Much Better
Simpson's rule fits a parabola through every three consecutive points. A parabola is an exact fit for quadratic functions, and a good fit for smooth functions in general. The coefficients 1, 4, 2, 4, 2, ..., 4, 1 come from integrating the Lagrange interpolating polynomial through those points. The key requirement: n must be even (pairs of subintervals).
Worked Comparison
Error Bounds — How Accurate Are You?
Simpson's error decreases as n⁴ — doubling n reduces the error by a factor of 16. Trapezoid error decreases as n², so doubling n only reduces error by 4. This is why Simpson's is preferred for smooth functions: you need far fewer function evaluations to achieve the same accuracy.
Adaptive Integration
Modern numerical integrators use adaptive step sizes — they automatically refine the partition in regions where f changes rapidly and use fewer points where f is smooth. This is how computer algebra systems like MATLAB, Python's scipy.integrate, and Wolfram Alpha compute definite integrals. The underlying algorithm is usually an adaptive Simpson or Gauss-Kronrod quadrature rule.