Module 9 : Intergral Calculus

901 : The Definition of anIntegral

O B J E C T I V E

In the project, we will learn about areas under curves, how Riemann sums converge to the area, how the choice of left, right, or midpoint of the subintervals has no ultimate effect, and then we will go through a four step procedure to set up Riemann sums on our own.

S E T U P

In this project we will use the following command packages. Type and execute this line before begining the project below. If you re-enter the worksheet for this project, be sure to re-execute this statement before jumping to any point in the worksheet.

> restart; with(plots): with(student):

Warning, the name changecoords has been redefined

__________________________________________________________________________________

A. Positive & Negative Area

__________________________________________________________________________________

First well look at the concept of area under a curve and see how it can be both positive and negative. To investigate this idea we will use the special plot procedure below. Type it in precisely as you see it a single comand plot. To create additiional lines without executing hit return (macintosh) or shift return (windows). When you're done, enter the comamand.

> area_plot := proc(f1,a,b)
local box,i,n,x1,x2,y1,y2,A,delta:
n:= 200; delta := (b-a)/n; x2 := a;
for i from 1 to n do
x1 := evalf(x2); y1 := evalf(f(x1));
x2 := evalf(a + i*delta); y2 := evalf(f(x2));
if( y1 > 0 )
then A||i :=polygonplot( [[x1,0],[x1,y1],[x2,y2],[x2,0]],color=coral,style=patchnogrid);
else A||i:=polygonplot( [[x1,0],[x1,y1],[x2,y2],[x2,0]],color=red, style=patchnogrid);
fi; od;
display([plot(f1(x), x = a..b, color=blue,thickness=2,discont=true), seq(A||i,i=1..n)]);
end:

To use this new function, define a function, and the left and right end points of an interval. In this case, we will view the area between x = 1 and x = 3. The area is measured between the x-axis and the graph of the function.

> f := x -> 1 + x/2 + (x/3)*sin(x^2); a := 1; b := 3;

f := proc (x) options operator, arrow; 1+1/2*x+1/3*...

a := 1

b := 3

> area_plot( f(x), a,b );

[Maple Plot]

Area can be both positive and negative. Area positive when y values are positive, and negative when y is negative.

> area_plot( x^2 + 3, -2, 2);
area_plot( -(x^2 + 3), -2, 2);

[Maple Plot]

[Maple Plot]

In many cases, there are regions where the curve weaves above and below the x axis. The regions above lead to positive areas, and the regions below make negative areas.

> f := x-> 10 + 6*x - x^2; a := -3; b := 9; area_plot( f(x), a,b );

f := proc (x) options operator, arrow; 10+6*x-x^2 e...

a := -3

b := 9

[Maple Plot]

__________________________________________________________________________________

B. Integrable Functions

__________________________________________________________________________________

Although a function needs to be both continuous and smooth to be differentiable, the area can still be clearly defined even for functions which are neither smooth nor continuous. Such functions are termed integrable for reasons which will be clear in the near future.


Area also applies to discontinuous, piecewise defined functions, and functions which are not differentiable everywhere.

> f:= x -> piecewise( x < 2, -1, x<6, 2-x/2, x < 8, .5*x^2 - 6*x + 18, 1);

f := proc (x) options operator, arrow; piecewise(x ...

> a:=0; b := 10; area_plot( f(x), a, b );

a := 0

b := 10

[Maple Plot]

> f := x-> sqrt( abs(x^2 - 9 )) - 2;
a := -5; b := 5; area_plot( f(x), a, b );

f := proc (x) options operator, arrow; sqrt(abs(x^2...

a := -5

b := 5

[Maple Plot]

__________________________________________________________________________________

C. Riemann Sums & Convergence

__________________________________________________________________________________

Now well examine a scheme to compute the area under curves. The idea is to divide the interval on the x axis into n small but equal pieces, and then draw a rectangle that approximates the area in each subinterval. The sum of all of the areas of the boxes approximates the area under the curve for this interval. As n gets larger, the approximation to the area gets better and better.

BOXES AND AREA

> f:= x -> x^3 -19*x^2 +99*x - 20; a := 1; b := 13; n := 10;

f := proc (x) options operator, arrow; x^3-19*x^2+9...

a := 1

b := 13

n := 10

> rightsum( f(x), x = a..b, n): Area := evalf(%,20);

Area := 1428.9600000000000000

> rightbox( f(x), x = a..b, n, title= convert( evalf(Area,10), string) );

[Maple Plot]

You can see 10 rectangles along with the graph of f(x). The area computation is the total area of the 10 rectangles. This number is a rough approximation to the area under the curve.

CONVERGENCE

We can carry this idea a bit further and look at increasing values of n and see how the area changes.

> for k from 1 to 25 do
print(cat(`Area for n=`,200*k), evalf(rightsum( f(x), x = a..b,200*k), 20)) ; od;

`Area for n=200`, 1313.7744000000000000

`Area for n=400`, 1310.8836000000000000

`Area for n=600`, 1309.9216000000000000

`Area for n=800`, 1309.4409000000000000

`Area for n=1000`, 1309.1525760000000000

`Area for n=1200`, 1308.9604000000000000

`Area for n=1400`, 1308.8231510204081632

`Area for n=1600`, 1308.7202250000000000

`Area for n=1800`, 1308.6401777777777778

`Area for n=2000`, 1308.5761440000000000

`Area for n=2200`, 1308.5237553719008264

`Area for n=2400`, 1308.4801000000000000

`Area for n=2600`, 1308.4431621301775148

`Area for n=2800`, 1308.4115020408163265

`Area for n=3000`, 1308.3840640000000000

`Area for n=3200`, 1308.3600562500000000

`Area for n=3400`, 1308.3388733564013841

`Area for n=3600`, 1308.3200444444444444

`Area for n=3800`, 1308.3031977839335180

`Area for n=4000`, 1308.2880360000000000

`Area for n=4200`, 1308.2743183673469388

`Area for n=4400`, 1308.2618479338842975

`Area for n=4600`, 1308.2504620037807184

`Area for n=4800`, 1308.2400250000000000

`Area for n=5000`, 1308.2304230400000000

In this way, we can see that the area seems to be converging as n increased from 200 to 5,000.

You can get an even better idea of how areas of the boxes converge to the area under the curve if we choose a sequence of values for n which is increasing geometrically. However, this process requires a fast computer. Depending on the speed of your computer, may wish to increase or decrease the value of 12 below.

> for k from 1 to 12 do
print(cat(`Area for n=`,100*2^k), evalf(rightsum(f(x), x = a..b,100*2^k),20)) ;od;

`Area for n=200`, 1313.7744000000000000

`Area for n=400`, 1310.8836000000000000

`Area for n=800`, 1309.4409000000000000

`Area for n=1600`, 1308.7202250000000000

`Area for n=3200`, 1308.3600562500000000

`Area for n=6400`, 1308.1800140625000000

`Area for n=12800`, 1308.0900035156250000

`Area for n=25600`, 1308.0450008789062500

`Area for n=51200`, 1308.0225002197265625

`Area for n=102400`, 1308.0112500549316406

`Area for n=204800`, 1308.0056250137329102

`Area for n=409600`, 1308.0028125034332275

Note that the areas appear to converge much quicker to more or less a common value. You can also see that the differences between the numbers are decreasing toward zero.

______________________________________________________________________

D. Left, Right, & Middle

__________________________________________________________________________________

When we drew boxes above, we computed the height of the small rectangles by evaluating f(x) at the right endpoint of each subinterval. This is not the only way of doing it. Just as easily, we could have evaluated f(x) at the left endpoint or the midpoint of each subinterval. Lets look at how these other methods appear different and give different results.

Carefully scrutinize the three plots. Look at the graph and where each small rectangle meet. Youll see that this is different in each of the three plots.

> f:= x -> x^3 -19*x^2 +99*x - 20;

f := proc (x) options operator, arrow; x^3-19*x^2+9...

> a := 1; b := 13;

a := 1

b := 13

> leftbox( f(x), x = 1..13, 20);

[Maple Plot]

> rightbox( f(x), x = 1..13, 20);

[Maple Plot]

> middlebox( f(x), x = 1..13, 20);

[Maple Plot]

We saw above that when you draw the boxes based on left or right endpoint evaluation, both the display and resulting approximation to the area are different. Ultimately, does the method of computing the height of boxes make a difference? Lets examine the left and right areas and the difference between them, numerically, as n goes from 200 to 3,000.

> f:= x -> x^3 -19*x^2 +99*x - 20; a := 1; b := 13;

f := proc (x) options operator, arrow; x^3-19*x^2+9...

a := 1

b := 13

> array( [ seq( [ 200*k,evalf(leftsum(f(x), x = a..b,200*k),8),
evalf(rightsum(f(x), x = a..b,200*k),8),
evalf(rightsum(f(x), x = a..b,200*k)-leftsum(f(x),x = a..b,
200*k),8) ], k = 1..15)]);

matrix([[200, 1302.2544, 1313.7744, 11.5200], [400,...

The four columns of numbers are n, the left sum, the right sum, and their difference. Although the left and right areas are not the same, the appear to be converging to the same value. Also, please note, that the differences between the two are approaching zero.

How do the left, middle, and right sums compare?

> array( [ seq( [ 200*k, evalf(leftsum(f(x), x = a..b,200*k),8),
evalf(middlesum(f(x), x = a..b,200*k),8),
evalf(rightsum(f(x), x = a..b,200*k),8)], k = 1..15)]);

matrix([[200, 1302.2544, 1307.9928, 1313.7744], [40...

The four columns are n, the left sum, the middle sum, and the right sum. Again, all of the values are different, but they all seem to be converging to the same value.

______________________________________________________________________

E. Creating Riemann Sums

__________________________________________________________________________________

Maple has the useful functions we've seen above : rightsum, rightbox, leftsum, leftbox, and middlesum, middlebox which display Riemann boxes and Riemann sums automatically. However, its important for us to know how to set these up for ourselves. We are going to follow 4 steps to create Riemann sums :
How to Create a Riemann Sum
1. Compute Delta x, the width of each subinterval using an indefinite n
2. Compute xk, the partition of the interval
3. Set up and simplify the Riemann sum (using right end point evaluation)
4. Take the limit as n approaches infinity.

Well start with the same example we used above.

> restart;

> f := x -> x^3 - 10*x^2 + 20*x + 10; a:=-3; b :=5 ;

f := proc (x) options operator, arrow; x^3-10*x^2+2...

a := -3

b := 5

Here are the four steps.

1. Compute Delta x
2. Compute the partition xk
3. Set up and simplify the Riemann sum
4. Take the limit as n approaches infinity.

> Delta := (b-a)/n;

Delta := 8*1/n

> x[k] := a + k*Delta;

x[k] := -3+8*k/n

> Sum( f(x[k])*Delta, k=1..n):
% = simplify(value(%));

Sum(8*((-3+8*k/n)^3-10*(-3+8*k/n)^2-50+160*k/n)/n,k...

> Limit(%%,n = infinity): %= evalf(value(%));

Limit(Sum(8*((-3+8*k/n)^3-10*(-3+8*k/n)^2-50+160*k/...

>