Math 166 A2
Class Exercise
4 October 1996

Work on these problems in teams of 3 or 4.

Your group should discuss each problem together, but you may divide up
the actual work any way you like.

At the end of the class, turn in one completed set of results for your team.

Names:_______________          _________________


         ________________          _________________

Our exercises today use the function  y(x) = 1 / (1+x^2) or data derived from it.
First, let's ENTER the function definition:

Clear[f, x]
f[x_]:= 1 / (1+x^2)

Plot this function over the range 0 <= x <= 3:

Plot[{f[x],0},{x,0,3}]

Define x and y values that sample this function, using 6 equal intervals (and so 7 points):

n=6;

xvals = Table[ 3.0*(i-1)/n, {i,1,n+1} ]
yvals = Table[ f[xvals[[i]]], {i,1,n+1}]

Plot this approximate data using the Table and ListPlot commands:

pairs = Table[ {xvals[[i]], yvals[[i]]}, {i,1,n+1} ]

ListPlot[pairs,PlotJoined->True,AxesOrigin->{0,0}]

1) The area under the curve:

A) Enter the following Mathematica  command to integrate f[x] from 0 to 3. 
   * If the Integrate command fails, try the NIntegrate command.  
   * If the Integrate command gives you a symbolic answer, use the N[Integrate] command.

Integrate[ f[x],{x,0,3} ]

B) Let's repeat this exercise, using the data xvals and yvals and a left Riemann sum,  using Mathematica  just as a simple calculator:

right = 0.5*???    + 0.5*???     + 0.5*??? +
        0.5*???    + 0.5*???     + 0.5*???

C) Now let's try using a Mathematica  command to compute the same Riemann sum on the approximate data.  Fill in the question marks with the appropriate quantity:

Sum[ ???, {i, 1, n} ]

2) The center of mass:

If the area under the curve represents a solid shape, of uniform density and thickness, we can define the center of mass (xc, yc).  We have to compute three integrals:
   the mass (which is just the area, which we have just computed), 
   the x-mass (or "moment in the y direction"), and 
   the y-mass (or "moment in the x direction").

A)  Compute the center of mass using the exact data and the Integrate or NIntegrate command:

mass = ( use value from 1A)

x_mass = Integrate[ ???, {x,0,3} ]

y_mass = Integrate[ ???, {x,0,3} ]

xc = x_mass / mass
yc = y_mass / mass

B)  Compute the center of mass using ONLY approximate data:

mass = (use value from 1B or 1C)

x_mass = Sum[ ???, {i,1,n} ]

y_mass = Sum[ ???, {i,1,n} ]

xc = x_mass / mass
yc = y_mass / mass

3) The volume of revolution:

Suppose we rotate our exact and approximate curves around the x axis.   We have three different formulas for computing the resulting volume.

A) For the method of disks, use Integrate or NIntegrate on the exact data, and the appropriate Sum command on the approximate data, to compute the volume.

exact_vol_disks = Pi * Integrate[ ???, {x,0,3} ]

approx_vol_disks = Pi * Sum[ ???, {i,1,n} ]

B) For the method of shells,  using the exact formula, we integrate in the y direction.  Hence, we must compute the inverse of f[x].

Solve[ f[x] == y, x]

Mathematica  gives us two answers.  Which one must we use?

g[y_] := ???

Determine the integrand and y limits of integration, and integrate:

exact_vol_shell = 
  2 * Pi * Integrate[ ???, {y, ?, ?} ]

C) For the method of shells, using the approximate data and a left Riemann sum, we just compute 2 * Pi * Sum (x(i) * y(i)).  ENTER this command:

approx_vol_shell = 
  2 * Pi * Sum[ xvals[[i]]*yvals[[i]], {i,1,n}]

Can you make the approximation better by setting up a trapezoidal rule?

approx_vol_shell = 
  2 * Pi * Sum[ ???, {i,1,n}]

D) The method of Pappus  says that V = 2*Pi*A*r, where A is the area under the original curve, and r is the distance from the axis of rotation to the center of mass of the area.

exact_vol_pap = 2 * Pi * ??? * ???

approx_vol_pap = 2 * Pi * ??? * ???

4) The arc length:

A)  For the exact formula, we simply have to remember the correct quantity to insert in the Mathematica  Integrate or NIntegrate command:

exact_arc = Integrate[ ???, {x,0,3} ]

B) For the approximate data, we need to approximate the derivative.  For this, we use the slope of the line between (x(i),y(i)) and (x(i+1),y(i+1)).  N+1 values of y give us n estimates for
the derivative.  ENTER this command:

ypvals = Table[ (yvals[[i+1]]-yvals[[i]]) / 
  (xvals[[i+1]]-xvals[[i]]), {i,1,n} ]

For "technical reasons", we associate ypvals[[i]] with the midpoint of interval i.  We set up a special list of data called xpvals to contain this information.  ENTER this command:

xpvals = 
    Table[ 1/2 (xvals[[i+1]]+xvals[[i]]),{i,1,n}]

A ListPlot of xpvals and ypvals should look similar to a Plot of the exact derivative f'.

pairs = Table[ {xpvals[[i]], ypvals[[i]]}, {i,1,n}];

plot1=ListPlot[ pairs, PlotJoined->True,
  DisplayFunction->Identity]
  
plot2=Plot[ f'[x], {x,0,3},
  DisplayFunction->Identity]
  
Show[plot1,plot2, DisplayFunction->$DisplayFunction]

C) Now use a Riemann sum to approximate the arc length:

approx_arc = Sum[ ???, {i,1,n} ]

5) The surface area of the volume of revolution:

A) For the exact formula, insert the correct quantity into the Integrate or NIntegrate command:

exact_surf = Integrate[ ???, {x,0,3} ]

B) To compute the surface area defined by the approximate data, use the ypvals data from 4B.

approx_surf = Sum[ ???, {i,1,n} ]