Riemann Sum
Left, right, midpoint and trapezoid sums for any function, with the convergence as n grows.
Strip width 0.1 · Rectangle height from the left edge of each strip
| n | Sum | Error |
|---|---|---|
| 4 | 0.21875 | 1.15e-1 |
| 10 | 0.285 | 4.83e-2 |
| 50 | 0.3234 | 9.93e-3 |
| 200 | 0.3308375 | 2.50e-3 |
| 1000 | 0.3328335 | 5.00e-4 |
A Riemann sum approximates the area under a curve with rectangles. Split [a, b] into n strips of width (b − a)/n, take a height from each, and add up the areas. As n grows the sum converges on the definite integral — that limit is what the integral is defined to be.
The definition, not just an approximation
It is easy to treat Riemann sums as a rough method you use before learning proper integration. They are the other way round: the definite integral is defined as the limit of these sums as the strips become infinitely thin. Antiderivatives are a way of evaluating that limit quickly, which the Fundamental Theorem of Calculus licenses — but the sum is the thing being evaluated.
That is why the sums still matter after you can integrate. Plenty of functions have no elementary antiderivative, and for those the only route to a number is to sum something. It is also why the method generalises so readily to data: if you have measurements rather than a formula, a trapezoid sum over the samples is still meaningful.
Where the height comes from
The four choices differ only in where each rectangle's height is read. The left rule uses the left edge of each strip, the right rule the right edge, the midpoint rule the centre, and the trapezoid rule averages the two edges — drawing a straight line across the top instead of a flat one. On a function that is increasing throughout, left always underestimates and right always overestimates, which brackets the true value between them.
xᵢ* is the sample point in each strip — its left edge, right edge or midpoint
- 1 Find the strip width. For f(x) = x² on [0, 1] with n = 4, Δx = (1 − 0) ÷ 4 = 0.25.
- 2 List the sample points. The left rule uses x = 0, 0.25, 0.5, 0.75 — the left edge of each strip.
- 3 Evaluate the function at each. f gives 0, 0.0625, 0.25 and 0.5625.
- 4 Add them and multiply by the width. (0 + 0.0625 + 0.25 + 0.5625) × 0.25 = 0.21875.
- 5 Compare against the true value. The integral is exactly 1/3 ≈ 0.3333, so four left rectangles underestimate substantially — increasing n closes the gap.
The four rules on f(x) = x² over [0, 1]
The true value is 1/3 ≈ 0.333333. Notice how much better the midpoint and trapezoid rules do at the same n.
| n | Left | Right | Midpoint | Trapezoid |
|---|---|---|---|---|
| 4 | 0.21875 | 0.46875 | 0.328125 | 0.34375 |
| 10 | 0.285 | 0.385 | 0.3325 | 0.335 |
| 50 | 0.3234 | 0.3434 | 0.3333 | 0.3334 |
| 200 | 0.330838 | 0.335838 | 0.333331 | 0.333338 |
How fast each rule converges
Left and right sums halve their error when n doubles — first order, and the reason they need so many strips to be useful. The midpoint and trapezoid rules are second order, so doubling n cuts their error by a factor of four, which is why they are ahead by two decimal places at the same n in the table above.
The midpoint rule usually beats the trapezoid rule despite both being second order, because its errors on a convex function point the opposite way and are about half the size. A useful consequence: on a function that curves consistently, the true value lies between the midpoint and trapezoid estimates, so the two together bracket the answer.
Two cautions on what this tool reports. The value it compares against is Simpson’s rule at 20,000 intervals — a very accurate numerical result, not a symbolic one, so for an integrand with a vertical tangent at an endpoint such as √x even the reference carries error. And a function undefined anywhere in the interval stops the calculation rather than being silently skipped.