Math

Riemann Sums

A definite integral is the limit of rectangle sums. Increase the number of subintervals and compare left, right, and midpoint rules against the exact area.

6 minLevel 2/3The interactive stage stays ad-free.
Rectangles6Estimate14.5926Exact14.6667Error0.51%

The amber curve is f(x) = 0.5x² + 1 on [0, 4]. Cyan shapes approximate the area underneath. Press Play to add rectangles; midpoint and trapezoid rules usually converge much faster than left or right endpoints.

What you are seeing

1

Split the interval into n equal pieces. Each rectangle uses the function value at a sample point.

2

Left and right rules tend to under- or overestimate on monotone curves; the midpoint rule often cancels errors.

3

As n grows, the rectangle area converges to the exact integral, regardless of the sampling rule.

Why it matters

Riemann sums connect discrete computation with continuous area. They are the intuition behind numerical integration, probability densities, and physics.

Complexity & details

Each estimate costs O(n) function evaluations. Midpoint error is O(1/n²) for smooth functions; left/right error is O(1/n).

Frequently asked questions

Why does the midpoint rule work better?+

On each interval, the midpoint value balances positive and negative linear error. For smooth functions the leading error terms cancel.

Do all Riemann sums converge to the same value?+

For continuous functions, yes. Any sequence of partitions with shrinking mesh width converges to the same definite integral.