Riemann Sums

Go for a run with your phone in your pocket and it will tell you, at the end, exactly how far you went — even though it never measured a distance. All it ever measured was your speed, once a second. So how does it know the distance?

It cheats, beautifully. For each one-second slice it pretends your speed was constant, so distance = speed × time works on that slice; then it adds the slices up. If you ran at about 3\,\mathrm{m/s} for one second, that slice contributed about 3 metres. A thousand tiny "pretend it's constant" slices later, out comes your run. The pretence is never exactly right — your speed drifts within each second — but the thinner the slices, the smaller the lie.

Surveyors play the same trick with a lake: no formula from geometry class gives the area of a wiggly shoreline, so they slice the lake into thin parallel strips, treat each strip as a rectangle, and add. This chapter is that trick made precise — and it is the doorway to the whole of integration.

The recipe: chop, sample, sum

Here is the general problem. How much area sits under the curve y = f(x) between x = a and x = b? When the top boundary is curved there is no ready-made area formula. 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. Each rectangle has area \text{height} \times \text{width} = f(x_i^{*})\,\Delta x, and the total tiled area is a Riemann sum:

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

Every symbol earns its keep: f(x_i^{*}) is a height, \Delta x is a width, the \Sigma adds one rectangle per strip. It is your fitness app's calculation with the labels changed — there the "heights" were speeds and the "widths" were seconds. The sums are named after Bernhard Riemann, who in 1854 pinned down precisely when this rectangle game has a well-defined answer.

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:

Notice that L_n and R_n use almost the same heights: both include f(x_1), \dots, f(x_{n-1}). The only difference is the two ends — the left sum uses f(a) and skips f(b); the right sum does the opposite. Subtracting kills everything in between:

R_n - L_n = \big(f(b) - f(a)\big)\,\Delta x.

Keep that little identity in your pocket — it will tell us exactly how fast the two sums close in on each other.

Worked example 1 — a left sum, every digit shown

Take f(x) = x^2 on [0, 1] with n = 4 strips. (The true area, which we'll be able to compute exactly once we have the definite integral, is \tfrac13 \approx 0.3333 — keep it in view as the target.)

Step 1 — the grid. \Delta x = \tfrac{1-0}{4} = \tfrac14, so the strip edges sit at 0,\ \tfrac14,\ \tfrac12,\ \tfrac34,\ 1.

Step 2 — the left-edge heights. The left sum samples the left edge of each strip, so the four heights are

f(0) = 0, \quad f\!\left(\tfrac14\right) = \tfrac{1}{16}, \quad f\!\left(\tfrac12\right) = \tfrac{4}{16}, \quad f\!\left(\tfrac34\right) = \tfrac{9}{16}.

Step 3 — add, then multiply by the width.

L_4 = \left(0 + \tfrac{1}{16} + \tfrac{4}{16} + \tfrac{9}{16}\right)\cdot\tfrac14 = \tfrac{14}{16}\cdot\tfrac14 = \tfrac{14}{64} = \tfrac{7}{32} = 0.21875.

That's noticeably below the true 0.3333 — and it had to be. Since x^2 is increasing on [0,1], each strip's left edge is its lowest point, so every left rectangle tucks entirely under the curve. L_4 is a guaranteed underestimate.

Worked example 2 — the right sum brackets the truth

Same curve, same four strips, but now sample the right edges \tfrac14, \tfrac12, \tfrac34, 1:

R_4 = \left(\tfrac{1}{16} + \tfrac{4}{16} + \tfrac{9}{16} + \tfrac{16}{16}\right)\cdot\tfrac14 = \tfrac{30}{16}\cdot\tfrac14 = \tfrac{30}{64} = \tfrac{15}{32} = 0.46875.

For an increasing curve the right edge is each strip's highest point, so every right rectangle pokes above the curve: R_4 is a guaranteed overestimate. Put the two together and the true area is trapped:

\underbrace{0.21875}_{L_4} \;<\; \underbrace{\tfrac13}_{\text{true}} \;<\; \underbrace{0.46875}_{R_4}.

This is more than a pair of guesses — it's a certificate. Without knowing any integration at all, we have proved the area lies between 0.219 and 0.469. And check the gap: R_4 - L_4 = 0.25, exactly \big(f(1) - f(0)\big)\Delta x = 1 \cdot \tfrac14, just as our pocket identity promised.

Worked example 3 — refine and squeeze

Now double the strips. With n = 8, \Delta x = \tfrac18 and the heights are \left(\tfrac{i}{8}\right)^2 = \tfrac{i^2}{64}. Using 0 + 1 + 4 + 9 + 16 + 25 + 36 + 49 = 140 for the left edges:

L_8 = \frac{140}{64}\cdot\frac18 = \frac{140}{512} = \frac{35}{128} \approx 0.2734, \qquad R_8 = \frac{140 + 64}{512} = \frac{51}{128} \approx 0.3984.

The trap has tightened from both sides. Push on (a spreadsheet or a few lines of code does the drudgery) and watch the squeeze:

\begin{array}{c|c|c|c} n & L_n & R_n & R_n - L_n \\ \hline 4 & 0.21875 & 0.46875 & 0.25 \\ 8 & 0.27344 & 0.39844 & 0.125 \\ 100 & 0.32835 & 0.33835 & 0.01 \\ 1000 & 0.33283 & 0.33383 & 0.001 \end{array}

The gap is R_n - L_n = \tfrac{1}{n} — it halves every time n doubles, and the one number caught between the closing jaws for every n is \tfrac13. That squeezing-to-a-single-value is the whole story of integration in miniature.

Taking the limit exactly — a sum we can finish by hand

The table above suggests the limit is \tfrac13, but a table is not a proof. To see a Riemann sum actually reach its limit, switch to the friendlier curve 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. The same manoeuvre with the sum of squares formula \sum i^2 = \tfrac{n(n+1)(2n+1)}{6} nails our x^2 example to exactly \tfrac13 — try it.

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.

Archimedes, in the third century BC. To find the area of a parabolic segment he stuffed it with triangles: one big triangle, then two smaller ones in the leftover gaps, then four, then eight — each round of triangles "exhausting" more of the missing area. The pieces shrank in a perfect geometric pattern, 1 + \tfrac14 + \tfrac{1}{16} + \cdots, and he proved the total is exactly \tfrac43 of the first triangle. No limits, no algebra, no coordinate axes — yet the strategy is pure Riemann: approximate with shapes you can measure, refine, and corner the true value between an under- and an over-estimate. It took two millennia for the calculus of Newton and Leibniz to turn his one-off masterpiece into a machine, and Riemann in 1854 to say precisely when the machine is guaranteed to work. Your phone runs the same idea today: GPS fitness apps, flight computers, and Mars-landing software all integrate speed into distance one thin slice at a time.

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

Everything above, live. 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.

Three experiments worth running:

See it explained