Riemann Sums and Definite Integrals

The area under y = x² from 2 to 6, approximated with four rectangles and then computed exactly as a limit of Riemann sums.

The shaded region below is bounded by the curve y=x2y = x^2, the xx-axis, and the vertical lines x=2x = 2 and x=6x = 6. We want to find its area.
The region under y = x² from x = 2 to x = 6.
There is no area formula for a region with a curved boundary, as there is for a rectangle or a triangle. We approximate the region with rectangles, whose areas we can compute, and then take a limit to make the approximation exact.

Four rectangles, right endpoints

Divide the interval [2,6][2, 6] into four subintervals of equal width. The width of each subinterval is
Δx=624=1.\Delta x = \frac{6 - 2}{4} = 1.
The four subintervals are [2,3][2, 3], [3,4][3, 4], [4,5][4, 5] and [5,6][5, 6]. On each subinterval we draw a rectangle whose height is the value of ff at the right endpoint: f(3)=9f(3) = 9, f(4)=16f(4) = 16, f(5)=25f(5) = 25 and f(6)=36f(6) = 36.
R₄: four rectangles of width 1, with heights f(3), f(4), f(5) and f(6).
The area of each rectangle is height times width. The sum of the four areas is the right Riemann sum with four rectangles, written R4R_4:
R4=f(3)Δx+f(4)Δx+f(5)Δx+f(6)Δx=9+16+25+36=86.R_4 = f(3)\,\Delta x + f(4)\,\Delta x + f(5)\,\Delta x + f(6)\,\Delta x = 9 + 16 + 25 + 36 = 86.
Since ff is increasing on [2,6][2, 6], each rectangle extends above the curve. Thus R4=86R_4 = 86 is an overestimate of the area.

Four rectangles, left endpoints

We use the same four subintervals, so again Δx=1\Delta x = 1. Now the height of each rectangle is the value of ff at the left endpoint: f(2)=4f(2) = 4, f(3)=9f(3) = 9, f(4)=16f(4) = 16 and f(5)=25f(5) = 25.
L₄: the same four subintervals, with heights f(2), f(3), f(4) and f(5).
L4=f(2)Δx+f(3)Δx+f(4)Δx+f(5)Δx=4+9+16+25=54.L_4 = f(2)\,\Delta x + f(3)\,\Delta x + f(4)\,\Delta x + f(5)\,\Delta x = 4 + 9 + 16 + 25 = 54.
Every rectangle lies below the curve, so L4=54L_4 = 54 is an underestimate. Thus the exact area AA satisfies
54<A<86.54 < A < 86.

More rectangles

With four rectangles the approximation is rough. Use the slider to increase the number of rectangles nn. The readout shows the Riemann sum, the exact area, and the error. Compare the left and right sums: at n=4n = 4 they differ by 3232, and both approach the same value as nn increases.

Any number of rectangles

The same construction works for any number of rectangles. Take an interval [a,b][a, b] and divide it into nn subintervals of equal width. We use right endpoints.
R₁₆: sixteen rectangles with right endpoints. The overestimate is smaller.
The width of each rectangle is
Δx=ban,\Delta x = \frac{b - a}{n},
and the right endpoints are
x1=a+Δx,x2=a+2Δx,,xi=a+iΔx,,xn=b.x_1 = a + \Delta x, \qquad x_2 = a + 2\,\Delta x, \qquad \ldots, \qquad x_i = a + i\,\Delta x, \qquad \ldots, \qquad x_n = b.
The ii-th rectangle has height f(xi)f(x_i) and width Δx\Delta x. The sum of the nn areas is the approximate area,
Rn=f(x1)Δx+f(x2)Δx++f(xn)Δx=i=1nf(xi)Δx,R_n = f(x_1)\,\Delta x + f(x_2)\,\Delta x + \cdots + f(x_n)\,\Delta x = \sum_{i=1}^{n} f(x_i)\,\Delta x,
and the exact area is the limit of this sum as nn \to \infty:
A=limn[f(x1)Δx+f(x2)Δx++f(xn)Δx].A = \lim_{n \to \infty} \bigl[f(x_1)\,\Delta x + f(x_2)\,\Delta x + \cdots + f(x_n)\,\Delta x\bigr].
It can be proved that this limit always exists when ff is continuous. It can also be shown that we get the same value using left endpoints, where x0=ax_0 = a:
A=limnLn=limn[f(x0)Δx+f(x1)Δx++f(xn1)Δx].A = \lim_{n \to \infty} L_n = \lim_{n \to \infty} \bigl[f(x_0)\,\Delta x + f(x_1)\,\Delta x + \cdots + f(x_{n-1})\,\Delta x\bigr].
For f(x)=x2f(x) = x^2 on [2,6][2, 6], RnR_n approaches AA from above and LnL_n from below, as the explorer shows.

Setting up the exact area

We return to f(x)=x2f(x) = x^2 on [2,6][2, 6], now with nn rectangles and right endpoints. Here a=2a = 2 and b=6b = 6, so
Δx=62n=4n,xi=2+iΔx=2+4in.\Delta x = \frac{6 - 2}{n} = \frac{4}{n}, \qquad x_i = 2 + i\,\Delta x = 2 + \frac{4i}{n}.
The height of the ii-th rectangle is
f(xi)=(2+4in)2=4+16in+16i2n2,f(x_i) = \left(2 + \frac{4i}{n}\right)^2 = 4 + \frac{16i}{n} + \frac{16i^2}{n^2},
Thus the right Riemann sum is
Rn=i=1nf(xi)Δx=i=1n(4+16in+16i2n2)4n=i=1n(16n+64in2+64i2n3).\begin{aligned} R_n = \sum_{i=1}^{n} f(x_i)\,\Delta x &= \sum_{i=1}^{n} \left(4 + \frac{16i}{n} + \frac{16i^2}{n^2}\right)\frac{4}{n} \\[8pt] &= \sum_{i=1}^{n} \left(\frac{16}{n} + \frac{64i}{n^2} + \frac{64i^2}{n^3}\right). \end{aligned}
We cannot finish this computation yet. The sum has nn terms, and nn is a variable, so the terms cannot be written out and added. To take the limit we need closed-form formulas for i=1n1\sum_{i=1}{n} 1, i=1ni\sum_{i=1}{n} i and i=1ni2\sum_{i=1}{n} i2. These formulas come from the sequences and series unit of Algebra 2 or Precalculus.

Summation formulas

The properties let us split a sum term by term and factor out constants. Note that nn is a constant with respect to the index ii, so any power of nn can be factored out of the sum.

Computing the exact area

We split the sum into three sums and factor out the constants:
Rn=16ni=1n1+64n2i=1ni+64n3i=1ni2.R_n = \frac{16}{n}\sum_{i=1}^{n} 1 + \frac{64}{n^2}\sum_{i=1}^{n} i + \frac{64}{n^3}\sum_{i=1}^{n} i^2.
Now we apply the summation formulas:
Rn=16nn+64n2n(n+1)2+64n3n(n+1)(2n+1)6=16+32(n+1)n+32(n+1)(2n+1)3n2.\begin{aligned} R_n &= \frac{16}{n}\cdot n + \frac{64}{n^2}\cdot\frac{n(n+1)}{2} + \frac{64}{n^3}\cdot\frac{n(n+1)(2n+1)}{6} \\[8pt] &= 16 + \frac{32(n+1)}{n} + \frac{32(n+1)(2n+1)}{3n^2}. \end{aligned}
This is a formula for RnR_n for any nn. As a check, n=4n = 4 gives 16+40+30=8616 + 40 + 30 = 86, which is R4R_4. Now we take the limit. Since n+1n1\frac{n+1}{n} \to 1 and (n+1)(2n+1)n22\frac{(n+1)(2n+1)}{n^2} \to 2 as nn \to \infty,
A=limnRn=16+32+643=208369.33.A = \lim_{n \to \infty} R_n = 16 + 32 + \frac{64}{3} = \frac{208}{3} \approx 69.33.
The exact area is 208369.33\frac{208}{3} \approx 69.33. Note that L4=54<2083<R4=86L_4 = 54 < \frac{208}{3} < R_4 = 86, as expected.