\(MATH\ 257\ Calculus\ III				Week\ of\ May\ 5, \ 2003\)
Lab 6 :  Surfing Surfaces
Name 1
Name 2
Section:

I.  Laboratory Objectives
	Use Mathematica to explore
		3D plots of surfaces in rectangular and spherical coordinates

II.  Formatting and Syntax Information

Plot3D[f[x,y], {x, min, max}, {y, min, max}]	 	
				Just like Plot[], but for 2-variable functions (3D graphs of surfaces).
				
	ContourPlot[]	Draws a contour plot (a z-trace).
	
	ParametricPlot3D[{x[t], y[t], z[t]}, {t, min, max}]
					Make a parametric plot.  That is, t ranges from min to max, 
				and plot the points (x[t], y[t], z[t]) as you go.  Can be used to
				plot spherical coordinate equations...

Graphing 3D Surfaces

Graphing 3D surfaces in Mathematica is easy if you have a function of the form z=f(x,y).  Just use the Plot3D[] command, which works just like Plot[] except you have to specify the x and y ranges.

For example, let's plot  f[x,y]=Cos[x*y] - Sin[x*y]:

Plot3D[
      Cos[x*y] - Sin[x*y],  {x,  -4, 4},  {y, -4, 
        4}]

Cool, but notice how chunky the graph is.  To make it finer, use the PlotPoints option:

Plot3D[Cos[x*y] - Sin[x*y],  {x,  -4, 4},  {y, -4, 4},  
      PlotPoints -> 40]

We can also make traces, that is, slices through the x or y axes.  The easiest way to do this is using the Table[] command.  Here we make traces where we fix x=k for some constant k:

Clear[f, x, y];
f[x_, y_] :=  Cos[x*y] - Sin[x*y];
xtraces = Table[f[k, y],  {k, 0, 3}];     
Plot[
          Evaluate[xtraces],  {y,  -3, 3}]

Question 1: In the above trace graph, which curve corresponds to the trace x=0, x=1, x=2, and x=3?

We can also do the y-traces.  Notice that for this surface that are notably similar to the x-traces.

ytraces = 
        Table[f[x, k],  {k, 0, 3}];  

    Plot[Evaluate[ytraces],  {x,  -3, 3}]

To do the z-traces (slices through the z-axis, parallel to the xy-plane), we need to use the ContourPlot[] command.  If you don't like the resolution, use the PlotPoints option again.

ztrace = 
      ContourPlot[f[x, y],  {x, -3, 3},  {y, -3, 3}]

If you don't like the shading, you can get rid of it.

ztrace = 
      ContourPlot[f[x, y],  {x, -3, 3},  {y, -3, 3},  
        PlotPoints -> 40,  ContourShading -> False]

Question 2: Notice how in the above contour plot the trace curves look like ... what?  Hyperbolas?  Get an equation for one of them using the Solve[] command to solve f[x,y] = z when z=1.  (Solve for either y or x.)  Make a plot of the equation you get to see that it looks like one of the contours above.

Question 3: For the following functions, make (i) a 3D plot, (ii) x- and y-traces, and (iii) a contour plot (z-trace).
	(a)   z = Sin[x+y] + Cos[x-y]	
	 (b)  z = 20 (e^(-(((x^2)  +  (y^2))/3)))   (make sure you get the whole thing!)
	 (c)  z = Cos[x + Sin[y]]

One more thing: what if you wanted to graph the line in 3D:  x(t) = t,   y(t) = 2t,  z(t) = 3t +4  ?  Use the command ParametricPlot3D[] !  (Yeah, big whooppie.  But it's good to know this command.)

ParametricPlot3D[{t,  2  t,  
        3  t + 4},  {t,  -4, 4}]

Spherical Surfaces

Graphing surfaces made by equations in spherical coordinates takes a little bit of prep-work.  Mathematica doesn't just do it all for you.  It helps a lot if we define a function to convert from spherical to rectangular coordinates:

sphrToRect[{ρ_,  θ_,  ϕ_}] = {ρ*Sin[ϕ]*Cos[θ],  ρ*Sin[ϕ] 
          Sin[θ],  ρ*Cos[ϕ]}

This takes a point in spherical coordinates (ρ, θ, ϕ) and converts it to regular (x, y, z), like God intended!
Test it out:

sphrToRect[{1,  π/6,  π/
          3}]

We can use this command to graph equations in spherical coordinates.  

Example:  Suppose we wanted to graph the equation ρ = 3, which should be a sphere of radius 1.  Just set ρ = 3 and let θ and ϕ range over some values:  0 ≤ θ ≤ 2π  and   0 ≤ ϕ ≤ π:  We need to use the ParametricPlot3D command to do this, however:

ParametricPlot3D[
      sphrToRect[{3, θ, ϕ}],  {θ,  0,  
        2  π},  {ϕ,  0,  π}]

But what happens if we change the range of, say, θ?  Let's find out:

ParametricPlot3D[
      sphrToRect[{3, θ, ϕ}],  {θ,  0,  
        7  π/4},  {ϕ,  0,  π}]

Question 4a: Make a few good pictures that show what the spherical equation  ρ = 2 θ   looks like.  Tip: you have to make θ range to some higher values, like 0 ≤ θ ≤ 10 or something.  Also, you won't be able to see all the cool stuff going on inside unless you change the range of ϕ as well.  (Like,  1 ≤ ϕ ≤ π  or something like that.)  Make sure some of your pictures display this.  Then describe what this surface is like in a sentance or two.

Question 4b: Do the same thing (make a few good, descriptive 3D pictures and write a sentance ot two describing the surface) for the equation ρ = ϕ.

Question 4c:  Do the same thing for ρ = 1 + Sin[ϕ].

Question 5:  Explore the family of spherical surfaces given by ρ = 1 + 0.2 Sin[m*θ]*Sin[n*ϕ] where m and n are positive integers.  (These surfaces have been used to model the shape of tumors.)  Make a few good pictures of these surfaces for various values of m and n (if you choose high values, you might want to use the PlotPoints command to draw the surface more finely).  Describe in a few sentances the roles m and n play in the shape of the surface.

Now that you're done, 
	(1) 	Clean up your work by deleting everything that's not needed.  
		There should only be the title, your names, section number, and the questions and your answers
		(with any needed explanations, graphs, etc.).
	(2) 	Save this to your disk.
	(3)	Go back to Blackboard and upload your final lab report to the Digital Drop Box, located
		in the User Tools area.  Remember that you have to first ADD your file to your digital drop box and 
		then SEND it to me!