Integral Calculator: Numeric Definite Integrals, Area Between Curves and Riemann Sums
By FindMySum · Last reviewed
An integral calculator finds the value of a definite integral: the net area between a curve and the x-axis over an interval. This one does it numerically, which means it works for almost any function you can type, including ones with no antiderivative in closed form and integrals with infinite limits. It also finds the area between two curves and shows how left, right, midpoint and trapezoid Riemann sums approach the true value.
It does not give antiderivatives (indefinite integrals). For those you need a computer algebra system or integration by hand; this page is the place to check the number your antiderivative should produce.
What a definite integral measures
For a function f on [a, b], the definite integral ∫ₐᵇ f(x) dx adds up f(x) × dx across the interval. Geometrically it is the net signed area: area above the x-axis counts as positive and area below as negative. The fundamental theorem of calculus says that if F is an antiderivative of f, the integral equals F(b) − F(a). That is how integrals are evaluated by hand, and it is the standard against which a numeric answer can be checked.
The net signed area and the total area are different numbers whenever f changes sign. ∫₋₁¹ x³ dx = 0, because the negative half cancels the positive half, but the total area between the curve and the axis is ∫₋₁¹ |x³| dx = 1/2. The calculator reports both.
How numeric integration works
Gauss–Kronrod quadrature. A Gauss rule picks the points where f is evaluated, and the weights it gets, so that it is exact for polynomials of as high a degree as possible: the 7-point Gauss rule is exact up to degree 13. The Kronrod extension adds 8 more points to make a 15-point rule exact up to degree 22, reusing the 7 Gauss points. The difference between the two answers estimates the error. QUADPACK, the Fortran library behind integration routines in many scientific packages, uses this pair adaptively: it keeps splitting the piece with the largest error until the total is small enough. This calculator follows the same strategy, aiming for an error near 10⁻¹² of the answer.
Adaptive Simpson's rule. Simpson's rule fits a parabola through the two ends and the midpoint of an interval. The adaptive version compares one Simpson step with two half-size steps and splits the interval wherever they disagree. It is exact for cubics and very good for smooth functions, but it needs the end-point values, so it can't handle an integrand that is infinite at a limit.
Infinite limits. An integral to infinity is turned into an integral over a finite interval by a change of variable. For [a, ∞) the substitution x = a + (1 − t)/t maps t from 1 down to 0 onto x from a up to ∞; the integrand picks up a factor 1/t². For the whole real line, x = t/(1 − t²) maps (−1, 1). If the transformed integral doesn't settle down, the original integral diverges and the calculator says so.
Worked example: ∫₀² x² dx
The calculator opens with f(x) = x² from 0 to 2.
- By hand: an antiderivative of x² is x³/3, so the integral is 2³/3 − 0 = 8/3 = 2.666666667.
- Numerically: the Gauss–Kronrod rule is exact for polynomials, so a single 15-point evaluation gives 2.666666667 with an error estimate near zero.
- Total area: x² is never negative on [0, 2], so the total area equals the integral.
Switch to Riemann sums with n = 4. The interval splits into four pieces of width Δx = 0.5:
- Left sum: 0.5 × (f(0) + f(0.5) + f(1) + f(1.5)) = 0.5 × (0 + 0.25 + 1 + 2.25) = 1.75.
- Right sum: 0.5 × (0.25 + 1 + 2.25 + 4) = 3.75.
- Midpoint sum: 0.5 × (0.0625 + 0.5625 + 1.5625 + 3.0625) = 2.625.
- Trapezoid rule: the average of the left and right sums, 2.75.
The left sum falls short by 0.917 and the right sum overshoots by 1.083 because x² is increasing. The midpoint sum is off by only 0.042 and the trapezoid by 0.083, in the opposite direction; that pattern of half the error with the opposite sign is why Simpson's rule, which combines them, is so accurate.
Area between two curves
To find the area enclosed between f and g from a to b, integrate the distance between them, |f(x) − g(x)|. If you integrate f − g without the absolute value, regions where g is on top subtract from regions where f is on top. The calculator finds every crossing inside the interval, integrates each piece separately and adds the absolute values.
For f(x) = x and g(x) = x² on [0, 1], the line is above the parabola throughout, so the area is ∫₀¹ (x − x²) dx = 1/2 − 1/3 = 1/6. For sin x and cos x on [0, π], the curves cross at π/4; the area is (√2 − 1) + (1 + √2) = 2√2 ≈ 2.828, while the signed integral of sin x − cos x is only 2.
Improper integrals
An integral is improper when a limit is infinite or the integrand blows up somewhere in the interval. It converges when the limit of ordinary integrals exists. Two classic results:
- ∫₁^∞ 1/x² dx = 1 converges, but ∫₁^∞ 1/x dx diverges: 1/x shrinks too slowly. In general ∫₁^∞ 1/xᵖ dx converges only for p > 1.
- ∫₀¹ 1/√x dx = 2 converges although 1/√x is infinite at 0, because the spike is narrow enough.
The Gaussian integral ∫₀^∞ e^(−x²) dx = √π/2 ≈ 0.8862 is a good test: it has no elementary antiderivative, but the calculator returns it to full precision.
When numeric integration struggles
Functions that oscillate very fast, such as sin(1/x) near 0, functions with jumps, and integrands that are nearly infinite inside the interval can all slow the adaptive method down or defeat it. Watch the error estimate: if it is large compared with the answer, split the interval at the difficult point, or check the graph of the function first with the graphing calculator.
More questions
Why is a numeric answer useful if I can integrate by hand?
It is a fast check on hand work, and many integrals have no closed form at all. The bell-curve integral of e^(−x²), sin(x)/x and √(1 + x³) have no antiderivatives in elementary functions, yet their definite integrals are ordinary numbers that numeric methods find to ten or more digits.
What does the error estimate mean?
It is the method's own estimate of how far the answer could be from the true integral, from comparing two rules of different accuracy on each piece. A value like 3e-15 means the answer is reliable to about the last digit shown. A large error estimate is a warning: the function may have a singularity, oscillate wildly or diverge.
What happens if the function has a vertical asymptote inside the interval?
If the integral still exists, as for 1/√x near 0, the adaptive method keeps halving the pieces near the trouble spot and usually converges. If it doesn't exist, as for 1/x across 0, or the function is undefined at a point the method uses, the calculator reports an error or no convergence. Split the integral at the asymptote and treat each side as an improper integral.
Can I integrate with respect to a variable other than x?
Type the function in x: the name of the variable doesn't change a definite integral's value. ∫₀¹ t² dt and ∫₀¹ x² dx are both 1/3. Other letters, such as constants a or k, are not accepted; put their numeric values in instead.
Why does the left Riemann sum underestimate for an increasing function?
On each piece an increasing function is lowest at its left end, so every left-endpoint rectangle sits under the curve and the sum falls short. The right-endpoint sum overestimates for the same reason. For a decreasing function the roles swap, and the midpoint rule sits in between.
Sources
This article explains how the calculator works and is general information, not financial, tax, legal or medical advice. Rules change; check the sources above or a qualified professional before you act.