Recipe
Apply the composite Simpson's rule
Use when: you need \int_a^b f(x)\,dx to a specific accuracy and f is smooth enough that a piecewise-parabola fit tracks it well
Goal: a single numerical approximation S_n to the integral, built from n+1 evaluations of f
Taught in Simpson's rule and degree of precision
Quick recipe
-
1
Decide how many panels to split [a,b] into. n must be even. The 1,4,2,4,\dots,4,1 weight pattern pairs panels two at a time. An odd n leaves one panel with no defined pair.
Example
For \displaystyle\int_0^2 e^x\,dx (true value e^2-1\approx6.389056), take n=4.
- n is already even — proceed directly to Step 2.
- n is given odd (or computed from a target step size and lands odd) — round up to the next even integer before continuing. The resulting h shrinks slightly, which only helps accuracy.
Why: the weight pattern's own derivation fits one parabola through each PAIR of panels. An odd number of panels leaves a leftover one the pattern was never built to weight.
-
2
h=\dfrac{b-a}{n}, and x_i = a+ih for i=0,\dots,n.
Example
h=\dfrac{2-0}{4}=0.5, giving grid points x_0,\dots,x_4=0,\,0.5,\,1,\,1.5,\,2.
⚡ Shortcut
Doubling n later never wastes the first pass's work — say, going from 4 to 8 panels, to check whether the answer has converged. Every OLD grid point is still a grid point of the new, finer grid. Only the new midpoints between them are genuinely new evaluations. Section 4's Romberg integration is built entirely around this same reuse, applied to the trapezoidal rule instead of Simpson's rule.
Why: an evenly spaced grid is what makes the weight pattern in Step 3 apply the same way everywhere. Every inner point's weight depends only on whether its index is odd or even, never on where it sits.
-
3
Compute f(x_0), f(x_1), \dots, f(x_n) once each.
Example
f(x)=e^x: f(0)=1, f(0.5)\approx1.648721, f(1)\approx2.718282, f(1.5)\approx4.481689, f(2)\approx7.389056.
Why: every later step is pure arithmetic on these n+1 numbers. No further evaluations of f are needed once this list exists.
-
4
Odd-indexed points (x_1,x_3,\dots) get weight 4. Even inner points (x_2,x_4,\dots,x_{n-2}) get weight 2. The two endpoints get weight 1.
Example
1(1)+4(1.648721)+2(2.718282)+4(4.481689)+1(7.389056)=38.347261.Why: this exact pattern is what makes each pair of panels match its own fitted parabola's area exactly (Section 2's own degree-of-precision point). It isn't an arbitrary smoothing weight — it falls directly out of the parabola's own closed-form area.
-
5S_n = \frac{h}{3}\Big[\text{the weighted sum from Step 4}\Big].
Example
S_4=\frac{0.5}{3}(38.347261)\approx6.391210,against the true value e^2-1\approx6.389056 — an error of about 0.00215.
Why: this is the constant every pair of panels' own exact parabola-area formula carries. It's derived once and reused for every pair, rather than re-derived per pair.
Common mistakes
- Using an odd number of panels. This is the single most common mistake, since nothing about typing a number into "n=" visibly warns that odd values break the pattern.
- Assigning weight 2 to an odd-indexed point (or 4 to an even one). The pattern alternates starting from 4 at x_1, not from 2.
- Scaling by h/2 out of habit from the trapezoidal rule instead of h/3.
- Treating one application of the recipe on a wide [a,b] as good enough. Check whether more panels are actually needed — Section 3's own error bound answers this directly.