5.1 Areas and Distances

Mathematica script by Chris Parrish,
   cparrish@sewanee.edu

Sources and references for some of these problems include
    James Stewart, "Calculus: Concepts and Contexts," Second Edition, Brooks/Cole, 2001
    Deborah Hughes-Hallett, Andrew M. Gleason, et. al., "Calculus," Second Edition, John Wiley & Sons, 1998
    Robert Fraga, ed., "Calculus Problems for a New Century," The Mathematical Association of America, 1993
    
Code for the Mathematica procedures AreaR, AreaL, and AreaM is modified slightly from programs developed in
    Finch and Lehmann, "Exploring Calculus with
Mathematica," Addison-Wesley, 1992

Calculating Riemann Sums

Generic Formulas for Riemann Sums

We first create the formulas for three types of Riemann Sums defined for a generic function f over an interval [a,b] using a uniform subdivision of [a,b] into n equal subintervals.
The three formulas correspond to the choice of lefthand endpoint rule, midpoint rule, and righthand endpoint rule for determining the heights of the rectangles to be constructed.

In[149]:=

Clear[f, a, b, n]  riemannSumL[n_] := Sum[f[a + i (b - a)/n] * (b - a)/n, {i, 0, n - 1 ... , {i, 0, n - 1}}], ]}]}], ;}] riemannSumR[n_] := Sum[f[a + i (b - a)/n] * (b - a)/n, {i, 1, n}] ;

Calculating Riemann Sums for Specific Functions
and Specific Values of n

Now apply these formulas to the task of calculating Riemann Sums for a specific function f over a specific interval [a,b] and with a specified number of subdivisions n.

In[153]:=

Clear[f, a, b, ns, data]  f[x_] := x^(1/2)  a = 0 ; b = 1 ;  ns = {10, ... uot;, "RiemannSumL(n)", "RiemannSumM(n)", "RiemannSumR(n)"}, None}]

Out[159]//TableForm=

n 10 50 100 500
RiemannSumL(n) 0.610509 0.656095 0.661463 0.665648
RiemannSumM(n) 0.668384 0.666831 0.666725 0.666672
RiemannSumR(n) 0.710509 0.676095 0.671463 0.667648

Taking the Limit of Riemann Sums
as n Goes to Infinity

In[160]:=

Clear[f, a, b, n]  f[x_] := x^2 ;  a = 0 ; b = 2 ;  riemannSumL[n]

Out[164]=

(4 (-1 + n) (-1 + 2 n))/(3 n^2)

In[165]:=

Limit[riemannSumL[n], n∞]

Out[165]=

8/3

Mathmatica can calculate the integral directly.

In[166]:=

∫_a^bf[x] x

Out[166]=

8/3

Illustrating Riemann Sums

AreaR,  AreaL,  AreaM -- contains Mathematica code only, not worked exercises

Using Rectangles to Estimate the Area of the Region
under the Graph of  f(x) = x/(1 - x^4)^(1/2)and over the interval [0,1/2^(1/2)].

Hughes-Hallett, Gleason, et al, Second Edition, Exercise 7.2.25, page 332

The Mathematica procedure called AreaRVerbose was designed to produce illustrations such as those to be found in Section 5.1 of Stewart and Section 7.2 of Hughes-Hallett, Gleason, et al. It takes four arguments: the function f, the right- and left-hand endpoints of the interval to be taken as the domain of f, and the number n of rectangles to use in the construction. The "R" in the procedure's name indicates that we will use the righthand endpoint of each subinterval along the x-axis to determine the height of the associated rectangle built on top of that subinterval. The"Verbose" in the name of the procedure indicates that it will print out a statement following the graph reporting the area of the approximating rectangles.

In[187]:=

Clear[f, x] ;  f[x_] := x/(1 - x^4)^(1/2) ;  a = 0 ;     & ... sp;    (*n = number of rectangles*)AreaRVerbose[f, a, b, n] ;

[Graphics:HTMLFiles/5.1_areasDistances_13.gif]

RowBox[{The total area of the illustrated rectangles is , , 0.29105}]

The Mathematica procedure called AreaLVerbose uses lefthand endpoints of the subintervals to determine the heights of the rectangles used in the construction.

In[192]:=

AreaLVerbose[f,a,b,n];

[Graphics:HTMLFiles/5.1_areasDistances_15.gif]

RowBox[{The total area of the illustrated rectangles is , , 0.233315}]

The Mathematica procedure called AreaMVerbose uses the midpoints of the subintervals to determine the heights of the rectangles used in the construction.

In[193]:=

AreaMVerbose[f,a,b,n];

[Graphics:HTMLFiles/5.1_areasDistances_17.gif]

RowBox[{The total area of the illustrated rectangles is , , 0.261609}]

Let's see what Mathematica's built-in numerical procedures produce as an estimate of the area we have been working with.

In[194]:=

NIntegrate[f[x],{x,a,b}]

Out[194]=

0.261799

Calculating the integral directly yields

In[195]:=

∫_a^bf[x] x %//N

Out[195]=

π/12

Out[196]=

0.261799

Which of the procedures AreaLVerbose, AreaMVerbose, AreaRVerbose produced the most accurate approximation to the true value of the integral?
How can you explain its relative accuracy?

Using Rectangles to Estimate the Area of the Region
under the Graph of  f(t) = Sin(1/t) and over the interval [1/4, 1].

Hughes-Hallett, Gleason, et al, Second Edition, Exercise 7.2.26, page 332

First, use righthand endpoints for the construction.

In[197]:=

Clear[f,t];

f[t_] := Sin[1/t]

a = 1/4;  (* a = lefthand endpoint *)
b = 1;    (* b = righthand endpoint *)
n = 10;   (* n = number of rectangles *)

AreaRVerbose[f,a,b,n];

[Graphics:HTMLFiles/5.1_areasDistances_25.gif]

RowBox[{The total area of the illustrated rectangles is , , 0.606809}]

Then use use lefthand endpoints.

In[203]:=

AreaLVerbose[f,a,b,n];

[Graphics:HTMLFiles/5.1_areasDistances_27.gif]

RowBox[{The total area of the illustrated rectangles is , , 0.486939}]

And finally, let's use midpoints.

In[204]:=

AreaMVerbose[f,a,b,n];

[Graphics:HTMLFiles/5.1_areasDistances_29.gif]

RowBox[{The total area of the illustrated rectangles is , , 0.555086}]

Here is what Mathematica's built-in numerical procedures produce as its approximation to the (signed) area of the region.

In[205]:=

NIntegrate[f[t],{t,a,b}]

Out[205]=

0.552286


Created by Mathematica  (April 20, 2004)