topic:  visualizing functions of 2 or more variables
description:  introduces Plot3D, ContourPlot, and animations (for functions of 3 variables)
file name:  graphing3d.nb
directions:  Read the text cells for background information.  Execute any existing input cells as you come to them.  Answer questions or work exercises as you come to them.  Modify the existing input cells as needed to work exercises requiring the use of Mathematica.

Computer Assignment #1
Visualizing Functions

Special thanks to Calculus&Mathematica (Addison-Wesley, 1994) for their support of these assignments.  Each is very much in the style of C&M, and some problems and commands are adaptations of C&M problems and commands.

Welcome to the wonderful world of Mathematica!

We will be using Mathematica in Math 243 this semester to visualize some of the concepts of multivariable calculus.  In fact, each computer assignment has been carefully designed to help you better understand the mathematics of the course.  (Yes, that's right...contrary to popular belief, the computer projects are not meant to be a haze!)  Please make an effort to understand what you are doing (don't just copy and paste blindly.)  If you have any questions on the material, see your instructor.  We are here to help.

Why should I have to do this computer assignment anyway?

Being able to visualize functions of two or more variables in a variety of different ways is essential to your success in Math 243.  Over the past couple weeks, we have talked about sections of functions, 3-D graphs, contour diagrams, and level surfaces.  This computer assignment is designed to review some of the different methods we have available for visualizing functions while helping you become more familiar with the technology and the tools available.

Part 1 -- Plot3D

Here is how we get a nice, high-resolution graph of the function f(x,y) = x^2 + y^2.

f[x_,y_] = x^2 + y^2;
Plot3D[f[x,y],{x,-3,3},{y,-3,3},
		AxesLabel->{"x","y","z"},
		PlotPoints->30];

The option PlotPoints->30 is what tells Mathematica to give us a high-res picture.  Larger numbers of PlotPoints yield higher resolution pictures, but also require larger amounts of computer time.  I guess there's no such thing as a free lunch!

If we are unhappy with our perspective on the world, we can change it:

Plot3D[f[x,y],{x,-3,3},{y,-3,3},
		AxesLabel->{"x","y","z"},
		PlotPoints->30,
		ViewPoint->{2.299,-2.330,-0.859}];

a.  Use the Plot3D command to plot a cone of circular cross-section opening downward and with its vertex at the point (0,0,10).  Plot the cone from two different ViewPoints, each of your choice.

<<INSERT COMMAND HERE, FIRST VIEWPOINT>>

<<INSERT COMMAND HERE, SECOND VIEWPOINT>>

Part 2 -- ContourPlot

Here is a contour diagram of the same function above:

f[x_,y_] = x^2 + y^2;
ContourPlot[f[x,y],{x,-3,3},{y,-3,3}];

Mathematica uses the convention that darker regions represent smaller function values.  If we want to see the level curves without the shading:

ContourPlot[f[x,y],{x,-3,3},{y,-3,3},
		ContourShading->False];

Now we can see the spacing between the level curves much better!

a.  The level curves appear to be closer to one another near the edges of the contour diagram than they are near the center.  What does this say about the graph of f(x,y) which we plotted above?

<<ANSWER HERE>>

The following is the contour diagram of a certain function:

b.  Determine a function which will produce such a contour diagram.  Then, execute a ContourPlot command to check your answer.  (You do NOT have to have the exact same picture as above, but the contours should be equally-spaced and the shading scheme should agree.)

<<INSERT COMMAND HERE>>

Here is the contour diagram of another function:

c.  Determine a function which will produce such a contour diagram.  Then, execute a ContourPlot command to check your answer.  (You do NOT have to have the exact same picture as above, but the contours should become more separated toward the edges and the shading should agree.)

<<INSERT COMMAND HERE>>

An elliptical paraboloid is described by the graph of the function f(x,y) = a x^2 + b y^2, where a and b are both positive constants.  The contour diagram of an elliptical paraboloid consists of concentric ellipses.

d.  Determine values for a and b such that the contour diagram for f(x,y) = a x^2 + b y^2 consists of ellipses which are twice as long in the x-direction as they are in the y-direction.  Then, plot the contour diagram for this function.

<<INSERT COMMAND HERE>>

Part 3 -- Functions of 3 Variables (or "How to become an Animaniac")

Here is a rather complicated function of 3 variables:

Clear[f,x,y,t];
f[x_,y_,t_] =
	(Sin[Sqrt[x^2 + y^2] - t])^2/(1 + Sqrt[x^2 + y^2])

We will think of x and y as representing east-west and north-south coordinates, respectively,
and t as representing time.  Since the value of z = f[x,y,t] is a fourth value, we cannot represent this function as a surface in 3-space.  Let's pick this puppy apart, one dimension at a time...

First, here's the section (remember that term?) of f obtained when we fix y = 1.3 and t = 0:

Plot[f[x,1.3,0],{x,-10,10},
		AxesLabel->{"x","f[x,1.3,0]"}];

Note:  The Plot[] command is used for functions of one variable, which is what we are dealing with when we fix everything except for x!

Hmmm...the plot looks kind of like a sine wave, with a few differences.

a.  Geometrically, what effect does the denominator (1 + Sqrt[x^2 + y^2]) have on the plot compared with if it weren't there?  (In other words, how does the graph above compare with the graph of g[x,1.3,0], where g[x_,y_,t_] = (Sin[Sqrt[x^2 + y^2] - t])^2?)

<<ANSWER HERE>>

b.  How does the graph of f[x,1.3,0] compare with that of f[x,4.5,0]?

<<ANSWER HERE>>

We can get a better idea of what we're dealing with by looking at the section of f obtained when we fix just one variable, such as time t:

c.  Plot the surface defined by the section z = f[x,y,0].

<<INSERT COMMAND HERE>>

d.  Looking at the surface you just plotted, describe what the level curves would look like in a contour diagram of f[x,y,0].

<<ANSWER HERE>>

Problem 5 in Section 11.6 asked you to describe the motion of the water surface in a pond, where the height (in feet) of the water was given by...

h[x_,y_,t_] = 20 + Sin[x + y - t];

Here is one way to describe the motion.  First, execute the following cell:

Needs["Graphics`Animation`"];
Animate[
	Plot3D[h[x,y,t],
		{x,-10,10},{y,-10,10},
		PlotPoints->30,
		PlotRange->{19,21}],
		{t,0,2 Pi,Pi/4}];

Now, click once on the outermost cell bracket to the right of the graphs above, so that the cell bracket is highlighted.  Then, press Ctrl-Y (hold down the Ctrl key, then press Y).  Good things should happen.  Click once on the right-arrow that appears at the bottom of the screen so that the animation progresses in the forward direction only.

Now, animate the function f[x,y,t] above.  Hint:  Be certain that you pick a good PlotRange.

e.  Give an English description of a real-world process which the function f[x,y,t] could be used to describe or model.

<<ANSWER HERE>>

f.  PLEASE...delete all ANIMATION cells above so that we do not kill an entire forest printing this assignment!  (Plus, it will take a LONG TIME for all of those 3-D plots to print!)  Then, print the assignment.  (Don't forget your documentation!)