# Difference between revisions of "Riemann Sums"

Jump to navigation Jump to search

## Approximating Area Under a Curve

Graphically, we can consider a definite integral, such as

${\displaystyle {\displaystyle \int _{0}^{1}x^{2}\,dx}}$

to be the area "under the curve", which might be better said as the area that lies between the line ${\displaystyle x=1,}$  the ${\displaystyle x}$-axis ${\displaystyle (y=0)}$  and the curve ${\displaystyle y=x^{2}.}$  In order to find this area, we can begin with a familiar geometric object: the rectangle. In this case, we wish to find an area above the interval from ${\displaystyle 0}$ to ${\displaystyle 1}$. In order to approximate this, we can divide the interval into, say ${\displaystyle 4}$ shorter intervals of equal length. Let's call this length ${\displaystyle \Delta x}$, and since they are all the same length, we know that the length of each will be ${\displaystyle 1/4.}$

However, in order to define an area, our rectangles require a height as well as a width. Most often, calculus teachers will use the function's value at the left or right endpoint for the height of each rectangle, although we could also choose the minimum or maximum value of ${\displaystyle f(x)}$ on each interval, or perhaps the value at the midpoint of each interval.

Let's approximate this area first using left endpoints. Notice that our leftmost interval is ${\displaystyle [0,1/4],}$ so the height at the left endpoint is ${\displaystyle f(0)=0.}$ This means the area of our leftmost rectangle is

${\displaystyle f(0)\cdot \Delta x\,=\,0\cdot \left({\displaystyle {\frac {1}{4}}}\right)\,=\,0.}$

Continuing, the adjacent interval is ${\displaystyle [1/4,1/2].}$ Now, our left endpoint is ${\displaystyle 1/4}$, and our area is

${\displaystyle {\displaystyle f\left({\frac {1}{4}}\right)\cdot \Delta x\,=\,{\frac {1}{16}}\cdot {\frac {1}{4}}\,=\,{\frac {1}{64}}}.}$

The next interval to the right is ${\displaystyle [1/2,3/4],}$ and as such the left endpoint is ${\displaystyle 1/2,}$ so the area is

${\displaystyle {\displaystyle f\left({\frac {1}{2}}\right)\cdot \Delta x\,=\,{\frac {1}{4}}\cdot {\frac {1}{4}}\,=\,{\frac {1}{16}}.}}$

Finally, we have the rightmost rectangle, whose base is the interval ${\displaystyle [3/4,1].}$ This has ${\displaystyle 3/4}$ as its left endpoint, so its area is

${\displaystyle {\displaystyle f\left({\frac {3}{4}}\right)\cdot \Delta x\,=\,{\frac {9}{16}}\cdot {\frac {1}{4}}\,=\,{\frac {9}{64}}.}}$

Adding these four rectangles up with sigma ${\displaystyle (\Sigma )}$  notation, we can approximate the area under the curve as

${\displaystyle {\begin{array}{rcl}S&=&{\displaystyle \sum _{i=1}^{4}f\left(x_{i}\right)\cdot \Delta x}\\\\&=&{\displaystyle 0+{\frac {1}{64}}+{\frac {1}{16}}+{\frac {9}{64}}}\\\\&=&{\displaystyle {\frac {14}{64}}}\\\\&=&{\displaystyle {\frac {7}{32}}.}\end{array}}}$

Of course, we could also use right endpoints. In this case, we would use the endpoints ${\displaystyle 1/4,\,1/2,\,3/4}$ and ${\displaystyle 1}$ for the height above each interval from left to right to find

${\displaystyle {\begin{array}{rcl}S&=&{\displaystyle \sum _{i=1}^{4}f\left(x_{i}\right)\cdot \Delta x}\\\\&=&{\displaystyle f\left({\frac {1}{4}}\right)\cdot \Delta x+{\displaystyle f\left({\frac {1}{2}}\right)\cdot \Delta x+}{\displaystyle f\left({\frac {3}{4}}\right)\cdot \Delta x+}{\displaystyle f\left(1\right)\cdot \Delta x}}\\\\&=&{\displaystyle {\frac {1}{16}}\cdot {\frac {1}{4}}+{\frac {1}{4}}\cdot {\frac {1}{4}}+{\frac {9}{16}}\cdot {\frac {1}{4}}+1\cdot {\frac {1}{4}}}\\\\&=&{\displaystyle {\frac {1}{64}}+{\frac {1}{16}}+{\frac {9}{64}}+{\frac {1}{4}}}\\\\&=&{\displaystyle {\frac {15}{32}}}.\end{array}}}$

Note that in this case, one is an overestimate and one is an underestimate. This approximation through the area of rectangles is known as a Riemann sum.

## Additional Examples with Fixed Numbers of Rectangles

Example 1. Approximate the area under the curve of ${\displaystyle f(x)=x^{3}-x}$ from  ${\displaystyle -1}$ to ${\displaystyle 3}$  using ${\displaystyle n=4}$ rectangles and left endpoints.

Solution. Note that our ${\displaystyle x}$-values range from ${\displaystyle -1}$ to ${\displaystyle 3}$, so our length is actually ${\displaystyle 3-(-1)=4.}$ Thus each rectangle will have a base of

${\displaystyle \Delta x\,=\,{\displaystyle {\frac {b-a}{n}}\,=\,{\frac {3-(-1)}{4}}\,=\,{\frac {4}{4}}\,=\,1.}}$

This is our first step. This means our intervals from left to right are ${\displaystyle [-1,0],\,[0,1],\,[1,2]}$ and ${\displaystyle [2,3].}$ Choosing left endpoints, we have

${\displaystyle {\begin{array}{rcl}S&=&{\displaystyle \sum _{i=1}^{4}f(x_{i})\cdot \Delta x}\\\\&=&f(-1)\cdot 1+f(0)\cdot 1+f(1)\cdot 1+f(2)\cdot 1\\\\&=&-2+0+0+6\\\\&=&4.\end{array}}}$

Here is where the idea of "area under the curve" becomes clearer. We actually have a signed area, where area below the ${\displaystyle x}$-axis is negative, while area above the ${\displaystyle x}$-axis is positive.

Example 2. Approximate the area under the curve of ${\displaystyle f(x)=x^{3}-x}$ from ${\displaystyle -4}$ to ${\displaystyle 4}$ using ${\displaystyle n=4}$ rectangles and midpoints.

Solution. Here, our ${\displaystyle x}$-values range from ${\displaystyle -4}$  to ${\displaystyle 4,}$ so

${\displaystyle \Delta x\,=\,{\displaystyle {\frac {b-a}{n}}\,=\,{\frac {4-(-4)}{4}}\,=\,{\frac {8}{4}}\,=\,2.}}$

As a result, our intervals from left to right are ${\displaystyle [-4,-2],\,[-2,0],\,[0,2]}$ and  ${\displaystyle [2,4].}$ More importantly, our midpoints occur at ${\displaystyle -3,\,-1,\,1}$ and ${\displaystyle 3}$ respectively; this is where we will evaluate the height of each rectangle. Thus

${\displaystyle {\begin{array}{rcl}S&=&{\displaystyle \sum _{i=1}^{4}f(x_{i})\cdot \Delta x}\\\\&=&f(-3)\cdot 2+f(-1)\cdot 2+f(1)\cdot 2+f(3)\cdot 2\\\\&=&(-24)\cdot 2+0\cdot 2+0\cdot 2+24\cdot 2\\\\&=&0.\end{array}}}$

## Defining the Integral as a Limit

Although associating the area under the curve with four rectangles gives us a really rough approximation, there's no reason we can't continue to divide (partition) the interval into smaller pieces, and then get closer to the actual area. The graphic on the right shows precisely the idea. We can keep making the base of each rectangle, or ${\displaystyle \Delta x,}$ smaller and smaller, and we'll get a better approximation. More importantly, we can continue this idea as a limit, leading to the following definition.

Definition. We define the Definite Integral of ${\displaystyle f(x)}$ on ${\displaystyle [a,b],}$  written

${\displaystyle {\displaystyle \int _{a}^{b}f(x)\,dx},}$

to be

${\displaystyle {\displaystyle \int _{a}^{b}f(x)\,dx\,=\,\lim _{n\rightarrow \infty }\sum _{i=1}^{n}f(x_{i})\cdot \Delta x_{i}.}}$

For an introductory course, we usually have ${\displaystyle \Delta x_{i}=\Delta x={\displaystyle {\frac {b-a}{n}},}}$  so each rectangle has exactly the same base.

## Using the Definition to Evaluate a Definite Integral

Frequently, students will be asked questions such as: Using the definition of the definite integral, find the area under the curve of the function ${\displaystyle f(x)=x^{2}}$ on the interval ${\displaystyle [0,3]}$ using right endpoints.

Rather than using "easier" rules, such as the power rule and the Fundamental Theorem of Calculus, this requires us to use the the definition just listed. The first step is to set up our sum. We have ${\displaystyle a=0,\,b=3}$  and ${\displaystyle n}$ is just an arbitrary natural (or counting) number. This tells us that

${\displaystyle \Delta x\,=\,{\displaystyle {\frac {b-a}{n}}\,=\,{\frac {3-0}{n}}\,=\,{\frac {3}{n}}}.}$

For a given ${\displaystyle n}$, our leftmost interval would start at ${\displaystyle 0,}$ and be of length ${\displaystyle \Delta x=3/n.}$ This describes the interval ${\displaystyle [0,3/n].}$ On the other hand, our next interval would start where the leftmost stopped, or ${\displaystyle 3/n}$, and it's length would also be ${\displaystyle \Delta x=3/n.}$ This is the interval

${\displaystyle {\displaystyle \left[{\frac {3}{n}},{\frac {3}{n}}+{\frac {3}{n}}\right]\,=\,\left[1\cdot {\frac {3}{n}},2\cdot {\frac {3}{n}}\right].}}$

If we call the leftmost interval ${\displaystyle I_{1},}$ then we would have ${\displaystyle I_{1}={\displaystyle \left[0\cdot {\frac {3}{n}},1\cdot {\frac {3}{n}}\right]}.}$ Similarly, our second interval would be ${\displaystyle I_{2}={\displaystyle \left[1\cdot {\frac {3}{n}},2\cdot {\frac {3}{n}}\right]}.}$ If we were to continue this rule, we would have that for any ${\displaystyle i=1,2,\ldots ,n,}$ we could write ${\displaystyle I_{i}={\displaystyle \left[(i-1)\cdot {\frac {3}{n}},i\cdot {\frac {3}{n}}\right]}.}$ This allows us to determine where to choose our height for each interval. Since we are asked to use right endpoints, we would want ${\displaystyle f\left({\displaystyle 1\cdot {\frac {3}{n}}}\right)}$ for ${\displaystyle I_{1},}$ ${\displaystyle f\left({\displaystyle 2\cdot {\frac {3}{n}}}\right)}$ for ${\displaystyle I_{2},}$ and finally ${\displaystyle f\left({\displaystyle i\cdot {\frac {3}{n}}}\right)}$ for ${\displaystyle I_{i}.}$

This allows us to build the sum. For an arbitrary ${\displaystyle n,}$ we would have

${\displaystyle {\displaystyle \sum _{i=1}^{n}f(x_{i})\cdot \Delta x_{i}\,=\,\sum _{i=1}^{n}f\left({\frac {3i}{n}}\right)\cdot \Delta x\,=\,\sum _{i=1}^{n}{\frac {9i^{2}}{n^{2}}}\cdot {\frac {3}{n}}\,=\,\sum _{i=1}^{n}{\frac {27i^{2}}{n^{3}}}.}}$

Using this result, we now have

${\displaystyle {\displaystyle \int _{a}^{b}f(x)\,dx\,=\,\lim _{n\rightarrow \infty }\sum _{i=1}^{n}f(x_{i})\cdot \Delta x_{i}\,=\,\lim _{n\rightarrow \infty }\sum _{i=1}^{n}{\frac {27i^{2}}{n^{3}}}.}}$

Now, we have several important sums explained on another page. These are the sum of the first ${\displaystyle n}$ numbers, the sum of the first ${\displaystyle n}$ squares, and the sum of the first ${\displaystyle n}$ cubes:

${\displaystyle {\displaystyle \sum _{i=1}^{n}i\,=\,{\frac {n(n+1)}{2}};\qquad \sum _{i=1}^{n}i^{2}\,=\,{\frac {n(n+1)(2n+1)}{6}};\qquad \sum _{i=1}^{n}i^{3}\,=\,{\frac {n^{2}(n+1)^{2}}{4}}.}}$

Moreover, we have some basic rules for summation. These rules that make sense in simpler notation, such as

${\displaystyle ca_{1}+ca_{2}=c(a_{1}+a_{2})}$ or ${\displaystyle (a_{1}+b_{1})+(a_{2}+b_{2})=(a_{1}+a_{2})+(b_{1}+b_{2})}$

work the same way in Sigma notation, meaning

${\displaystyle {\displaystyle \sum _{i=1}^{n}ca_{i}\,=\,ca_{1}+ca_{2}+\cdots +ca_{n}\,=\,c(a_{1}+\cdots +a_{n})\,=\,c\sum _{i=1}^{n}a_{i},}\qquad \qquad (\dagger )}$

and

${\displaystyle {\displaystyle \sum _{i=1}^{n}(a_{i}+b_{i})\,=\,a_{1}+b_{1}+a_{2}+b_{2}\cdots a_{n}+b_{n}\,=\,a_{1}+a_{2}+\cdots +a_{n}+b_{1}+b_{2}+\cdots +b_{n}\,=\,\sum _{i=1}^{n}a_{i}+\sum _{i=1}^{n}b_{i}.\qquad \qquad (\dagger \dagger )}}$

Before worrying about the limit as ${\displaystyle n\rightarrow \infty }$, when we write ${\displaystyle {\displaystyle \sum _{i=1}^{n}{\frac {27i^{2}}{n^{3}}},}}$ both ${\displaystyle 27}$ and the ${\displaystyle n^{3}}$ in the denominator are just constants, like the ${\displaystyle c}$ in ${\displaystyle (\dagger ).}$ As a result we have

${\displaystyle {\displaystyle \sum _{i=1}^{n}{\frac {27i^{2}}{n^{3}}}\,=\,{\frac {27}{n^{3}}}\sum _{i=1}^{n}i^{2}\,=\,{\frac {27}{n^{3}}}\cdot {\frac {n(n+1)(2n+1)}{6}}\,=\,{\frac {9n(n+1)(2n+1)}{2n^{3}}},}}$

where we applied the rule for the first ${\displaystyle n}$ squares. Finally, we can look at this as being approximately ${\displaystyle 18n^{3}/2n^{3}}$  for large ${\displaystyle n,}$ so the limit as ${\displaystyle n\rightarrow \infty }$  is ${\displaystyle 9.}$ Thus

${\displaystyle {\displaystyle \int _{0}^{3}x^{2}\,dx=9.}}$

## A Left Point of View

What would change if we approached the above integral through left endpoints, instead of right? We would only be changing our value for ${\displaystyle f(x_{i}).}$ For example, the leftmost interval is  ${\displaystyle {\displaystyle \left[0\cdot {\frac {3}{n}},1\cdot {\frac {3}{n}}\right],}}$ so our left endpoint is ${\displaystyle 0.}$ On the other hand, our second interval is  ${\displaystyle {\displaystyle \left[1\cdot {\frac {3}{n}},2\cdot {\frac {3}{n}}\right],}}$ so our left endpoint is ${\displaystyle 3/n.}$ For the interval ${\displaystyle I_{1}={\displaystyle \left[(i-1)\cdot {\frac {3}{n}},i\cdot {\frac {3}{n}}\right],}}$ our left endpoint is ${\displaystyle 3(i-1)/n.}$ Let's apply the same process as the last section to this value. for height. We then have

${\displaystyle {\begin{array}{rcl}{\displaystyle \int _{0}^{3}x^{2}\,dx}&=&{\displaystyle \lim _{n\rightarrow \infty }\,\sum _{i=1}^{n}f(x_{i})\cdot \Delta x_{i}}\\\\&=&{\displaystyle \lim _{n\rightarrow \infty }\,\sum _{i=1}^{n}\left({\frac {3(i-1)}{n}}\right)^{2}\cdot {\frac {3}{n}}}\\\\&=&{\displaystyle \lim _{n\rightarrow \infty }\,\sum _{i=1}^{n}{\frac {9(i-1)}{n^{2}}}^{2}\cdot {\frac {3}{n}}}\\\\&=&{\displaystyle \lim _{n\rightarrow \infty }\,\sum _{i=1}^{n}{\frac {27(i-1)}{n^{3}}}^{2}}\\\\&=&{\displaystyle \lim _{n\rightarrow \infty }\,{\frac {27}{n^{3}}}\sum _{i=1}^{n}(i^{2}-2i+1).}\end{array}}}$

From here, we use the special sums again. This means that

${\displaystyle {\begin{array}{rcl}{\displaystyle \lim _{n\rightarrow \infty }\,{\frac {27}{n^{3}}}\sum _{i=1}^{n}(i^{2}-2i+1)}&=&{\displaystyle \lim _{n\rightarrow \infty }\,{\frac {27}{n^{3}}}\left({\frac {n(n+1)(2n+1)}{6}}+{\frac {n(n+1)}{2}}+n\right)}\\\\&=&{\displaystyle \lim _{n\rightarrow \infty }\,\left({\frac {9n(n+1)(2n+1)}{2n^{3}}}+{\frac {27n(n+1)}{2n^{3}}}+{\frac {27}{n^{2}}}\right)}\\\\&=&{\displaystyle \lim _{n\rightarrow \infty }\,\left({\frac {18n^{3}}{2n^{3}}}+{\frac {27n^{2}}{2n^{3}}}+{\frac {27}{n^{2}}}\right)\qquad \qquad ({\textrm {for~large~}}n)}\\\\&=&9+0+0\\\\&=&9.\end{array}}}$

Thus our choice of endpoints makes no difference in the resulting value.

## A More Advanced Example

For most Riemann Sum problems in an integral calculus class, ${\displaystyle \Delta x}$ will always be the same width, and we will need to use the special sums to evaluate the limit. However, what can we do if we wish to determine the value of

${\displaystyle \int _{0}^{1}{\sqrt {x}}\,dx?}$

Using rectangles of the same width as shown in the earlier animation would result in a very messy sum which contains a lot of square roots! This makes finding the limit nearly impossible. Instead, we could consider the inverse function to the square root, which is squaring. Instead of choosing ${\displaystyle \Delta x=(b-a)/n=1/n,}$ let's consider ${\displaystyle x_{0}=0,}$ and let

${\displaystyle x_{i}\,=\,{\displaystyle {\frac {i^{2}}{n^{2}}}.}}$

For example, ${\displaystyle x_{1}=1/n^{2}}$ while ${\displaystyle x_{2}=4/n^{2}.}$ In particular, since we indexed the leftmost point as ${\displaystyle x_{0}=0,}$ this means that

${\displaystyle {\displaystyle \Delta x_{i}\,=\,x_{i}-x_{i-1}\,=\,{\frac {i^{2}}{n^{2}}}-{\frac {(i-1)^{2}}{n^{2}}}\,=\,{\frac {2i-1}{n^{2}}}.}}$

Each ${\displaystyle \Delta x_{i}}$ will be a different width, but either endpoint would be a square, so taking ${\displaystyle f(x_{i})}$ will not leave a square root in our sum.

Now we have all the pieces. Let's use right endpoints for the height of each rectangle, so ${\displaystyle f(x_{i})={\displaystyle {\sqrt {\frac {i^{2}}{n^{2}}}}={\frac {i}{n}}.}}$ Then

${\displaystyle {\begin{array}{rcl}{\displaystyle \int _{0}^{1}{\sqrt {x}}\,dx}&=&{\displaystyle \lim _{n\rightarrow \infty }\,\sum _{i=1}^{n}f(x_{i})\cdot \Delta x_{i}}\\\\&=&{\displaystyle \lim _{n\rightarrow \infty }\sum _{i=1}^{n}{\frac {i}{n}}\cdot {\frac {2i-1}{n^{2}}}}\\\\&=&{\displaystyle \lim _{n\rightarrow \infty }\sum _{i=1}^{n}{\frac {2i^{2}-i}{n^{3}}}}\\\\&=&{\displaystyle \lim _{n\rightarrow \infty }{\frac {1}{n^{3}}}\left(2\cdot {\frac {n(n+1)(2n+1)}{6}}-{\frac {n(n+1)}{2}}\right)}\\\\&=&{\displaystyle \lim _{n\rightarrow \infty }\left({\frac {2n(n+1)(2n+1)}{6n^{3}}}-{\frac {n(n+1)}{2n^{3}}}\right)}\\\\&=&{\displaystyle \lim _{n\rightarrow \infty }\,\left({\frac {4n^{3}}{6n^{3}}}+{\frac {n^{2}}{2n^{3}}}\right)\qquad \qquad ({\textrm {for~large~}}n)}\\\\&=&{\displaystyle {\frac {2}{3}}+0}\\\\&=&{\displaystyle {\frac {2}{3}}.}\end{array}}}$

You will NEVER see something like this in a first year calculus class, but it is just a reminder that the definition includes the indexed ${\displaystyle \Delta x_{i}}$ for a reason; the rectangles don't need to be all of the same width!