Definite Integral Calculator (Numerical)

Integrate a function of x between two limits numerically with Simpson's rule, with an error estimate, rule comparison and shaded graph.

Examples: x^2 + 1, exp(-x^2), sqrt(1 - x^2), 1/(1 + x^2), x*ln(x). Trig functions use radians.
Numbers or pi/2, sqrt(2)…
Even number; more is more accurate.
Simpson's rule
2
Trapezoidal rule
1.9999983551
Midpoint rule
2.0000008225
Estimated error
± 1.08 × 10⁻¹²
Average value of f
0.63661977∫ ÷ (b − a)
∫ sin(x) dx from 0 to π2≈ 2

Show the work

  1. Split [0, 3.141593] into n = 1000 equal pieces of width h = (b − a) ÷ n = 0.0031415927.
  2. Simpson's rule: ∫ ≈ (h/3)[f(x0) + 4f(x1) + 2f(x2) + 4f(x3) + … + 4f(xn−1) + f(xn)].
  3. First and last sample points:
    x0 = 0: f = 0, weight 1
    x1 = 0.00314159: f = 0.0031415875, weight 4
    x2 = 0.00628319: f = 0.006283144, weight 2
    …
    x999 = 3.13845106: f = 0.0031415875, weight 4
    x1000 = 3.14159265: f = 1.224646799 × 10⁻¹⁶, weight 1
  4. Weighted sum × h/3 = 2.
  5. Error estimate: comparing with 500 sub-intervals, |S1000 − S500| ÷ 15 ≈ 1.08 × 10⁻¹².
0123−0.500.51ab

The shaded region is the signed area: parts below the x-axis count as negative.

A definite integral adds up a quantity that changes continuously — area under a curve, distance from a velocity, total output from a rate. Many integrals have no tidy formula, so this calculator evaluates them numerically with Simpson’s rule, compares the result with the trapezoidal and midpoint rules, estimates the remaining error, and shades the region on a graph.

How to use the definite integral calculator

  1. Type the function of x, for example sin(x), x^2 + 1, exp(-x^2) or 1/(1 + x^2). Trigonometric functions use radians.
  2. Enter the lower limit a and upper limit b. Expressions such as pi, pi/2 or sqrt(2) are fine.
  3. Choose the number of sub-intervals n (even; 1,000 is the default and plenty for smooth functions).
  4. Read the integral on the tape. The steps show the strip width, Simpson’s weights, sample values and the error estimate.

Supported functions include sqrt, cbrt, abs, exp, ln, log (base 10), log2, sin, cos, tan and their inverses asin, acos and atan, plus the constants pi and e.

Simpson’s rule formula

Split [a, b] into n equal strips of width h = (b − a)/n, with sample points xi = a + ih. Then

∫ab f(x) dx ≈ (h/3)[f(x0) + 4f(x1) + 2f(x2) + 4f(x3) + … + 4f(xn−1) + f(xn)]

The 1, 4, 2, 4, …, 4, 1 pattern comes from fitting a parabola through every three consecutive points. For comparison, the trapezoidal rule uses weights ½, 1, 1, …, 1, ½ (straight lines between points), and the midpoint rule samples the center of each strip.

To estimate the error, the calculator repeats the computation with half as many strips. For smooth functions the difference divided by 15 is a reliable error estimate; if the values converge more slowly than expected — typical near a kink or a vertical tangent — the estimate is adjusted to the observed rate and a note explains why.

Worked example

Integrate sin(x) from 0 to π. The exact answer, from the antiderivative −cos(x), is −cos π + cos 0 = 2.

Strips: n = 1,000, so h = π/1,000 ≈ 0.0031416.

Simpson's rule: 2.0000000000, with an estimated error near 10−12.

Trapezoidal rule: 1.9999983551 (too low, because sine curves downward).

Midpoint rule: 2.0000008225 (too high by about half the trapezoid's error).

For a polynomial such as x2 + 1 from 0 to 3, the calculator also shows the exact value: the antiderivative x3/3 + x gives 9 + 3 = 12, matching Simpson’s rule exactly (Simpson’s rule is exact for polynomials up to degree three).

Choosing n and spotting trouble

Situation What to do
Smooth function on a modest interval n = 1,000 is more than enough
Rapid oscillation, such as sin(50x) raise n so each wiggle gets many strips
Vertical tangent at an end, such as sqrt(1 − x²) expect slower convergence; read the adjusted error
Function undefined inside the interval split the integral at that point
Very wide interval integrate in pieces and add

Numerical integration cannot detect behavior between sample points. A narrow spike that falls between samples can be missed, so the graph is worth a glance whenever the result looks surprising.

To see how the area is built from rectangles, use the Riemann sum calculator. The reverse operation, differentiation, is covered by the polynomial derivative calculator, and the bell-curve integral behind probabilities is handled by the normal distribution calculator.

Frequently asked questions

Does this give an exact answer?

For polynomials with numeric limits it also shows the exact value from the antiderivative. For other functions, such as e^(−x²), there is often no elementary antiderivative, and Simpson's rule gives a numerical value that is usually accurate to 8–12 significant digits.

What is Simpson's rule?

It splits the interval into an even number of strips and fits a parabola through each pair of strips, then adds the areas under those parabolas. Its error shrinks with the fourth power of the strip width, so doubling n cuts the error by about 16.

Why does the calculator say the function is undefined at some point?

A sample point landed where the function blows up or has no value, such as 1/x at x = 0 or ln(x) at x = 0. The integral may be improper. Split it at the bad point or move the limit slightly away.

What happens if the upper limit is smaller than the lower one?

The integral changes sign: the integral from b to a is the negative of the integral from a to b. The calculator handles this automatically and notes it.

Why can the result be negative?

A definite integral measures signed area. Regions below the x-axis count as negative, so the integral of sin(x) from 0 to 2π is 0 even though the curve encloses plenty of area.

Last reviewed October 2026 by the CalcFluent editorial team. How we check our calculators.