Numerical methods
Composite Simpson's rule
num.simpsonAlso called simpson, simpsons rule, simps, simpson rule
where
Integral estimate from an odd number n of equally spaced samples with spacing h: weights 1, 4, 2, 4, …, 2, 4, 1 times h/3. Exact for cubic polynomials.
Notation
function values at equally spaced points y0 … yn−1
y ∈ ℝn
spacing between points
h > 0 · default 1
number of sample points (odd)
Size, at least 3, odd
Result: the integral estimate
scalar
Worked examples
Each result is solved exactly and confirmed by two independent computations.
Given
Result
≈ 2.66666666667
Given
Result
x3 on [0, 2]; Simpson's rule is exact for cubics.
Given
Result
Common mistakes
Swaps the weights 4 and 2
Odd-indexed samples get weight 2 and even-indexed interior samples weight 4.
Fix: Weight odd-indexed samples (y1, y3, …) by 4 and even-indexed interior samples by 2.
Uses h/6 in place of h/3
The factor h/6 belongs to the single-panel form written with the full panel width 2h.
Fix: Multiply by h/3, where h is the spacing between samples.
Source
DLMF, eqs. 3.5.6 and 3.5.7
NIST Digital Library of Mathematical Functions. https://dlmf.nist.gov/ Release 1.2.8 of 2026-09-15. F. W. J. Olver, A. B. Olde Daalhuis, D. W. Lozier, B. I. Schneider, R. F. Boisvert, C. W. Clark, B. R. Miller, B. V. Saunders, H. S. Cohl, and M. A. McClain, eds.