Calculus, Linear Algebra & Discrete Math Integrals & Applications of Integration Fundamental Theorem of Calculus; adaptive Simpson quadrature

Definite Integral Calculator (FTC & Numeric)

Enter an integrand and two limits and this calculator evaluates the definite integral by adaptive Simpson quadrature, refining the subdivision only where the function is hard to fit. Alongside the value you get the unsigned area, the mean value of the function over the interval, and an error estimate produced by rerunning the whole calculation at a looser tolerance. A convergence table shows composite Simpson at seven subdivision counts so you can watch the answer settle, which is the honest way to decide how many digits to quote.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
Integrand f(x)Use ^ for powers, * for multiplication (2*x, 2x and a plain space all work, so x sin(x) is read as a product), and the function names sin, cos, tan, sec, csc, cot, asin, acos, atan, sinh, cosh, tanh, exp, ln, log (base 10), sqrt, cbrt and abs. The constants pi and e are recognised.x^2
Lower limit aWhere the integration starts.0
Upper limit bWhere it ends. Putting b below a negates the result, as the orientation convention requires.1
ToleranceTarget accuracy for the adaptive refinement. Tighter costs more evaluations of f.1e-10 (default)

It returns

  • Definite integral — The signed value: area above the axis counts positive, area below counts negative.
  • Unsigned area — The integral of the absolute value of f, so nothing cancels.
  • Mean value of f on the interval
  • Estimated error — How far the answer moved when the tolerance was loosened by a factor of a thousand.

The formula

abf(x)dx=F(b)F(a)
lrfrl6[f(l)+4f(m)+f(r)]

In plain text: ∫ from a to b of f(x) dx = F(b) − F(a), where F′ = f

  • f(x)The integrand (units of f)
  • a, bLower and upper limits of integration (units of x)
  • F(x)Any antiderivative of f, so that F′ = f (units of f times units of x)

The Fundamental Theorem turns an integral into a subtraction whenever an antiderivative is available. When it is not, the value is still perfectly well defined and is computed numerically, which is what this calculator does.

Updated Category Integrals & Applications of Integration Verified against published test cases Reading time 9 min

What a definite integral measures

A definite integral is a signed accumulation. Slice the interval from a to b into thin strips, multiply each strip's width by the height of f there, add up the products, and take the limit as the strips shrink. Where f is above the axis the products are positive; where it is below, they are negative.

That signed convention is the source of most confusion about integrals, and it is deliberate. The integral of from −1 to 1 is exactly zero, not one half, because the region below the axis on the left cancels the region above it on the right. If you wanted the geometric area you would integrate the absolute value, which is why this calculator reports both numbers side by side.

The accumulation reading is more useful than the area reading in most applications. Integrate velocity and you get displacement. Integrate power and you get energy. Integrate a probability density and you get a probability. Integrate a flow rate and you get a volume. In each case the sign is not a nuisance — it is the difference between going forward and going back.

The Fundamental Theorem of Calculus is what makes any of this computable by hand. It says that if you can find a function F whose derivative is f, then the whole accumulation collapses to one subtraction, F(b) − F(a). Finding that F is the job of the antiderivative calculator.

Why this calculator integrates numerically, and how

Most functions have no elementary antiderivative. e^(−x²) is the famous case: it is smooth, well behaved and central to statistics, and no combination of powers, exponentials, logarithms and trigonometric functions differentiates to it. Liouville proved this in the 1830s, so the situation is permanent rather than a failure of ingenuity.

Numerical quadrature sidesteps the problem. Adaptive Simpson fits a parabola through three points of each panel, estimates the panel's integral from it, then splits the panel in half and does the same to each half. If the two halves together agree with the whole to within the tolerance, the panel is accepted; if not, the algorithm recurses into each half. Effort therefore concentrates where the function is hard to fit and stays cheap where it is nearly a parabola already.

The refinement uses Richardson extrapolation: because Simpson's error scales as the fourth power of the panel width, halving the panel divides the error by about sixteen, and the leftover difference divided by fifteen is a good estimate of the remaining error. That correction is added to the result, which is why the values in the convergence table settle so quickly.

The error figure reported alongside the answer comes from a genuinely independent run at a tolerance a thousand times looser. If the two runs agree to twelve digits, the answer is solid; if they disagree in the sixth, quote six digits and no more.

Worked example: ∫ from 0 to 1 of x² dx, by hand and by Simpson

By the Fundamental Theorem. An antiderivative of is F(x) = x³/3, since F′(x) = 3x²/3 = x². Then the integral is F(1) − F(0) = 1/3 − 0 = 0.333333…. That is the exact answer.

By Simpson's rule on a single panel. With l = 0, m = 0.5 and r = 1, the values are f(0) = 0, f(0.5) = 0.25 and f(1) = 1. Then (1 − 0)/6 × [0 + 4(0.25) + 1] = (1/6)(2) = 0.333333…. Simpson matches exactly, and it will do so for any cubic or lower polynomial, because a parabola through three points reproduces every quadratic exactly and the cubic error terms cancel by symmetry.

A case where it does not match exactly. Take ∫ from 0 to π of sin x dx, whose exact value is [−cos x] evaluated at the ends, giving −(−1) − (−1) = 2. Composite Simpson with four subintervals gives 2.0045598, off by 0.0045598. Doubling to eight subintervals gives 2.0002692, off by 0.0002692. The ratio of those errors is 16.9, which is the factor of sixteen that fourth-order accuracy predicts, plus the higher-order remainder.

Reading the sign. Integrate from −1 to 1 and you get [x⁴/4] from −1 to 1, which is 0.25 − 0.25 = 0. The unsigned area is 2 × 0.25 = 0.5, because each half contributes a quarter. This calculator reports 0 and 0.5 respectively, and that pair is one of its test vectors.

How to read the four numbers

The integral is signed. Compare it against the unsigned area. When the two agree, f keeps one sign across the whole interval. When the unsigned area is larger, f crosses the axis and cancellation is happening — useful information, and the calculator says so explicitly.

The mean value is the integral divided by the width. It is the constant height that would enclose the same signed area, and the Mean Value Theorem for Integrals guarantees that a continuous f actually attains it somewhere inside the interval. Root-mean-square values in electrical work, average concentrations in chemistry and expected values in probability are all this quantity.

The error estimate is a difference between two runs, not a proof. Adaptive quadrature can be fooled by a function that is flat where it samples and spiky where it does not — a narrow tall bump between the sample points looks like nothing at all. If your integrand has such a feature, split the interval by hand around it and add the pieces.

The convergence table is the diagnostic. On a smooth integrand the change column should shrink by roughly a factor of sixteen from row to row. If it shrinks much more slowly, the integrand is not smooth enough for Simpson's error analysis to apply — a square-root singularity at an endpoint is the usual reason — and the reported digits should be trusted only as far as that column suggests.

Standard integrals you can check this calculator against

Every value below follows from the Fundamental Theorem with an elementary antiderivative, so it is exact.
IntegralAntiderivativeExact valueDecimal
∫₀¹ x² dxx³/31/30.3333333333
∫₀¹ x³ dxx⁴/41/40.2500000000
∫₁ᵉ (1/x) dxln x11.0000000000
∫₀^π sin x dx−cos x22.0000000000
∫₀^(π/2) cos x dxsin x11.0000000000
∫₀¹ e^x dxe^xe − 11.7182818285
∫₀¹ 4/(1+x²) dx4·arctan xπ3.1415926536
∫₀¹ 1/√x dx2√x22.0000000000
∫₋₁¹ x³ dxx⁴/400.0000000000

The 1/√x row is an improper integral: the integrand blows up at the left endpoint yet the area is finite. Adaptive quadrature handles it approximately by stepping just inside the endpoint, so expect the last few digits there to be soft.

Where a definite integral goes wrong

  • Integrating across a pole. ∫ from −1 to 1 of 1/x dx does not exist; the two halves diverge in opposite directions. A numerical method will happily return a number close to zero by symmetry, and that number is meaningless.
  • Confusing the signed integral with area. Area is ∫|f|. If your integrand crosses the axis and you wanted the geometric area, read the unsigned figure instead.
  • Forgetting that reversing the limits flips the sign. ∫ from b to a = −∫ from a to b. This is a convention, but it is the convention that makes the Fundamental Theorem come out right.
  • Trusting a quadrature rule on a spiky integrand. A narrow tall feature between sample points is invisible to any fixed sampling scheme. Split the interval around it and add.
  • Using degrees. Every trigonometric antiderivative assumes radians. ∫₀^π sin x dx = 2 only in radians.
  • Quoting more digits than the convergence table supports. If the change column has stalled at 1e−7, the eighth decimal place is noise.

If you want the formula, not the number, use the indefinite integral calculator. It finds an antiderivative where one exists in elementary terms, which lets you evaluate the same integral at any limits without recomputing.

If you are being asked to apply a specific rule by hand, use the trapezoidal rule or Simpson's rule calculators, which show the node table, the coefficient pattern and the classical error bound rather than adapting behind the scenes. Riemann sums are the definitional version, useful for teaching and poor for accuracy.

If your data is a table of measurements rather than a formula, the trapezoidal rule applied to the data points is usually the right choice, since fitting higher-order polynomials to noisy data amplifies the noise.

If you want the area enclosed between two curves, that is ∫|f − g| split at the intersections, which the area between curves calculator handles including the root finding.

If the region is two-dimensional, move up to iterated double integrals, which apply the same one-dimensional quadrature twice.

Frequently asked questions

Does this calculator find the antiderivative?

No — it evaluates the number directly by adaptive quadrature, which is why it works on integrands that have no elementary antiderivative at all, such as e^(−x^2) or sin(x)/x. If you want the formula F(x) rather than a value, use the indefinite integral calculator, then apply F(b) − F(a) yourself.

Why is my integral zero when the curve clearly encloses area?

Because the integral is signed and your function crosses the axis, so the negative part cancels the positive part. ∫ from −1 to 1 of x³ dx is exactly zero for this reason. Read the unsigned area output, which integrates the absolute value and comes to 0.5 in that example.

How accurate is the answer?

On a smooth integrand over a finite interval, typically twelve or more correct digits at the default tolerance. The estimated-error output measures it: the calculator runs the whole quadrature a second time at a tolerance a thousand times looser and reports how far the answer moved. Quote no more digits than that figure supports.

Can it handle an improper integral?

Only the kind with a finite interval and an integrable endpoint singularity, such as ∫₀¹ dx/√x = 2, and even then the final digits are soft because the method steps just inside the endpoint rather than taking a true limit. Infinite limits are not supported; substitute to map them onto a finite range first.

What does the mean value output tell me?

It is the integral divided by the width of the interval — the constant height that would enclose the same signed area. For a continuous function the Mean Value Theorem for Integrals guarantees that f actually equals that value at some point inside the interval, so it is a genuine average rather than a bookkeeping artefact.

Why does the change column stop shrinking?

Because you have reached the floor set by double-precision rounding, or because the integrand is not smooth enough for Simpson's fourth-order error to apply. A square-root singularity at an endpoint gives the second behaviour: the error then falls like a low power of the subinterval count rather than the fourth power.

Is it a problem if b is smaller than a?

No, and the result changes sign, which is correct. The orientation convention ∫ from b to a = −∫ from a to b is what makes the Fundamental Theorem work for any pair of limits. The calculator flags the reversal so you notice the sign is intentional.

How does adaptive quadrature decide where to work harder?

It compares Simpson's estimate for a panel against the sum of Simpson's estimates for that panel's two halves. If they agree within the local tolerance the panel is accepted; if not, the panel is split and each half is examined the same way. Smooth stretches are accepted immediately and awkward ones are subdivided repeatedly.

References

  • Calculus, 8th edition (the definite integral and the Fundamental Theorem, chapter 5) — James Stewart, Cengage Learning
  • Numerical Recipes: The Art of Scientific Computing, 3rd edition (adaptive quadrature, chapter 4) — Press, Teukolsky, Vetterling & Flannery, Cambridge University Press
  • NIST Digital Library of Mathematical Functions, Chapter 3: Numerical MethodsNational Institute of Standards and Technology