This material was developed by Aaron Tresham at the University of Hawaii at Hilo and is

licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

- Intro to Sage

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 ).

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.

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.

385

137/60

For , .

3829036719783221149071997/280346265322438720204800
13.6582405168811

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 .

The left Riemann sum is 2.32000000000000
The right Riemann sum is 3.12000000000000

Now .

The left Riemann sum is 2.48000000000000
The right Riemann sum is 2.88000000000000

Finally, .

The left Riemann sum is 2.62720000000000
The right Riemann sum is 2.70720000000000

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.

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 .

The left Riemann sum is 0.984209788675773
The right Riemann sum is 1.01562571521167

Here are graphs for the left and right Riemann sums with :

Now we'll use .

The left Riemann sum is 0.992125456605633
The right Riemann sum is 1.00783341987358

Here are the graphs for .