Quant Memo
Core

The Trapezoid and Simpson Rules

Two simple recipes for estimating the area under a curve when you only know its value at a handful of points — replacing the true curve with straight lines or gentle parabolas that are easy to integrate exactly.

Prerequisites: Numerical Stability and Error Analysis

Pricing a European option under a model with no closed-form solution often reduces to computing an integral — the expected payoff, averaged over a probability density. Computers can't integrate symbolically; they can only evaluate a function at specific points and combine those values. The trapezoid and Simpson rules are the two most basic recipes for this: replace the true curve between sample points with something simple enough to integrate exactly — a straight line, or a gentle curve — and add up the areas of those pieces.

An analogy: estimating a field's area from fence posts

Imagine a field with a wavy boundary on one side, and you can only measure the boundary's height at a few evenly-spaced fence posts. The crudest honest estimate connects each pair of adjacent posts with a straight line and adds up the areas of the resulting trapezoids — simple, and reasonable if the boundary doesn't wiggle much between posts. A better estimate fits a smooth, gently curving arc (specifically a parabola) through each group of three consecutive posts instead of a straight line, hugging the true wavy boundary more closely and giving a noticeably better area estimate for the same number of posts measured.

The math, one piece at a time

The trapezoid rule approximates abf(x)dx\int_a^b f(x)\,dx by chopping [a,b][a,b] into nn equal strips of width h=banh = \frac{b-a}{n}, and on each strip approximating ff with the straight line connecting its two endpoints — turning each strip into an actual trapezoid, whose area has a simple formula:

abf(x)dxh2[f(x0)+2f(x1)+2f(x2)++2f(xn1)+f(xn)].\int_a^b f(x)\,dx \approx \frac{h}{2}\Big[f(x_0) + 2f(x_1) + 2f(x_2) + \cdots + 2f(x_{n-1}) + f(x_n)\Big] .

In words: every interior sample point is counted twice (it's the shared edge of two neighboring trapezoids) and the two endpoints are counted once, all multiplied by half the strip width — this is just "average the two end-heights of each trapezoid, times its width," summed over all strips. The error shrinks proportional to h2h^2: halving the strip width quarters the error.

Simpson's rule instead fits a parabola through each group of three consecutive points (so it needs an even number of strips), giving a noticeably better formula for the same sample points:

abf(x)dxh3[f(x0)+4f(x1)+2f(x2)+4f(x3)++4f(xn1)+f(xn)],\int_a^b f(x)\,dx \approx \frac{h}{3}\Big[f(x_0) + 4f(x_1) + 2f(x_2) + 4f(x_3) + \cdots + 4f(x_{n-1}) + f(x_n)\Big] ,

alternating weights of 4 and 2 for interior points, endpoints weighted 1. In plain English: because a parabola can bend to match a curve's curvature, not just its slope, Simpson's rule captures far more shape information per sample point — its error shrinks proportional to h4h^4, so halving the step size cuts the error by a factor of 16, versus only 4 for the trapezoid rule.

Worked example 1: trapezoid rule by hand

Estimate 02x2dx\int_0^2 x^2\,dx (true value 832.667\frac{8}{3} \approx 2.667) using 4 strips, h=0.5h = 0.5: sample points at x=0,0.5,1,1.5,2x=0,0.5,1,1.5,2 give f=0,0.25,1,2.25,4f = 0, 0.25, 1, 2.25, 4.

0.52[0+2(0.25)+2(1)+2(2.25)+4]=0.25×[0+0.5+2+4.5+4]=0.25×11=2.75.\frac{0.5}{2}\big[0 + 2(0.25) + 2(1) + 2(2.25) + 4\big] = 0.25 \times [0 + 0.5 + 2 + 4.5 + 4] = 0.25 \times 11 = 2.75 .

Trapezoid estimate 2.75 versus true value 2.667 — off by about 3.1%, because a straight line always slightly overestimates the area under an upward-curving (convex) function like x2x^2.

trapezoid: 2.75 error ≈ 3.1% Simpson: 2.667 error = 0 (exact) true
On this convex integrand, the trapezoid rule overestimates by cutting a corner; Simpson's parabola-fitting rule reproduces the exact value, since x² is itself a low-degree polynomial.

Worked example 2: Simpson's rule on the same problem

Same points, Simpson's rule (weights 1,4,2,4,11,4,2,4,1):

0.53[0+4(0.25)+2(1)+4(2.25)+4]=0.16×[0+1+2+9+4]=0.16×16=2.66.\frac{0.5}{3}\big[0 + 4(0.25) + 2(1) + 4(2.25) + 4\big] = 0.1\overline{6} \times [0 + 1 + 2 + 9 + 4] = 0.1\overline{6} \times 16 = 2.6\overline{6} .

Simpson's estimate is 2.6672.667, matching the true value 83\frac{8}{3} exactly — because x2x^2 is itself a parabola, and Simpson's rule fits parabolas exactly, it has zero error here regardless of step size. For a function that isn't itself a low-degree polynomial, Simpson's rule won't be exact, but it will still be dramatically more accurate than the trapezoid rule for the same number of evaluated points.

true f(x) trapezoid: straight segments Simpson: fitted parabola hugs the curve
The trapezoid rule's straight segments cut corners on a curving function; Simpson's rule fits a parabola through each triple of points, tracking the true curve's bend far more closely for the same sample points.

What this means in practice

Trapezoid and Simpson's rules are the entry point to numerical integration used throughout pricing: computing expected payoffs under a known density, integrating a volatility term structure to get total variance, or evaluating any definite integral that arises in a closed-form-adjacent pricing model. In practice, Simpson's rule is almost always preferred over the plain trapezoid rule when the integrand is smooth, since it costs no extra function evaluations but delivers far better accuracy — the trapezoid rule mainly survives as the simplest possible baseline or for integrands with kinks where higher-order methods offer no benefit.

Both rules approximate an integral by replacing the true function with something simple on each small interval and summing the exact areas of those simple pieces — trapezoid uses straight lines (error shrinks like h2h^2), Simpson's uses parabolas through triples of points (error shrinks like h4h^4), so Simpson's rule is almost always more accurate for the same number of function evaluations.

The classic mistake is applying Simpson's rule (or any smooth-curve-fitting quadrature) to a function with a kink, jump, or singularity inside the integration range — fitting a parabola across a discontinuity produces a worse, not better, local approximation than a straight line would, and the promised h4h^4 error rate silently fails to materialize. Always check the integrand is smooth over each sub-interval, or split the integration range at any known kink, before trusting Simpson's rule's superior convergence rate.

Related concepts

Practice in interviews

Further reading

  • Burden & Faires, Numerical Analysis, ch. 4
  • Press et al., Numerical Recipes, ch. 4
ShareTwitterLinkedIn