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
- Type the function of x, for example
sin(x),x^2 + 1,exp(-x^2)or1/(1 + x^2). Trigonometric functions use radians. - Enter the lower limit a and upper limit b. Expressions such as
pi,pi/2orsqrt(2)are fine. - Choose the number of sub-intervals n (even; 1,000 is the default and plenty for smooth functions).
- 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
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.
Related tools
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.