MATH 021 Z1 Lab 2

Riemann Sums and Integrals

Initialization

Evaluate the following initialization cell with Shift-Enter before you begin. (It will evaluate automatically if you answer Yes at the prompt.)

err="Interval is backwards. Fix it and try again.";
getlines[f_,{x_,a_,b_},n_,loc_]:=Module[{dx},dx=(b-a)/n;
	Table[Line[{{a + i*dx, 0},{a + i*dx, f/.{x->a + (i+loc)*dx}},
     {a + (i+1)*dx, f/.{x->a + (i+loc)*dx}},
     {a + (i+1)*dx, 0}}], {i, 0, n - 1}]];

PlotLeftRec[f_,{x_,a_, b_}, n_] :=If[a>b,Print[err],Show[Plot[f, {x, a, b},
     PlotRange->{{Min[0,a],Max[0,b]},All}],
     Graphics[{Darker[Green], Thick,getlines[f,{x,a, b}, n,0]}],
     AxesOrigin->{0,0},PlotLabel->ToString[n]<>" Left Rectangles",
     PlotRangeClipping->False]];

PlotRightRec[f_,{x_,a_, b_}, n_] :=If[a>b,Print[err],Show[Plot[f, {x, a, b},
      PlotRange->{{Min[0,a],Max[0,b]},All}],
      Graphics[{Red, Thick,getlines[f,{x,a, b}, n,1]}],AxesOrigin->{0,0},
      PlotLabel->ToString[n]<>" Right Rectangles",PlotRangeClipping->False]];

PlotMidRec[f_,{x_,a_, b_}, n_] :=If[a>b,Print[err],Show[Plot[f, {x, a, b},
      PlotRange->{{Min[0,a],Max[0,b]},All}],
      Graphics[{Purple, Thick,getlines[f,{x,a, b}, n,1/2]}],
      AxesOrigin->{0,0},PlotLabel->ToString[n]<>" Midpoint Rectangles",
      PlotRangeClipping->False]];

This defines functions for plotting area-approximating rectangles.

Exercise 1

(a)

To begin, define f(x)=(6/(arctan((x/2))))

Plot f (x) on the interval [1, 4] with 5 left rectangles, and with 5 right rectangles.

Do left rectangles overestimate or underestimate the area under the curve?

Do right rectangles overestimate or underestimate the area under the curve?

Find the sum of the areas of 5 left and 5 right rectangles. Give your answers as decimal numbers to 6 significant digits.

Based on your work so far, fill in the blanks.

Plot f(x) on the interval [1,4] with 50 left rectangles, and with 50 right rectangles, and find the sum of the rectangle areas.

Plot f(x) on the interval [1,4] with 500 left rectangles, and with 500 right rectangles, and find the sum of the rectangle areas.

What happens to the accuracy of the left and right rectangle sums as the number of rectangles is increased?

(b) Now use the integrate command (see palette) to find the exact area under the curve using the definite integral.

Exercise 2

(a)

To begin, define g(x)=6048 x-2016 (x^2)+210 (x^3)-7 (x^4)

Plot g(x) with 100 midpoint rectangles on the interval [0,6], and find the midpoint rectangle sum.

(b)

Plot g(x) with 200 midpoint rectangles on the interval [0,12], and find the midpoint rectangle sum. (Note that Δx is the same as before.)

(c)

Explain why the answer to (b) is less than the answer to (a), even though the region is twice as wide.

Exercise 3

Evaluate each of the following indefinite integrals using the built in integral function found in the advanced math pallete.  Try to do part a by hand and see if mathematica yields the same answer.

(a) ∫(((e^(4x))((e^(4x))-15))^8)dx
(b) ∫(Sin^22)[x](Cos^5)[x]dx
(c) ∫(1/(Sqrt[64+25(x^2)]))dx

Exercise 4

To begin, define f(x)=12(x^2)-168x+480. Plot f(x) on the interval [0,15], and make another plot with Filling->0.

Next, evaluate the following cell, which defines the area function equal to the limit of rectangle sums for our f(x) on the interval [0,b].

area[b_]=(∫_0^b)f[x]\[DifferentialD]x;

To find the limit of rectangle sums for f[x] on the interval [0,b] for some specific b, we simply substitute that particular b into the area function. For example, area[2] finds the limit of rectangle sums for f(x) on the interval [0,2].

Make a table of ordered pairs {b, area[b]} for b from 0 to 15 in increments of 1. Display it as a Grid.

Refer to the table, and to the filled plot of f[x]. Answer the following questions; explain what is happening with the area (not some mathematical formula).

Explain why area[0] = 0. (That is, why is the area 0?)

Explain why area[2] is greater than area[1].

Explain why area[5] is less than area[4].