Riemann Sums

How much area sits under the curve y = f(x) between x = a and x = b? When the boundary is curved there is no area formula from geometry class. The fix is wonderfully blunt: tile the region with thin rectangles, add up their areas, and let the rectangles get thinner.

Chop [a, b] into n equal strips, each of width

\Delta x = \frac{b - a}{n}.

On each strip stand a rectangle whose height is f sampled at some point x_i^{*} inside that strip. The total tiled area is a Riemann sum:

S_n = \sum_{i=1}^{n} f(x_i^{*})\,\Delta x.

Where you sample inside each strip gives the sum its name: the left, right, or midpoint rule.

Left, right, and midpoint, side by side

With strip i running from x_{i-1} to x_i where x_i = a + i\,\Delta x:

A sum we can do by hand — line by line

Take f(x) = x on [0, 1]. Geometry already knows the answer — the region is a right triangle with legs 1 and 1, so the area is \tfrac12. Let us watch the right Riemann sum march to exactly that as n \to \infty.

Step 1 — set up the grid. With a = 0, b = 1, the width is \Delta x = \tfrac{1}{n} and the right edge of strip i sits at x_i = \tfrac{i}{n}.

Step 2 — write the right sum. Since f(x) = x, the height at x_i is just x_i = \tfrac{i}{n}:

R_n = \sum_{i=1}^{n} f\!\left(\frac{i}{n}\right)\frac{1}{n} = \sum_{i=1}^{n} \frac{i}{n}\cdot\frac{1}{n}.

Step 3 — pull the constants out of the sum. The factor \tfrac{1}{n^2} does not depend on i:

R_n = \frac{1}{n^2}\sum_{i=1}^{n} i.

Step 4 — use Gauss's sum \sum_{i=1}^{n} i = \dfrac{n(n+1)}{2}:

R_n = \frac{1}{n^2}\cdot\frac{n(n+1)}{2} = \frac{n(n+1)}{2n^2}.

Step 5 — simplify. Cancel one factor of n:

R_n = \frac{n+1}{2n} = \frac{1}{2} + \frac{1}{2n}.

Step 6 — take the limit. As n \to \infty the crumb \tfrac{1}{2n} \to 0, so

\lim_{n\to\infty} R_n = \frac{1}{2}.

The Riemann sum converges to \tfrac12 — exactly the triangle's area. The +\tfrac{1}{2n} is the overshoot of the right rule (each rectangle pokes above the line); it shrinks away as the strips thin.

For a continuous f on a closed interval, every choice of sample points gives sums converging to the same limit as the mesh \Delta x \to 0. Continuity controls how much f can wiggle within a strip: over a tiny width the spread between the largest and smallest values is uniformly small, so left, right, and midpoint all get squeezed together. That common limit is what we will christen the definite integral.

Let f be continuous on [a, b], and partition the interval into n equal strips of width \Delta x = \tfrac{b-a}{n}. Then, for any choice of sample points x_i^{*} in the strips, the Riemann sums converge:

\lim_{n\to\infty} \sum_{i=1}^{n} f(x_i^{*})\,\Delta x \quad\text{exists and is independent of the sample points.}

That common limit is the (signed) area under f over [a, b]. In particular the left, right, and midpoint sums all share the same limit.

Watch the rectangles converge

The curve is f(x) = x^2 on [0, 2], whose true area is \int_0^2 x^2\,dx = \tfrac{8}{3} \approx 2.667. Slide n up and the rectangles thin; flip the rule between left, right, and midpoint sampling. The live readout shows the sum closing in on the true area — fastest for the midpoint rule.