Lab09: Riemann Sums

0. Objective:

The object of this project is to find the area under the curve of a positive function on an interval [a,b].  In order to construct the appropriate rectangles, we will divide this interval into n equal parts each of which will serve as the base for one of the individual rectangles.

As in class we will use the following:  Δx = ((b-a)/n), (Subscript[x, k])=a+k×Δx, for k = 0, 1, 2, ..., n.  Here Δx is the width of the rectangles and f((SuperStar[(Subscript[x, k])])) is the height of the rectangles where (SuperStar[(Subscript[x, k])]) depends on the method used.

1. Examples:

First lets look at estimating the area under the curve, f(x)=(x^2), on the interval [1, 2].  We define the function:

f[x_]=x^2;

and generate the partition points, called xx here, for the case of n = 4:

n=4;
dx=(2-1)/n;
xx=Table[1+k*dx,{k,0,n}]

We can graph the function and the rectangles using the Right-Hand-Method:

plot1=Plot[f[x],{x,.5,2.5},PlotRange->{-1,6}];

plot2=Graphics[Table[{EdgeForm[Dashed],Gray,Opacity[.5],Rectangle[{xx[[k]],0},{xx[[k+1]],f[xx[[k+1]]]}]},{k,1,n}]];

Show[plot1,plot2]

The sum of the area of the rectangles would be:

rhm4=Sum[f[xx[[k+1]]],{k,1,n}]*dx

N[rhm4,15]

To graph the rectangles for the Left-Hand-Method:

plot3=Graphics[Table[{EdgeForm[Dashed],Gray,Opacity[.5],Rectangle[{xx[[k]],f[xx[[k]]]},{xx[[k+1]],0}]},{k,1,n}]];

Show[plot1,plot3]

and the sum of areas of these rectangles would be

lhm4=Sum[f[xx[[k]]],{k,1,n}]*dx

N[lhm4,15]

For the Midpoint-Method:

plot4=Graphics[Table[{EdgeForm[Dashed],Gray,Opacity[.5],Rectangle[{xx[[k]],f[(xx[[k]]+xx[[k+1]])/2]},{xx[[k+1]],0}]},{k,1,n}]];

Show[plot1,plot4]

with a sum of

mm4=Sum[f[(xx[[k]]+xx[[k+1]])/2],{k,1,n}]*dx

N[mm4,15]

Task

1. If f(x)=(1/(1+sin(x))), on the interval [0,(π/2)], find the following:

a. The left, right, and midpoint sums using n = 10, 30, 50, and 100 subintervals.  Note: to see a difference you may want to display at least 18 decimal digits.

({{□, Left, Right, Midpoint}, {10, □, □, □}, {30, □, □, □}, {50, □, □, □}, {100, □, □, □}})

b.  What happens to the values of the sums in part a as n increases?

c.  Estimate the value of the sums as n → ∞.

2.  If f(x)=ln(x+1), on the interval [0, 3], answer the same questions as above:

a. The left, right, and midpoint sums using n = 10, 30, 50, and 100 subintervals.

({{□, Left, Right, Midpoint}, {10, □, □, □}, {30, □, □, □}, {50, □, □, □}, {100, □, □, □}})

b.  What happens to the values of the sums in part a as n increases?

c.  Estimate the value of the sums as n → ∞.