Riemann Sums and Definite Integrals

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. This lesson finds its area, first approximately and then exactly.
The region under y = x² from x = 2 to x = 6.
Geometry has no formula for the area of this region, as it has for a rectangle, a triangle, or a circle. 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 into subintervals of equal width and stand a rectangle on each one. When each rectangle's height is the value of ff at the right endpoint of its subinterval, the sum of the rectangle areas is the right Riemann sum. With four rectangles it is written R4R_4.

Four rectangles, left endpoints

The left Riemann sum uses the same subintervals and reads each height at the left endpoint.
The two sums bracket the exact area AA:
54<A<86.54 < A < 86.
Both directions come from ff being increasing. On a decreasing function they reverse. Each left endpoint then gives the largest value of ff on its subinterval, and each right endpoint the smallest. So the left sum is too big and the right sum too small.

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.
The third button, Midpoint, reads each height at the center of its subinterval. The section on any sample point below works out that sum for four rectangles.

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=b−an,\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 n→∞n \to \infty:
A=lim⁡n→∞[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].
For a continuous ff this limit always exists. The left sums, which start at x0=ax_0 = a, approach the same number:
A=lim⁡n→∞Ln=lim⁡n→∞[f(x0) Δx+f(x1) Δx+⋯+f(xn−1) Δ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.

Any sample point

Left endpoints and right endpoints are two choices out of many. Nothing in the construction requires a rectangle's height to come from an end of its subinterval. The height may be the value of ff at any point of the ii-th subinterval [xi−1,xi][x_{i-1}, x_i]. Call that point cic_i, a sample point.
Whatever the sample points, the sum of the nn rectangle areas is called a Riemann sum:
∑i=1nf(ci) Δx=f(c1) Δx+f(c2) Δx+⋯+f(cn) Δx.\sum_{i=1}^{n} f(c_i)\,\Delta x = f(c_1)\,\Delta x + f(c_2)\,\Delta x + \cdots + f(c_n)\,\Delta x.
The left, right, and midpoint sums are all Riemann sums. They differ only in which point of the ii-th subinterval cic_i is.

Integrable functions

Three choices of sample point gave three different numbers: 5454, 6969, and 8686. Each one approximates the same area. The definition below asks that they all approach one limit as nn grows.
The definition asks for two things. The limit has to exist, and its value must not depend on where the sample points were taken.
Every function continuous on [a,b][a, b] is integrable there. So is every bounded function with only finitely many discontinuities, such as jumps or holes. Until improper integrals at the end of this unit, every function we integrate is one of these.
Every choice of sample point then produces the same limit, so we take whichever is easiest to compute with. That is the right endpoint, xi=a+i Δxx_i = a + i\,\Delta x. The left endpoint is a+(i−1) Δxa + (i - 1)\,\Delta x and the midpoint is a+(i−12)Δxa + \left(i - \frac{1}{2}\right)\Delta x, and the extra −1-1 or −12-\frac{1}{2} carries into every term of the sums that follow. We use right endpoints from here on.

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.
We can't add up this sum yet. It has nn terms, and nn is a variable, so the terms can't be written out one by one. To take the limit we need closed-form formulas for
∑i=1n1,∑i=1ni,∑i=1ni2.\sum_{i=1}^{n} 1, \qquad \sum_{i=1}^{n} i, \qquad \sum_{i=1}^{n} i^2.

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 took the limit with right endpoints. Since x2x^2 is continuous on [2,6][2, 6], it is integrable there, so every other choice of sample point gives the same number. That number is the definite integral:
∫26x2 dx=2083.\int_{2}^{6} x^2\,dx = \frac{208}{3}.