Fit parabolas, not rectangles
Every numerical integration rule replaces the integrand with something easy to integrate exactly. Riemann sums use flat rectangles. The trapezoidal rule uses straight lines. Simpson's rule uses parabolas, and that one step up in polynomial degree buys far more accuracy than it costs.
Take three equally spaced points on the curve. Exactly one parabola passes through them, and its integral over that pair of subintervals works out to (Δx/3)(f₀ + 4f₁ + f₂). Chain those pairs across the interval, and the shared interior nodes belong to two parabolas each, which is where the alternating 4-2-4-2 pattern comes from: interior odd-numbered nodes sit at the middle of a panel and get weight 4, interior even-numbered nodes are shared between panels and get weight 2, and the two ends get weight 1.
The remarkable part is that Simpson's rule is exact for cubics as well as quadratics, even though it only fits a parabola. The cubic part of the error is odd about the midpoint of each panel and integrates to zero. That accidental extra order is why the error scales with the fourth derivative rather than the third, and why halving the step divides the error by roughly sixteen instead of eight.
The 3/8 variant fits a cubic through four points instead of a parabola through three. Its accuracy is the same order, and its practical use is finishing an interval whose panel count is not even — you take one 3/8 panel and run 1/3 panels for the rest.
Applying the rule step by step
Step 1: choose n and compute Δx. Δx = (b − a)/n. For the 1/3 rule n must be even, because the nodes are consumed two at a time. For the 3/8 rule it must be a multiple of three. If you enter a value that does not satisfy the requirement, this calculator raises n to the next legal value and says so, rather than producing a silently wrong weighting.
Step 2: tabulate the nodes. xᵢ = a + i·Δx for i = 0…n. That is n + 1 ordinates, one more than the number of subintervals.
Step 3: apply the coefficients. For the 1/3 rule: 1, 4, 2, 4, 2, …, 4, 1. For the 3/8 rule: 1, 3, 3, 2, 3, 3, 2, …, 3, 3, 1. A quick check on your own work: the coefficients of the 1/3 rule sum to 3n, and those of the 3/8 rule sum to 8n/3. If your column does not add to that, a coefficient is in the wrong place.
Step 4: multiply by the leading factor. Δx/3 for the 1/3 rule, 3Δx/8 for the 3/8 rule.
The node table on this page carries out all four steps in the open, one row per node, with the coefficient and the weighted contribution in their own columns. That is the layout an examiner expects to see, and it is where a hand calculation most often goes wrong.
Worked example: ∫ from 0 to π of sin x dx with n = 4
The exact answer is [−cos x] from 0 to π, which is 1 + 1 = 2. Now approximate it.
- Step size.
Δx = (π − 0)/4 = 0.7853982. - Nodes.
x₀ = 0,x₁ = 0.7853982,x₂ = 1.5707963,x₃ = 2.3561945,x₄ = 3.1415927. - Ordinates.
f₀ = 0,f₁ = 0.7071068,f₂ = 1,f₃ = 0.7071068,f₄ = 0. - Weighted sum.
0 + 4(0.7071068) + 2(1) + 4(0.7071068) + 0 = 2.8284271 + 2 + 2.8284271 = 7.6568542. - Multiply by Δx/3.
0.7853982/3 = 0.2617994, and0.2617994 × 7.6568542 = 2.0045598.
The estimate is 2.0045598 against an exact 2, an error of 0.0045598 — about two parts in a thousand from only five evaluations of the sine.
Double the panels. With n = 8 the same procedure gives 2.0002692, an error of 0.0002692. Divide the first error by the second: 0.0045598 / 0.0002692 = 16.94. Fourth-order accuracy predicts a factor of 16, and the excess is the higher-order remainder that the leading term ignores.
Compare the bound. For sin x the fourth derivative is sin x again, so max|f⁗| = 1 on this interval. The bound is π⁵ × 1 / (180 × 4⁴) = 306.0197/46080 = 0.006641. The true error of 0.0045598 sits below it, as it must, and the ratio of about 1.5 is typical: the bound is a guarantee, not a prediction.
How to read the two error figures
The actual error compares Simpson against a reference. The reference is adaptive quadrature run to a tolerance of 1e−12, which is far tighter than any hand calculation, so the difference is a fair measurement of Simpson's own error on a smooth integrand.
The classical bound is a guarantee, and it is usually loose. It takes the largest absolute fourth derivative anywhere on the interval and assumes the worst case at every panel. Real integrands rarely achieve that, so the measured error typically lands a factor of two to five below the bound. A bound that is comfortably above the measured error is exactly what you should expect.
The bound is estimated, not exact, and here is how. This calculator differentiates your function symbolically four times and samples the result at 201 points across the interval to find its largest absolute value. If the fourth derivative has a spike between those samples, the estimate is low and the bound loses its guarantee. Where the fourth derivative does not exist at all — a corner, or a square-root singularity at an endpoint — the bound is meaningless and the calculator says so when the measured error exceeds it.
Doubling n divides the error by about sixteen. That is the practical content of fourth-order accuracy, and it is the fastest way to check whether the rule is behaving. If the ratio comes out much lower, your integrand is not smooth enough for Simpson's error analysis to apply.
Simpson's rule against the exact value, at four panel counts
| n | Δx | Simpson estimate | Error | Error ratio to previous |
|---|---|---|---|---|
| 2 | 1.5707963 | 2.0943951 | 0.0943951 | — |
| 4 | 0.7853982 | 2.0045598 | 0.0045598 | 20.70 |
| 8 | 0.3926991 | 2.0002692 | 0.0002692 | 16.94 |
| 16 | 0.1963495 | 2.0000166 | 0.0000166 | 16.22 |
| 32 | 0.0981748 | 2.0000010 | 0.0000010 | 16.06 |
The ratio column converges toward 16 from above, which is the signature of a fourth-order method: the leading error term dominates more completely as the step shrinks.
Where Simpson's rule goes wrong
- Using an odd n with the 1/3 rule. The panels are consumed in pairs, so an odd count leaves one subinterval with no partner. This calculator raises n rather than mis-weighting the last node.
- Getting the coefficient pattern out of phase. The interior pattern is 4, 2, 4, 2 with 4 on odd-numbered nodes. Starting with 2 gives an answer that looks plausible and is wrong. Check that the coefficients sum to 3n.
- Forgetting that the ends carry weight 1. There are n + 1 ordinates, not n, and the first and last are not multiplied by anything.
- Applying it across a discontinuity or a corner. The error analysis assumes four continuous derivatives. Split the interval at the bad point and apply the rule to each piece.
- Trusting the bound when the fourth derivative is unbounded. For an integrand such as sqrt(x) near zero the fourth derivative blows up, the bound is infinite in principle, and the observed convergence is far slower than fourth order.
- Working in degrees. As with every calculus result involving trigonometric functions, the nodes and ordinates here assume radians.
Choosing between Simpson, the trapezoidal rule and adaptive quadrature
Simpson beats the trapezoidal rule decisively on smooth integrands. The trapezoidal rule is second order, so halving the step divides its error by four rather than sixteen. On the sine example with n = 4, the trapezoidal rule gives 1.8961189 with an error of 0.104, roughly twenty-three times worse than Simpson's for the same five function evaluations. The trapezoidal rule calculator shows that calculation in the same node-table format.
The trapezoidal rule wins on data rather than formulas. Fitting parabolas to noisy measurements amplifies the noise, and trapezoids do not. It is also the natural choice for unequally spaced points, where Simpson's fixed pattern does not apply at all.
The 1/3 and 3/8 rules have the same order. Both are fourth order; the 3/8 rule is marginally less accurate per function evaluation, and its role is to mop up a panel count that is not even. If you have full control over n, use the 1/3 rule.
Adaptive quadrature beats both when you only want the answer. Rather than spacing nodes evenly, it subdivides where the integrand is hard and leaves smooth stretches alone, which is what the definite integral calculator does. Fixed-step Simpson remains the right tool when the point is to show the method — in a numerical-methods course, a hand calculation, or a spreadsheet somebody else has to audit.
For the crudest picture of what all these methods are approximating, Riemann sums show the definition itself: rectangles, no cleverness, first-order accuracy.
