MISSION · Calculus
Riemann Sums and Numerical Integration
Rectangles under a curve, and what happens as they get thin
LEVEL 1 · EXPLORE
Make the idea move
Change the controls and watch what happens. Follow your curiosity and see what you notice.
Loading the activity…
LEVEL 2 · LEARN
Unlock the explanation
Open the chapters in any order. Try the examples as you go.
The idea in one sentence
You cannot find the area under a curve directly, so you cover it with shapes whose area you do know, and then make those shapes narrower until the error stops mattering.
Setting one up
To estimate \(\int_a^b f(x)\,dx\) with \(n\) rectangles, first cut the interval into \(n\) equal strips, each of width
\[\Delta x = \frac{b - a}{n}\]Each rectangle’s width is \(\Delta x\). What differs between methods is where you read the height.
- Left sum: the height is \(f\) at the left edge of each strip.
- Right sum: the height is \(f\) at the right edge.
- Midpoint sum: the height is \(f\) at the centre.
Then add up width × height for all \(n\) strips.
\[L_n = \sum_{i=0}^{n-1} f(a + i\,\Delta x)\,\Delta x \qquad R_n = \sum_{i=1}^{n} f(a + i\,\Delta x)\,\Delta x\]The two sums use the same list of heights except for the endpoints — left includes \(f(a)\) and stops before \(f(b)\), right does the opposite. That is the only difference.
Which way does the estimate lean?
This is asked constantly, and it is worth reasoning out rather than memorising.
On an increasing function, the left edge is the lowest point of each strip, so every rectangle sits under the curve: the left sum underestimates. The right sum, taking the tallest point of each strip, overestimates. On a decreasing function both conclusions swap.
Concavity decides the other two. On a curve that is concave up, trapezoids cut across above the curve, so the trapezoid rule overestimates, and the midpoint rule underestimates. Concave down reverses both.
None of it needs memorising if you sketch one strip and look at where the rectangle pokes out.
The trapezoid rule
Instead of a flat top, join the two edge heights with a straight line. Each strip becomes a trapezoid of area \(\frac{f(x_i) + f(x_{i+1})}{2}\Delta x\), and adding them gives
\[T_n = \frac{\Delta x}{2}\left[f(x_0) + 2f(x_1) + 2f(x_2) + \cdots + 2f(x_{n-1}) + f(x_n)\right]\]The interior heights are doubled because each is shared by two trapezoids; the two ends belong to one each. That \(1, 2, 2, \dots, 2, 1\) pattern is the whole formula.
\(T_n\) is also just the average of \(L_n\) and \(R_n\), which is a faster way to compute it if you already have both.
Try it on \(\int_0^4 x^2\,dx\) with 2 strips: \(\Delta x = 2\), heights \(0, 4, 16\), so \(T_2 = \frac{2}{2}[0 + 2(4) + 16] = 24\). The true value is \(\frac{64}{3} \approx 21.33\), so the overestimate is what concave up predicted.
Why it matters after you learn antiderivatives
Once you can integrate \(x^2\) exactly, rectangles look like a stage you have passed. Two reasons they are not.
The definition. \(\int_a^b f(x)\,dx\) is the limit of these sums as \(n \to \infty\). Everything else — the Fundamental Theorem, every integration technique — is machinery for evaluating that limit without doing it by hand.
Most functions have no antiderivative in elementary terms. \(e^{-x^2}\), central to statistics, is the famous case. Every normal-distribution probability anyone has ever quoted came from numerical integration, and so does most of what a physics engine or a spreadsheet computes.
When data arrives as a table of readings rather than a formula, sums are the only option there has ever been.
Common mix-ups
- Using \(n\) heights for \(n+1\) points. A partition of \([0,8]\) into 4 strips has 5 boundary points. Off-by-one here is the most common lost mark.
- Forgetting to multiply by \(\Delta x\). Adding the heights alone gives a number with no area in it.
- Doubling the endpoints in the trapezoid rule. Only the interior heights double.
- Assuming more rectangles is always better in practice. Mathematically yes; numerically, thousands of tiny strips accumulate rounding error.
Check yourself
For an increasing function, does a left sum over- or underestimate? What is \(\Delta x\) for 4 rectangles on \([0, 8]\)? And what does the trapezoid rule with 2 strips give for \(\int_0^4 x^2\,dx\)?
Left edges are the low points of an increasing curve, so it underestimates. \(\Delta x = \frac{8-0}{4} = 2\). And \(\frac{2}{2}[0 + 2(4) + 16] = 24\), an overestimate of the true \(21.33\) because \(x^2\) is concave up.
LEVEL 3 · REFLECT
Add this quest to your trail
When you feel ready, mark this idea as explored. You can always come back and try it again.
EXPLORER STRATEGIES