Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
License: OTHER
Image: ubuntu2004

licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Prerequisites:
Intro to Sage
Riemann Sums and Area Under a Curve
Suppose we want to know the area between the graph of a positive function and the x-axis from to .
For most functions, this region is not a shape whose area we can find simply using geometry. So we will approximate the area using a simple geometric shape: the rectangle. Now using only one rectangle would give us a pretty poor approximation most of the time, so we should use many rectangles. Here is the approach:
Divide the interval into subintervals of equal width (this assumption is unnecessary, but it will simplify things).
We'll call this width . Since all the widths are the same, we have .
We'll label the endpoints of the intervals : , , , , .
If each subinterval is relatively small, then the function values on this subinterval are all approximately the same (i.e., for any and in the subinterval).
Choose any in the subinterval .
The area under the graph of on this subinterval is approximately (this is the area of the rectangle with one side along the x-axis from to and two vertical sides from the x-axis up to ).
To get the total area under the graph of on the interval , we add up all our approximations:
This is called a Riemann Sum, after German mathematician Bernhard Riemann (1826-1866).
If is chosen to be the left endpoint of each subinterval, then the resulting Riemann sum is called a Left Riemann Sum (I'll abbreviate it ).
(note that depends on ).
If is chosen to be the right endpoint of each subinterval, then the resulting Riemann sum is called a Right Riemann Sum (I'll abbreviate it ).
(note that depends on ).
Example 1
Here are pictures of the rectangles that make up the left and right Riemann sums for the function from to with subintervals.
The animation below shows graphs of left Riemann sums for increasing values of . You can see that the rectangles begin to fill in the area under the curve.
Definite Integrals
To get a better approximation, we make the subintervals smaller by increasing (the number of subintervals).
We then define the area as
(provided this limit exists).
It can be shown (although I won't do it) that this limit exists for many functions (and it does not depend on the choice of ). In particular, this limit exists if the function is continuous on the interval .
I have assumed that the function is positive on the interval . If this is not the case, then some may be negative, in which case would not be the area of the corresponding rectangle, but the opposite of this area (a negative number).
In calculus, we will decree that regions below the x-axis have negative area, while regions above the x-axis have positive area. Therefore, the area formula given above will still work, provided we think not of the geometric area of the region but of the "signed area."
Because of its importance, there is special notation for the limit of Riemann sums given above:
This quantity is called the Definite Integral of the function from to .
In this lab, we will compute values of Riemann sums using the "sum" command in Sage. Next time we will compute integrals using the "integral" command.
The sum command takes four arguments: sum(expression, variable of summation, starting value, ending value)
Make sure you declare your summation variable before using it.
Here some examples.
For , .
Example 2
Approximate the area between the graph of and the x-axis from to using left and right Riemann sums with , , and subintervals.
First, the solution with .
Now .
Finally, .
You can see that the left and right Riemann sums get closer together as increases (they are both getting closer to the actual area).
The actual area is . This gives you some idea of how big needs to be in order to get a good approximation.
Fortunately, there are much better ways to approximate areas! We'll talk about some of these in Math 206.
Example 3
Approximate the area between the graph of and the x-axis from to using left and right Riemann sums with and subintervals.
[Note: The actual area is .]
First, we'll use .
Here are graphs for the left and right Riemann sums with :
Now we'll use .
Here are the graphs for .