A Riemann sum approximates the area under a curve by slicing it into thin strips, replacing each strip with a rectangle (or trapezoid), and adding up the areas. It is the idea the definite integral is built on. This calculator draws the strips, lists every term, and measures how far the approximation is from the true integral.
How to use the Riemann sum calculator
- Enter the function, for example
x^2,sqrt(x)orsin(x). - Enter the interval start a and end b.
- Choose the number of rectangles n.
- Choose the sample point: left endpoint, right endpoint, midpoint, or trapezoid.
- Read the sum on the tape, the rectangles on the graph, and each term in the table.
Riemann sum formulas
Every version starts with the same width, Δx = (b − a)/n, and the grid points xi = a + iΔx.
| Method | Formula |
|---|---|
| Left | Ln = Δx[f(x0) + f(x1) + … + f(xn−1)] |
| Right | Rn = Δx[f(x1) + f(x2) + … + f(xn)] |
| Midpoint | Mn = Δx Σ f((xi−1 + xi)/2) |
| Trapezoid | Tn = (Ln + Rn)/2 |
In sigma notation the general Riemann sum is Σ f(xi)Δx, where xi is any point in the i-th strip. The definite integral is the limit of these sums as n → ∞.
Worked example
Approximate the area under f(x) = x2 from 0 to 2 with n = 4. Then Δx = 0.5.
Left: 0.5 × [f(0) + f(0.5) + f(1) + f(1.5)] = 0.5 × [0 + 0.25 + 1 + 2.25] = 0.5 × 3.5 = 1.75
Right: 0.5 × [0.25 + 1 + 2.25 + 4] = 0.5 × 7.5 = 3.75
Midpoint: 0.5 × [0.0625 + 0.5625 + 1.5625 + 3.0625] = 0.5 × 5.25 = 2.625
Trapezoid: (1.75 + 3.75) ÷ 2 = 2.75
Exact integral: 23/3 = 8/3 ≈ 2.6667
Because x2 is increasing on [0, 2], the left sum underestimates and the right sum overestimates. Because it curves upward, the trapezoid overestimates slightly and the midpoint underestimates by about half as much.
Over- or underestimate? A quick guide
| Shape of f on [a, b] | Left sum | Right sum | Midpoint | Trapezoid |
|---|---|---|---|---|
| Increasing | under | over | — | — |
| Decreasing | over | under | — | — |
| Concave up (curving upward) | — | — | under | over |
| Concave down | — | — | over | under |
When a function both increases and changes concavity on the interval, the errors can partly cancel, so check the table and the error value rather than relying on the rule of thumb.
Why Riemann sums matter
Riemann sums turn a continuous problem into ordinary arithmetic, which is exactly how data is handled in practice. A speedometer read every minute, rainfall measured every hour, or power use logged every 15 minutes can all be totaled with a Riemann sum, with no formula for the underlying function at all. In that setting, the trapezoidal rule is the usual choice.
For a high-accuracy value of the integral itself, use the definite integral calculator; to list function values at evenly spaced points first, try the function table calculator.
Frequently asked questions
Which Riemann sum is most accurate?
For smooth functions the midpoint and trapezoidal sums are usually far more accurate than left or right sums, and the midpoint error is typically about half the trapezoid error with the opposite sign.
When does a left sum overestimate?
When the function is decreasing on the interval: the left edge of each rectangle is its highest point, so every rectangle pokes above the curve. For an increasing function the left sum underestimates.
What happens as n grows?
The rectangles get thinner and every type of sum approaches the definite integral. Doubling n roughly halves the error of left and right sums and quarters the error of midpoint and trapezoid sums.
Why are some rectangles drawn in gold?
Those rectangles lie below the x-axis, where f(x) is negative. They subtract from the total, because a Riemann sum measures signed area.