Simpson's Rule vs. the Trapezoidal Rule

Two classic ways to approximate a definite integral by hand — side-by-side formulas, two fully worked examples, and an honest answer to "which one should I use?"

The one-line intuition

Both rules split [a, b] into n equal subintervals of width h = (b − a)/n and sample the function at the endpoints. The difference is what they draw between the samples:

  • Trapezoidal rule: connects consecutive points with straight lines, so the area under each segment is a trapezoid.
  • Simpson's rule: fits a parabola through each consecutive triple of points (so n must be even), then integrates the parabolas exactly.

Because parabolas hug a smooth curve better than straight lines, Simpson's rule is usually far more accurate for the same amount of work — but the trapezoid has its own niches, covered below.

The formulas

Let x₀ = a, x₁, …, xₙ = b and yₖ = f(xₖ).

  1. Trapezoid: Tₙ = (h/2)·(y₀ + 2y₁ + 2y₂ + … + 2yₙ₋₁ + yₙ) — weights 1, 2, 2, …, 2, 1. Works for any n.
  2. Simpson: Sₙ = (h/3)·(y₀ + 4y₁ + 2y₂ + 4y₃ + 2y₄ + … + 4yₙ₋₁ + yₙ) — weights 1, 4, 2, 4, …, 4, 1. n must be even.

Notice both rules sample the function at the same n+1 points. Simpson's extra accuracy costs zero extra function evaluations — it comes purely from the smarter 1-4-2-4-…-1 weighting.

Worked example 1: ∫₀π sin(x) dx = 2

Take n = 4, so h = π/4 ≈ 0.78540. The sample values are 0, 0.70711, 1, 0.70711, 0 (sin at 0, π/4, π/2, 3π/4, π).

  1. Trapezoid: T₄ = (h/2)·(1.41421 + 2 + 1.41421) = 0.39270 × 4.82843 ≈ 1.89612 — error ≈ 0.1039.
  2. Simpson: S₄ = (h/3)·(2.82843 + 2 + 2.82843) = 0.26180 × 7.65685 ≈ 2.00456 — error ≈ 0.0046.
  3. Simpson is about 23× closer with the same five sample points.

Worked example 2: ∫₀¹ eˣ dx = e − 1 ≈ 1.71828

Take n = 2 (the minimum Simpson allows), so h = 0.5. Values: 1, 1.64872, 2.71828.

  1. Trapezoid: T₂ = 0.25 × 7.01572 ≈ 1.75393 — error ≈ 0.0356.
  2. Simpson: S₂ = (0.5/3) × 10.31317 ≈ 1.71886 — error ≈ 0.00058.
  3. With just three points, Simpson's error is 60× smaller. Exponentials are smooth, and parabolas track them beautifully.

Want to confirm these on your own numbers? The numerical integration tool here evaluates ∫ sin(x) dx and friends to 10 digits.

The comparison cheat sheet

  • Error order: trapezoid error shrinks like h², Simpson's like h⁴. Doubling n cuts the trapezoid error by 4×, the Simpson error by 16×. Simpson's accuracy compounds fast.
  • Same cost: for the same n, both evaluate f at n+1 points. Simpson's accuracy is free.
  • Even n only: Simpson needs an even number of subintervals. If you're stuck with an odd n (or an odd number of data points), the trapezoid is the answer.
  • Uneven data: with irregularly spaced samples — typical for measured data — neither formula applies directly. The trapezoid generalizes naturally (each trapezoid uses its own width); Simpson does not.
  • Kinks and corners: Simpson assumes smoothness. On a function with a sharp corner inside an interval, the parabola fit is no better than a straight line, and the trapezoid is simpler and just as good.

Rules of thumb

  1. Smooth function, even n: use Simpson. Every time. The worked examples above are why.
  2. Odd number of points or uneven spacing: use the trapezoid — or split the interval at the kink so each piece is smooth, then use Simpson on the pieces.
  3. In doubt: compute both with the same samples and compare against a finer Simpson grid. If they disagree, trust the finer one and refine again.

Frequently asked questions

Which is more accurate, Simpson's rule or the trapezoidal rule?

Simpson's rule, by a wide margin on smooth functions: its error shrinks like h⁴ versus the trapezoid's h². Doubling n cuts the trapezoidal error by 4× but Simpson's by 16×.

Does Simpson's rule need an even number of subintervals?

Yes — it fits a parabola through each triple of consecutive points, so n must be even. The trapezoidal rule works for any n, which is one of the few situations where the trapezoid is the only option.

When should I use the trapezoidal rule instead of Simpson's?

With unevenly spaced data (typical of measurements), functions with kinks or corners, or an odd number of subintervals. The trapezoid's straight-line interpolation is the honest, robust choice there.

Does Simpson's rule cost more function evaluations?

No. For the same n, both rules sample the function at the same n+1 points — the extra accuracy comes entirely from the 1-4-2-4-…-1 weighting. It's free accuracy on smooth functions.