Calculator · Engineering Mathematics

Simpson's Rule Calculator

Approximate a definite integral by fitting a parabola across each pair of subintervals. Fourth-order accurate for smooth integrands, and exact for any cubic.

Problem definition

Operators + − * / ^, parentheses, pi and e, and sin, cos, tan, asin, acos, atan, exp, sqrt, abs, ln, log, log10. Write 2*x, not 2x.

n must be an EVEN whole number of at least 2 and at most 10,000. An odd or fractional n is rejected, never rounded or repaired.

Results

Integral estimate Q2.00026917
Interval [a, b][0, 3.142]
Subintervals n8
Step h = (b − a)/n0.3927
Function evaluations9

Integrand and partition

f(x)interval bounds a, bquadrature nodes
f(x) = sin(x) on [0, 3.142] with the Simpson nodes marked. The fitted parabolas are not drawn: at a readable n they lie visually on the curve.

Nodes and coefficients

Simpson nodes: coefficients run 1, 4, 2, 4, …, 4, 1
ixᵢf(xᵢ)Simpson cᵢweight wᵢwᵢ·f(xᵢ)
00010.13090
10.39270.382740.52360.2004
20.78540.707120.26180.1851
31.1780.923940.52360.4837
41.571120.26180.2618
51.9630.923940.52360.4837
62.3560.707120.26180.1851
72.7490.382740.52360.2004
83.1421.225e-1610.13091.603e-17

Continue

Open in Numerical Integration Lab

f(x), the interval and n continue into the Lab with the Simpson sweep enabled. An odd n is carried over unchanged and rejected there in the same way.

Assumptions & validity

  • · n is even and at least 2: the rule consumes subintervals in pairs, so an odd count has no meaning and is rejected.
  • · f is finite at every node; a non-finite value is a reported failure.
  • · The O(h⁴) statement assumes f has a continuous fourth derivative on the whole interval.
  • · For a non-smooth integrand — a kink, a jump, an unbounded derivative — Simpson is still computable but no fourth-order claim holds, and it may be no better than the trapezoidal rule.
  • · a > b returns the correct negative integral; a = b returns exactly zero without evaluating f.
  • · Proper integrals over a finite interval only.

Technical reference

h = (b − a) / n, n even

xᵢ = a + i·h, i = 0 … n

Sₙ = (h/3) [ f(x₀) + 4 Σ_{i odd} f(xᵢ) + 2 Σ_{i even, 0 < i < n} f(xᵢ) + f(xₙ) ]

Error for f ∈ C⁴: Sₙ − I = +(b − a) h⁴ f⁗(ξ) / 180 for some ξ in (a, b), equivalently I − Sₙ = −(b − a) h⁴ f⁗(ξ) / 180

I
the exact definite integral
Sₙ
composite Simpson estimate with n subintervals
h
step size, signed with the orientation of the interval
n
number of subintervals, even by construction
f⁗
fourth derivative of the integrand

Each parabola spans TWO subintervals, which is why n must be even. Rounding an odd n would silently change the problem the user asked for, so the engine refuses it instead.

The rule integrates any cubic exactly, even though it interpolates with a parabola: the cubic error terms of the two halves cancel.

Global error is O(h⁴) for a four-times continuously differentiable f, so halving h divides the error by about sixteen — a decisive advantage over the trapezoidal rule at the same evaluation count.

The sign convention here is ESTIMATE MINUS EXACT, the same convention used by the trapezoidal reference and the order in which the results above are presented.

The error term is proportional to f⁗; a smooth integrand with a large fourth derivative can still converge slowly at a coarse n.

The alternating 4 and 2 coefficients come from the parabolic fit, not from any weighting choice: interior odd nodes are parabola midpoints, interior even nodes are shared between two parabolas.

When the integrand has a singularity in a derivative — √x at 0, for example — the observed order drops well below four and the O(h⁴) statement must not be quoted.

Related tools