Calculate the definite integral (area under a curve) using numerical methods. Enter a function and bounds.
Last reviewed: May 2026
The area under a curve is one of the most important concepts in calculus, with applications that extend far beyond pure mathematics into physics, engineering, economics, statistics, and medicine. Formally, the area under a curve y = f(x) between x = a and x = b is the definite integral ∫[a,b] f(x) dx, which represents the accumulated quantity of whatever the function models.1
The concept is powerful because it converts a rate or density into a total quantity. A velocity function tells you how fast an object moves at each instant — the area under the velocity-time curve gives you the total distance traveled. A power function tells you energy consumption per unit time — the area under the power-time curve gives you total energy consumed. A probability density function tells you the relative likelihood of each outcome — the area under the PDF within an interval gives you the probability of the outcome falling in that range.
This calculator computes definite integrals using both analytical methods (when an antiderivative exists) and numerical methods (the trapezoidal rule and Simpson's rule) for functions that cannot be integrated symbolically or when working with discrete data points.2
The Fundamental Theorem of Calculus connects derivatives and integrals, providing the most efficient method for computing exact areas under curves. If F(x) is an antiderivative of f(x), then ∫[a,b] f(x) dx = F(b) − F(a). This means finding the area under a curve reduces to finding an antiderivative and evaluating it at two points.
For example, the area under y = x² from x = 0 to x = 3 is: ∫[0,3] x² dx = [x³/3] evaluated from 0 to 3 = 27/3 − 0 = 9 square units. The antiderivative of x² is x³/3, and the computation is straightforward. However, many functions encountered in practice do not have elementary antiderivatives — functions like e^(−x²), sin(x)/x, and √(1 + x³) require numerical methods.3
When a function lacks a closed-form antiderivative, numerical methods approximate the area by dividing the interval into small segments and summing the areas of simple geometric shapes fitted to the curve. The three most common methods, in order of increasing accuracy, are Riemann sums, the trapezoidal rule, and Simpson's rule.
Riemann sums approximate the area using rectangles. Left Riemann sums use the function value at the left endpoint of each subinterval as the rectangle height; right Riemann sums use the right endpoint; midpoint sums use the center. Riemann sums are conceptually simple but converge slowly — you need many rectangles for good accuracy.
The trapezoidal rule connects adjacent function values with straight lines, forming trapezoids instead of rectangles. This simple modification significantly improves accuracy because trapezoids capture the slope of the function between sample points. The error decreases as the square of the step size (h²).
Simpson's rule fits parabolic arcs through every three adjacent points, capturing the curvature of the function. This produces dramatically better accuracy — the error decreases as the fourth power of the step size (h⁴), meaning doubling the number of subintervals reduces the error by a factor of 16. Simpson's rule requires an even number of subintervals.1
| Method | Order of Accuracy | Error with 10 Subintervals | Error with 100 Subintervals | Best For |
|---|---|---|---|---|
| Left Riemann Sum | O(h) | ~10⁻¹ | ~10⁻² | Conceptual understanding only |
| Trapezoidal Rule | O(h²) | ~10⁻² | ~10⁻⁴ | Discrete data, simple implementation |
| Simpson's Rule | O(h⁴) | ~10⁻⁴ | ~10⁻⁸ | Smooth functions, high accuracy needed |
| Gaussian Quadrature | O(h²ⁿ) | ~10⁻⁸ | Machine precision | Maximum accuracy, known function |
| Function f(x) | Antiderivative F(x) | Example: ∫[0,1] f(x) dx |
|---|---|---|
| xⁿ (n ≠ −1) | xⁿ⁺¹ / (n+1) | ∫x² = 1/3 ≈ 0.333 |
| 1/x | ln|x| | ∫[1,e] 1/x = 1 |
| eˣ | eˣ | ∫eˣ = e − 1 ≈ 1.718 |
| sin(x) | −cos(x) | ∫[0,π] sin(x) = 2 |
| cos(x) | sin(x) | ∫[0,π/2] cos(x) = 1 |
| 1/(1+x²) | arctan(x) | ∫ = π/4 ≈ 0.785 |
Physics — displacement from velocity: If v(t) gives velocity as a function of time, then ∫[t₁,t₂] v(t) dt gives the displacement (net change in position) over that time interval. If velocity is always positive, displacement equals distance traveled. If velocity changes sign, the integral gives net displacement while ∫|v(t)| gives total distance.4
Engineering — work and energy: Work equals the integral of force over displacement: W = ∫F dx. For variable forces (like springs, where F = kx), integration is the only way to compute total work. The area under a stress-strain curve gives the energy per unit volume absorbed by a material before fracture — a critical measure of toughness in structural engineering.
Statistics — probability: For continuous probability distributions, the probability that a random variable falls between a and b equals the area under the probability density function (PDF) from a to b: P(a ≤ X ≤ b) = ∫[a,b] f(x) dx. The total area under any valid PDF equals exactly 1. The normal distribution's bell curve is perhaps the most widely used PDF in science and industry.
Economics — consumer and producer surplus: In microeconomics, consumer surplus is the area between the demand curve and the market price, representing the total benefit to consumers from paying less than their maximum willingness to pay. Producer surplus is the area between the supply curve and the market price. Both are computed as definite integrals.2
When you have measured data points rather than a continuous function — such as sensor readings, experimental measurements, or financial time series — numerical integration methods work directly on the data. The trapezoidal rule is particularly well-suited because it requires only pairs of adjacent data points and handles unequally spaced data naturally.
For equally spaced data with an even number of intervals, Simpson's rule provides better accuracy. For irregularly spaced data, the trapezoidal rule is the standard choice. Both methods are straightforward to implement in spreadsheets, Python (using scipy.integrate.trapz or scipy.integrate.simps), MATLAB, or any programming environment.3
Sometimes the area under a curve extends to infinity — either because the integration interval is unbounded (the upper or lower limit is infinity) or because the function has a vertical asymptote within or at the boundary of the interval. These are called improper integrals, and they can converge to a finite value or diverge to infinity depending on how quickly the function approaches zero or infinity.
For example, ∫[1,∞] 1/x² dx converges to 1 — even though the interval is infinitely long, the function decreases fast enough that the total area is finite. In contrast, ∫[1,∞] 1/x dx diverges — the function decreases too slowly for the area to converge. The general rule for ∫[1,∞] 1/xᵖ dx is convergence when p > 1 and divergence when p ≤ 1. This convergence test appears throughout probability theory, physics, and engineering when dealing with distributions and decay functions.1
The concept of area under a curve extends naturally to higher dimensions. A double integral ∫∫ f(x,y) dA computes the volume under a surface z = f(x,y) over a region in the xy-plane. Triple integrals compute four-dimensional hypervolume or, more practically, accumulated quantities like mass (integrating density over a 3D region), electric charge, or gravitational potential.
In practice, multidimensional integration is essential for computational physics, engineering simulation, and machine learning. Monte Carlo integration — using random sampling to estimate high-dimensional integrals — becomes the preferred method in dimensions above about five, where grid-based methods like the trapezoidal rule become computationally infeasible. The computational cost of grid methods grows exponentially with dimension (the "curse of dimensionality"), while Monte Carlo methods converge at a rate independent of dimension, making them indispensable for problems in quantum mechanics, financial option pricing, Bayesian statistics, and computer graphics rendering where integrations may involve dozens or hundreds of variables.3
Most scientific programming languages provide built-in numerical integration functions. In Python, SciPy offers scipy.integrate.quad for single integrals (adaptive Gaussian quadrature), scipy.integrate.trapezoid for the trapezoidal rule on discrete data, and scipy.integrate.simpson for Simpson's rule. MATLAB provides integral(), trapz(), and cumtrapz(). JavaScript libraries like math.js and numeric.js provide similar functionality for web-based calculations. For production applications requiring high reliability, these well-tested library functions are always preferred over custom implementations because they include adaptive step-size control, error estimation, and handling of edge cases that simple implementations miss.4
The definite integral computes signed area — regions where the function is above the x-axis contribute positive area, and regions below the x-axis contribute negative area. For ∫[0,2π] sin(x) dx, the positive area from 0 to π and the negative area from π to 2π cancel exactly, giving an integral of zero despite the function enclosing nonzero area.
To find the total enclosed area regardless of sign, integrate the absolute value: ∫|f(x)| dx. In practice, this means identifying where the function crosses the x-axis, integrating each segment separately, and summing the absolute values. The distinction between signed and total area matters in physics (where direction matters) versus pure geometry (where only magnitude matters).
→ Use Simpson's rule for smooth functions. It provides dramatically better accuracy than the trapezoidal rule for the same number of subintervals — typically 2–4 extra digits of accuracy with smooth, well-behaved functions.
→ Watch for discontinuities. Numerical methods can produce large errors near discontinuities or vertical asymptotes. Split the integral at any points of discontinuity and handle each segment separately.
→ Increase subintervals to check convergence. If doubling the number of subintervals does not significantly change the result, you have sufficient accuracy. If it does change, keep doubling until the result stabilizes.
→ Remember signed vs. total area. If the function crosses the x-axis in your interval, the definite integral gives net (signed) area, which can be smaller than the total enclosed area. Integrate |f(x)| if you need the total geometric area.
See also: Integral Calculator · Derivative · Graphing Calculator · Limit Calculator