Simpson's Rule Calculator
Approximate a definite integral with Simpson's 1/3 or 3/8 rule: type f(x), the limits and n, and get the estimate, step size, weights table and a trapezoidal comparison.
How it works
1/3 rule: ∫ₐᵇ f(x) dx ≈ (h/3)[f(x₀) + 4f(x₁) + 2f(x₂) + 4f(x₃) + … + 4f(xₙ₋₁) + f(xₙ)], n even · 3/8 rule: (3h/8)[f(x₀) + 3f(x₁) + 3f(x₂) + 2f(x₃) + … + f(xₙ)], n multiple of 3 · h = (b − a)/n
Simpson's rule replaces the curve on each pair of subintervals with a parabola through three points and integrates the parabolas exactly, giving the 1, 4, 2, 4, …, 4, 1 weight pattern. The error shrinks with h⁴, so it is far more accurate than the trapezoidal rule for smooth functions, and it is exact for any cubic. The 3/8 rule fits cubics through four points (weights 1, 3, 3, 2, …, 3, 3, 1) and needs n divisible by 3.
Worked example
For f(x) = 1/(1 + x²) on [0, 1] with n = 6 and the 1/3 rule: h = 1/6, the nodes are 0, 1/6, …, 1 and the weighted sum is 14.13716301; times h/3 = 1/18 gives 0.78539795 — the exact value is π/4 = 0.78539816…, an error of only about 2 × 10⁻⁷. The trapezoidal rule with the same n gives 0.78424077.
Sources: Simpson's rule — Wikipedia · Numerical Integration — OpenStax Calculus Volume 2, 3.6
Frequently asked questions
Why must n be even for Simpson's rule?
The 1/3 rule fits one parabola over every two subintervals, so the subintervals have to come in pairs. If your n is odd, use the 3/8 rule on three of them or choose n divisible by 3.
How accurate is Simpson's rule?
The error is −(b − a)h⁴f⁽⁴⁾(ξ)/180 for some ξ in [a, b]. Doubling n cuts the error by about 16, and the rule is exact for polynomials up to degree 3.
What is the difference between Simpson's 1/3 and 3/8 rules?
Both have fourth-order error. The 1/3 rule uses parabolas over pairs of subintervals and needs n even; the 3/8 rule uses cubics over triples and needs n divisible by 3. The 1/3 rule is slightly more accurate for the same n.
How do I type the function?
Use x as the variable, ^ for powers, * for multiplication (2x also works), and functions such as sin(x), cos(x), exp(x), ln(x), sqrt(x). pi and e are constants. Angles are in radians.
Related calculators
This calculator is for educational purposes. Double-check important results before acting on them.