Mathematica Lab 2, MA21a, 2000 Text only version
------------------------------------------------------------------------
*********************
* PLOTTING SURFACES *
*********************

The example

Plot3D[x^2-y^2,{x,-2,2},{y,-2,2}]

shows how to plot the surface of the function 

f(x,y)=x^2+y^2.

There are all kind of cosmetic parameters to tune.
For example

Plot3D[Sin[3*x]*Cos[2*y]*y,{x,0,5},{y,0,5},
   Background->GrayLevel[0.0],
   Axes->False,Mesh->False,
   Boxed->False,PlotPoints->100]

To see a list of features, the function Plot3D has, 
type

??Plot3D 

Surfaces given parametrically can be plotted as for 
example of the Dini surface which decorates the Web 
announcement of this course: 

ParametricPlot3D[
  {Cos[u]*Sin[v],Sin[u]*Sin[v],Cos[v]+Log[Tan[v/2]]+0.2*u},
  {u,0,4*Pi},{v,0.04,1.0},
  Boxed->False,Axes->False]

In the exercice below, you have the opportunity to experiment 
with parameters and functions. Nice surfaces can be obtained 
with functions  (u,v) -> (f(u,v),g(u,v),h(u,v)) ), where f,g,h 
are trigonometric polynomials (functions which contain only 
expressions like cos(u), sin(2v) etc. and sums and products 
of those) and where u and v range from 0 to 2Pi. For example: 

ParametricPlot3D[{Sin[u] Cos[2v],Sin[3u]*Cos[2v],Cos[u]},{u,0,2Pi},{v,0,2Pi},
  PlotPoints->100,Boxed->False,Axes->False]

********************
* CONTOUR PLOTS    *
********************

To see a surface like on a map, where the level curves show the 
location of the same heights, try 

ContourPlot[x^2-y^2,{x,-2 ,2 },{y,-2,2}, PlotPoints->50]

The next version shows it in color:

ContourPlot[Sin[3*x]*Cos[2*y]*y,{x,0,5},{y,0,5},
  {Background->GrayLevel[0],Axes->False,
   ColorFunction->Hue,PlotPoints->200}]  

******************
* VECTOR FIELDS  *
******************

To plot vector fields an additional
Mathematica package Graphics`PlotField` is loaded as the 
following example with the gradient field of the function 
f(x,y)=x^2+y^2 shows.

<<Graphics`PlotField`
Grad[f_,x_,y_]:={D[f,x],D[f,y]}
PlotVectorField[Evaluate[Grad[ x^2-y^2,x,y]],{x,-1,1},{y,-1,1}]

You can combine plots as in the example:

<<Graphics`PlotField`
f[x_,y_]:=-Sqrt[1+x^2+y^2];
Show[
  ContourPlot[f[x,y],{x,-2 ,2 },{y,-2,2},PlotPoints->100],
  PlotVectorField[Evaluate[Grad[f[x,y],x,y]],{x,-2,2},{y,-2,2}]
]

*********************************
* EXERCICE: 1                   *
*********************************
 
Experiment with plotting surfaces and pick your favorate
surface. We will post a gallery of the best surfaces of yours
on the web. Again, you are welcome to submit a printout also. To
get credit, you only have to submit the command, which produced it.      

