Integral calculator (definite)

Numerically compute ∫ab f(x) dx using composite Simpson's rule. Adjustable sub-intervals; for smooth functions you'll get 10+ correct digits with the default settings.

Integral inputs

Use ^ for power, explicit * for multiplication. Functions: sin, cos, tan, exp, ln, log, sqrt, abs. Constants: pi, e.
ab f(x) dx
5.8696
a
0
b
π
Step h = (b−a) ÷ n
0.003142
Trapezoid (cross-check)
5.8696

Composite Simpson's rule

ab f(x) dx ≈ (h/3) × [f(x₀) + 4·Σ f(xodd) + 2·Σ f(xeven) + f(xn)]

The interval [a, b] is divided into n equal sub-intervals (n must be even). Simpson's rule fits parabolas through three consecutive points, integrates them exactly, and sums the results. It's exact for polynomials up to degree 3 and very accurate for any smooth function.

Worked example

0π x² · sin(x) dx — analytical answer is π² − 4 ≈ 5.8696. Simpson's rule with n = 1000 hits this to all displayed digits.

FAQ

What if the integrand has a singularity?

Splitting the interval around the singularity and using larger n on the singular side helps. For improper integrals (a or b infinite, or integrand divergent), substitute t = 1/x or use specialised methods — basic Simpson's rule won't converge.

Why must n be even?

Simpson's rule processes points in pairs (groups of 3 with shared endpoints), so the sub-interval count must be even. Odd n is rounded up automatically.

Can I use this for an indefinite integral?

Not directly. For polynomials, see the polynomial calculator which gives the antiderivative symbolically. For other functions, a CAS is needed.

Related calculators