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 Q | 2.00026917 |
|---|---|
| Interval [a, b] | [0, 3.142] |
| Subintervals n | 8 |
| Step h = (b − a)/n | 0.3927 |
| Function evaluations | 9 |
Integrand and partition
Nodes and coefficients
| i | xᵢ | f(xᵢ) | Simpson cᵢ | weight wᵢ | wᵢ·f(xᵢ) |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 0.1309 | 0 |
| 1 | 0.3927 | 0.3827 | 4 | 0.5236 | 0.2004 |
| 2 | 0.7854 | 0.7071 | 2 | 0.2618 | 0.1851 |
| 3 | 1.178 | 0.9239 | 4 | 0.5236 | 0.4837 |
| 4 | 1.571 | 1 | 2 | 0.2618 | 0.2618 |
| 5 | 1.963 | 0.9239 | 4 | 0.5236 | 0.4837 |
| 6 | 2.356 | 0.7071 | 2 | 0.2618 | 0.1851 |
| 7 | 2.749 | 0.3827 | 4 | 0.5236 | 0.2004 |
| 8 | 3.142 | 1.225e-16 | 1 | 0.1309 | 1.603e-17 |
Continue
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.