The graph of a function of a single real variable is a set of
points (x,f(x)) in the plane. Typically, the graph of such a function
is a curve. For functions of two variables, the graph is a set of points
(x,y,f(x,y)) in three-dimensional space. For this reason, visualizing
functions of two variables is usually more difficult.

One of the most valuable services provided by computer software such
as Maple is that it allows us to produce intricate graphs with a minimum
of effort on our part. This becomes especially apparent when it comes
to functions of two variables, because there are many more computations
required to produce one graph, yet Maple performs all these computations
with only a little guidance from the user.

Two common ways of representing the graph of a function of two variables
are the surface plot and the contour plot. The first is simply a
representation of the graph in three-dimensional space. The second,
draws the level curves f(x,y)=C for several values of C in the
x,y -plane. We will explore how to produce these kinds of graphs in
Maple, and how to use the graphs to study the functions.

This command generates a surface plot of the
function. This command has a lot of options that you can use
to get the plot to look the way you want it. Some of the
most useful options are described below. For more
information, see the help for the plot3d command.

The default viewing angle is from a direction 45 degrees between
the positive x- and positive y- axes, and an angle of elevation
of 45 degrees. You can change this viewing angle with the
orientation option, orientation=[a,b]. The
first number is the polar angle, measured counterclockwise from
the positive x-axis. The second number is the angle of elevation;
it is measured downward from straight above, also in degrees.

You can also select a viewpoint using the mouse.
Click the mouse on a three-dimensional graph,
and notice the context bar that appears between the tool bar
and the Maple input/output window.
Click the graphic again, and the graph is replaced by a
box. Hold down the button as you move the mouse, and you'll see
the box from different angles. You'll also
see the numbers on the left, labeled and , change accordingly. They correspond to the two numbers in
the orientation option.

Once you've selected
the desired viewpoint, redraw the graphic by pressing
the button marked `R' at the right end of the tool bar.

The other buttons in the tool bar control other aspects of how
the plot is drawn, including the plot style, axes style,
etc.

The number of grid points in the plot can be changed with the
grid=[x,y] option. You may want to increase the number of grid
points if your plot appears rough, or has a lot of oscillation;
you may want to use a smaller number if the function is reasonably
smooth and you want to shorten calculation times.

Note that you can use the context bar instead of optional arguments to
the plot3d command to customize your plot. Saving your
worksheet after you have made changes will save the plot as it last
appeared. However, if you need to run the plot3d command
again, any customizations you made with the context bar will be
lost. The safest approach is to use the context bar to experiment with
your plot until you are satisfied with it. Then add options to your
plot3d command that will give you the same plot, for example
by specifying the orientation or axes arguments in
your command.

Generates a contour plot of a function of two
variables. This command is part of the ``plots'' package, so you
need to run with(plots) before using the command. The basic
syntax is the same as for plot3d.

Maple's default is to produce ten contours. This can be changed using
the option contours=n. Maple chooses the z-levels of the
contours automatically. If you want to see specific level curves,
you can write the z-values in a list.

If a surface cannot be easily written as
z=f(x,y) but can be written
as a relation F(x,y,z)=0, then the Maple
implicitplot3d command from the plots package can
often be used. For example, to plot the cylinder y2+z2 = 2 the
following command can be used. Don't forget to load the plots
package first using the command with(plots); first.

> implicitplot3d(y^2+z^2=2,x=0..2,y=-2..2,z=-2..2);

Getting a good plot using this command can be a little tricky because
you have to come up with good guesses for the ranges for x, y, and
z. If most or all of the surface is outside the ranges you specify,
you may not see a good representation of the surface.

Maple can also do plots of surfaces in cylindrical and spherical
coordinates. To do this, you just use the coords option to
the plot3d command to specify the coordinate system. For
example, the following command will plot the cylinder r=1 for .

> plot3d(1,theta=0..2*Pi,z=-1..1,coords=cylindrical);

The next command plots the cone r=1-z over the same range for z.

> plot3d(1-z,theta=0..2*Pi,z=-1..1,coords=cylindrical);

The plot3d command expects your equation for the
surface to be of the form , with the first
independent variable and z the second independent variable. If your
equation isn't of
this form, then you have to use a parametric plot. Parametric plots of
surfaces are usually beyond the scope of this course, but we will
present an example in Cartesian coordinates at the end of this
section.

Plotting a surface in spherical coordinates is very similar. Maple
expects the equation of the surface to be in the form . Again, the order is important. The following command
plots the unit sphere.

> plot3d(1,theta=0..2*Pi,phi=0..Pi,coords=spherical);

Many surfaces can be represented in more than one coordinate
system. For example, the following command plots the same cylinder of
radius 1 that we plotted before, but in spherical coordinates.

> plot3d(1/sin(phi),theta=0..2*Pi,phi=Pi/4..3*Pi/4,coords=spherical);

The implicitplot3d command can also be used to plot relations
in terms of cylindrical or spherical coordinates. The only tricky part
is that it expects you to give the ranges in a certain order. For
example, in cylindrical coordinates it expects the range for r
first, then the range for , and finally the range for
z. Other orders can give unpredictable results. For spherical
coordinates, the order must be .

Sometimes a surface cannot easily be represented in Cartesian, polar,
or even spherical coordinates. In these cases, a parametric plot of
the surface is often used. We have already seen parametric curves, in
which a single parameter, usually t was used. For a surface, two
parameters are required. A parametric surface in Cartesian coordinates
is an ordered triple of functions (f(s,t),g(s,t),h(s,t)) where
x=f(s,t), y=g(s,t), and z=h(s,t). That is, given values of the
parameters s and t you can compute a point (x,y,z) on the
surface. For example, any surface z=F(x,y) can be represented
parametrically as (s,t,F(s,t)). However, the real utility of a
parametric surface is for surfaces that cannot be represented as
z=F(x,y) or even as a simple relation between x, y, and z. For
example suppose you wanted to plot the cylinder
y2+z2=2 for . You could solve for z, but that
gives the two functions and and
you would have to combine them to plot the cylinder. An alternative is
the following.

> plot3d([s,2*cos(t),2*sin(t)],s=0..2,t=0..2*Pi);

We used the implicitplt3d command above to plot this same
cylinder. An advantage of using a parametric plot is that you usually know what ranges to use for your parameters to get the plot you want.

As a final example of a parametric surface, we present the torus, or
doughnut if you are
feeling hungry.

There are occasionally problems printing out a Maple worksheet that
has many three dimensional plots. The usual symptom is that part of
the worksheet is not printed. If this happens to you, the best method
for overcoming this problem in the past has been to delete all of the
output in your worksheet, save it, and then re-execute the whole
worksheet before attempting to print again. The best way to delete all
output is to use the Remove Output item from the
Edit menu. There is also an Execute option in the
Edit menu that you can use to execute all the commands in
your worksheet. If this doesn't work, consult your instructor.

The unfortunate thing about this problem is that modifications you
might have made to your plots using the mouse or the context bar are
lost. This is why it is a good idea to first experiment with your plot using
the mouse and the context bar but, once you have the plot looking the
way you want it, to include your modifications in the plot command.

Generate a surface plot and contour plot for each of the
following functions on the given domains:

i.

f(x,y) = x/(1+x2+y2), for and
.

ii.

, for
and .

(b)

What does the contour plot look like in the regions where
the surface plot has a steep incline? What does it look like
where the surface plot is almost flat?

(c)

What can you say about the surface plot in a region where the
contour plot looks like a series of nested circles?

2.

Generate a surface plot for the following functions on the domains
given.

(a)

for and . Use cylindrical coordinates.

(b)

for and .

3.

Consider the function for and , which looks like a deep valley with
mountains on either side. Is it possible to find a path on the surface
from the point to the point such that
the value of z is always between -0.25 and 0.25? You do not have
to find a formula for your path, but you must present convincing
evidence that it exists. For example, you might sketch your path in by
hand on an appropriate contour plot.

4.

Plot
for first using the
implicitplot3d command and then using a parametric plot and
the plot3d command.