Fitting the Curve Better

Simpson's rule

Trapezoids join the points with straight segments. But a curve is… curved. Hence the brilliant idea behind Simpson's rule: join the points with small arcs of parabolas, which follow the curvature.

We group the points three at a time — so we need an even number of pieces — and, on each pair of pieces, we pass the parabola that agrees with ff at those three points. The area under these parabolas gives a remarkable approximation:

∫abf(x) dx≈Δx3[f(x0)+4f(x1)+2f(x2)+4f(x3)+⋯+4f(xn−1)+f(xn)]\int_a^b f(x)\,\mathrm{d}x \approx \frac{\Delta x}{3}\Bigl[f(x_0) + 4f(x_1) + 2f(x_2) + 4f(x_3) + \cdots + 4f(x_{n-1}) + f(x_n)\Bigr]

The pattern of coefficients is distinctive: 1,4,2,4,2,…,4,11, 4, 2, 4, 2, \ldots, 4, 1. The endpoints count 11, the points with odd index count 44, and the interior points with even index count 22.

Method What approximates the curve Order of the error
rectangles flat top 1n\dfrac{1}{n}
trapezoids straight segment 1n2\dfrac{1}{n^2}
Simpson arc of a parabola 1n4\dfrac{1}{n^4}

Simpson's accuracy is spectacular: the error decreases like 1n4\dfrac{1}{n^4}. Better still, the method gives the exact result for every polynomial of degree ≤3\leq 3. On f(x)=x2f(x) = x^2 with only 44 pieces, Simpson already finds the exact value 13\tfrac{1}{3}, whereas the trapezoids are still off:

Method, with n=4n = 4 ∫01x2 dx\displaystyle\int_0^1 x^2\,\mathrm{d}x
trapezoids ≈0.34375\approx 0.34375
Simpson 0.333330.33333, exact value

Remember the progression: flat, then straight, then curved. Each level fits ff better, and accuracy shoots up for the same number of points. This is why Simpson's rule is so widely used in practice.