Riemann Sums
Source inspiration: (Mathew 2000-2019).
Description
Riemann sums approximate a definite integral by partitioning \([a,b]\) into \(n\) subintervals and replacing the curve with simple shapes whose areas can be added exactly. As \(n\) increases, the partition width \(\Delta x = (b-a)/n\) decreases and the approximation converges to the true integral.
For a partition with nodes \(x_i = a + i\Delta x\), common choices are the left, right, lower, and upper sums: \(L_n = \sum_{i=0}^{n-1} f(x_i)\Delta x\), \(R_n = \sum_{i=1}^{n} f(x_i)\Delta x\), and bounds from interval minima/maxima.
The legacy Mathews animations increase sampling density over the entire interval between frames. The animations below follow that same pattern.
Animations
Each animation below shows a Riemann sum diagram over \([0, 2]\) for \(y = e^{-x}\sin(8x^{2/3})+1\). Between frames, the number of sample points increases across the full interval so the approximation refines by density, not by sweeping left-to-right.
Julia source scripts that generated these animations are linked under each case.
Case 1 — Left Riemann Sum, \(y = e^{-x}\sin(8x^{2/3})+1\)
Behavior: The rectangle height on each subinterval is taken at the left endpoint. As sample-point density increases, the approximation settles toward the true integral.

Case 2 — Right Riemann Sum, \(y = e^{-x}\sin(8x^{2/3})+1\)
Behavior: The rectangle height is taken at the right endpoint. Comparing with Case 1 shows how endpoint choice shifts the approximation at finite \(n\).

Case 3 — Lower Riemann Sum, \(y = e^{-x}\sin(8x^{2/3})+1\)
Behavior: Each rectangle uses the minimum endpoint value on each subinterval. For nonnegative \(f\), this gives a lower bound that rises toward the integral as density increases.

Case 4 — Upper Riemann Sum, \(y = e^{-x}\sin(8x^{2/3})+1\)
Behavior: Each rectangle uses the maximum endpoint value on each subinterval, giving an upper bound. Lower and upper sums squeeze the exact value as \(n \to \infty\).
