Definite integral as the limit of a Riemann sum

Riemann sums help us approximate definite integrals, but they also help us formally define definite integrals. Learn how this is achieved and how we can move between the representation of area as a definite integral and as a Riemann sum.
Definite integrals represent the area under the curve of a function, and Riemann sums help us approximate such areas. The question remains: is there a way to find the exact value of a definite integral?

Riemann sums with "infinite" rectangles

Imagine we want to find the area under the graph of $f(x)=\dfrac15x^2$ between $x=2$ and $x=6$.
Using definite integral notation, we can represent the exact area:
$\displaystyle\int_2^6 \dfrac15 x^2\,dx$
We can approximate this area using Riemann sums. Let $R(n)$ be the right Riemann sum approximation of our area using $n$ equal subdivisions (i.e. $n$ rectangles of equal width).
For example, this is $R(4)$. You can see it's an overestimation of the actual area.
The area under the curve of $f$ between $x=2$ and $x=6$ is approximated using $4$ rectangles of equal width.
We can make our approximation better by dividing our area into further rectangles that are smaller in width, i.e. by using $R(n)$ for larger values of $n$.
You can see how the approximation gets closer to the actual area as the number of rectangles goes from $1$ to $100$:
Created with Geogebra.
Of course, using even more rectangles will get us even closer, but an approximation is always just an approximation.
What if we could take a Riemann sum with infinite equal subdivisions? Is that even possible? Well, we can't set $n=\infty$ because infinity isn't an actual number, but you might recall we have a way of taking something to infinity...
Limits!
Specifically, this limit:
$\Large\displaystyle\lim_{n\to\infty}R(n)$
Amazing fact #1: This limit really gives us the exact value of $\displaystyle\int_2^6 \dfrac15 x^2\,dx$.
Amazing fact #2: It doesn't matter whether we take the limit of a right Riemann sum, a left Riemann sum, or any other common approximation. At infinity, we will always get the exact value of the definite integral.
(The rigorous proof of these facts is too elaborate to cover in this article, but that's okay because we're just interested in the intuition behind connecting Riemann sums and definite integrals.)
So far we've used $R(n)$ as a placeholder for the right Riemann sum approximation with $n$ subdivisions. Now let's find the actual expression.
Quick review: We are looking for $\greenD{\Delta x}$, the constant $\greenD{\text{width}}$ of any rectangle, and $\blueD{x_i}$, the $x$-value of the right edge of the $i^{\text{th}}$ rectangle. Then, $\goldD{f(\blueD{x_i})}$ will give us the $\goldD{\text{height}}$ of each rectangle.
\begin{aligned} \greenD{\Delta x}&=\dfrac{6-2}{n}=\greenD{\dfrac4n} \\\\ \blueD{x_i}&=2+\Delta x\cdot i=\blueD{2+\dfrac4n i} \\\\ \goldD{f(\blueD{x_i})}&=\dfrac15(x_i)^2=\goldD{\dfrac15\left(\blueD{2+\dfrac4n i}\right)^2} \end{aligned}
So the area of the $i^{\text{th}}$ rectangle is $\greenD{\dfrac4n}\cdot \goldD{\dfrac15\left(\blueD{2+\dfrac4n i}\right)^2}$, and we sum that for values of $i$ from $1$ to $n$:
$R(n)=\displaystyle\sum_{i=1}^{n}\left(2+\dfrac{4i}{n}\right)^2\cdot\dfrac{4}{5n}$
Now we can represent the actual area as a limit:
\begin{aligned} &\phantom{=}\displaystyle\int_2^6 {\dfrac15x^2\,}{dx} \\\\ &=\displaystyle\lim_{n\to\infty}R(n) \\\\ &=\displaystyle\lim_{n\to\infty}\sum_{i=1}^{n}\left(2+\dfrac{4i}{n}\right)^2\cdot\dfrac{4}{5n} \end{aligned}

By definition, the definite integral is the limit of the Riemann sum

The above example is a specific case of the general definition for definite integrals:
The definite integral of a continuous function $f$ over the interval $[a,b]$, denoted by $\displaystyle\int_a^b f(x)dx$, is the limit of a Riemann sum as the number of subdivisions approaches infinity. That is,
$\displaystyle\int_a^b {f(x)}{dx}=\lim_{n\to\infty}\sum_{i=1}^n \greenD{\Delta x} \cdot \goldD{f(\blueD{x_i})}$
where $\greenD{\Delta x}=\dfrac{b-a}{n}$ and $\blueD{x_i=a+\Delta x\cdot i}$.

If we're asked to write a Riemann sum from a definite integral...

Imagine we've been asked to write the following definite integral as the limit of a Riemann sum.
$\displaystyle \int_\pi^{2\pi} \cos(x)\,dx$
First, let's find $\greenD{\Delta x}$:
\begin{aligned} \greenD{\Delta x}&=\dfrac{ b- a}{n} \\\\ &=\dfrac{{2\pi}- \pi}{n} \\\\ &=\greenD{\dfrac{\pi}{n}} \end{aligned}
Now that we have $\greenD{\Delta x}$, we can find $\blueD{x_i}$:
\begin{aligned} \blueD{x_i}&= a+\greenD{\Delta x}\cdot i \\\\ &= \pi+\greenD{\dfrac{\pi}{n}}\cdot i \\\\ &=\blueD{\pi+\dfrac{\pi i}{n}} \end{aligned}
Therefore,
$\displaystyle \int_\pi^{2\pi} \cos(x)\,dx=\lim_{n\to\infty}\sum_{i=1}^n\greenD{\dfrac\pi n}\cdot \goldD{\cos\left(\blueD{\pi+\dfrac{\pi i}n}\right)}$

Practice writing Riemann sums from definite integrals

Problem 1
$\displaystyle \int_0^3 e^x\,dx=\,?$
Problem 2
$\displaystyle \int_1^e \ln x\,dx=\,?$

Common mistake: Getting the wrong expression for $\Delta x$

For example, in Problem 2, we can imagine how a student might define $\Delta x$ to be $\dfrac en$ or $\dfrac{1}{n}$ instead of $\dfrac{e-1}{n}$. Another example is simply using $dx$ for $\Delta x$. Remember that $dx$ is only used in the integral notation, not in the sum. It tells us that the integration is with respect to $x$.

Another common mistake: Getting the wrong expression for $x_i$

A student might forget to add $a$ to $\Delta x\cdot i$, resulting in a wrong expression. For example, in Problem 2, a student might define $x_i$ to be $\dfrac{e-1}{n}\cdot i$ instead of $1+\dfrac{e-1}{n}\cdot i$.

If we're asked to write a definite integral from the limit of a Riemann sum...

Imagine we're being asked to find a definite integral that's equivalent to this limit:
$\displaystyle \lim_{n\to\infty} \sum_{i=1}^n \ln\left(2+\dfrac{5i}n\right)\cdot\dfrac5n$
This means we need to find the interval of integration $[\purpleC a,\purpleC b]$ and the integrand $\goldD{f(x)}$. Then, the corresponding definite integral will be $\displaystyle\int_{\purpleC a}^{\purpleC b} \goldD{f(x)}\,dx$.
We know that every Riemann sum has two parts: a width $\greenD{\Delta x}$ and a height $\goldD{f(\blueD{x_i})}$ for each rectangle in the sum. Looking at this specific limit, we can make reasonable choices for both parts.
$\displaystyle \lim_{n\to\infty} \sum_{i=1}^n \goldD{\ln\left(\blueD{2+\dfrac{5i}n}\right)}\cdot \greenD{\dfrac5n}$
Rectangles of uniform width: The expression $\greenD{\dfrac5n}$ is a reasonable choice for the width of our rectangles, $\greenD{\Delta x}$, because it doesn't depend on the index $i$. This means that $\greenD{\Delta x}$ will be the same for each term in the sum, which is what we'd expect from a Riemann sum where each rectangle has the same width.
Rectangles of varying height: The expression $\goldD{{\ln\left(\blueD{2+\dfrac{5i}n}\right)}}$ depends on $i$, which makes it a good choice to represent the height, $\goldD{f(\blueD{x_i})}$. The most natural choice for $\blueD{x_i}$ is $\blueD{2+\dfrac{5i}n}$, so let's go with that, which means that the function we're integrating is $\goldD{f(x)}=\goldD{\ln(x)}$.
To figure out the bounds of integration, $a$ and $b$, let's think back to the general definitions of $\greenD{\Delta x}$ and $\blueD{x_i}$ in relation to the definite integral.
As defined above, $\blueD{x_i}=\purpleC a+\greenD{\Delta x}\cdot i~$. In this specific problem, $\blueD{x_i} = \blueD{2+\dfrac{5i}n}$, which can be written as $\purpleC 2 + \greenD{\dfrac{5}{n}}i$, so $\purpleC a$ must equal $\purpleC 2$.
As defined above, $\greenD{\Delta x}=\dfrac{b-a}{n}~$. In this specific problem, $\greenD{\Delta x}=\dfrac5n$. Both denominators are $n$, so the numerators must be equal: $b-a=5$. We already know $\purpleC{a=2}$, so we can conclude that $\purpleC{b=7}$.
Putting everything together, here's a definite integral that equals the limit of the Riemann sum:
$\displaystyle \int_{ \purpleC 2}^{ \purpleC 7}\goldD{\ln(x)}\,dx$

Practice writing definite integrals from Riemann sums

Problem 3.A
Problem set 3 will walk you through the steps of finding the definite integral that is represented by this expression:
$\displaystyle \lim_{n\to\infty} \sum_{i=1}^n \left(3+\dfrac{4i}{n}\right)^2\cdot\dfrac4n$
What is $\Delta x$ in this expression?

Common struggle: Difficulty finding $\Delta x$ in the Riemann sum expression

When the summed expression is elaborate and includes many fractions, it can be hard to identify which part of it is $\Delta x$.
Remember that $\Delta x$ must be a factor of the summed expression, in the form $\dfrac{k}{n}$, where $k$ doesn't contain the summation index $i$.

Another common struggle: Difficulty finding the limits of integration

Notice how in Problem set 3, the fact that $\Delta x=\dfrac4n$ told us that $b-a=4$. This is helpful, but without finding $a$ we will not know what $a$ and $b$ are. We were able to find $a$ by using the fact that $x_i=3+\dfrac{4i}{n}$.
A common mistake is to immediately assume that if, for example, $\Delta x=\dfrac4n$, then the limits of integration are $[0,4]$.

One last common struggle: General difficulty analyzing the expression

Some students simply don't know where to begin.
Begin with the summed expression. You should be able to identify two factors: One of the form $\dfrac{k}{n}$ (where $k$ doesn't contain the summation index $i$) and one that is a function of $i$. The first will give you $\greenD{\Delta x}$ and the other will give you $\blueD{f(\goldD{x_i})}$.
Problem 4
$\displaystyle \lim_{n\to\infty} \sum_{i=1}^n \sqrt{4+\dfrac{5i}n}\cdot\dfrac5n=\,?$