| Math 235 Calculus III - Lab 1 Plotting in Three Dimensions |
Math 235 Calculus III
University of Colorado at Colorado Springs
Plotting in Three Dimensions
The graph of an equation f(x,y)=z is a three dimensional pictoral representation of the ordered triples that satisfy that equation. So, when you plug any point (x 1 ,y 1 ,z 1 ) from the graph into the equation f(x,y)=z the equation will hold true while if you plug in any point that is not on the graph, the mathematical equation will not be satisfied. Since this pictoral representation is so important to us and since it is often very difficult to generate a 3-dimensional graph by hand we will learn to use Maple to generate these pictures for us. First, we will cover plotting a 3-dimensional curve in rectangular coordinates, then in cylindrical and sprherical coordinates.
Rectangular Coordinates
To sketch a 3-Dimensional surface it is often helpful to graph the intersection of the surface with planes parallel to the coordinate planes. The curves that result from this intersection are called traces and the names given to the three dimensional figures often reflect the shape of these curves. Maple will allow us to graph these surfaces with relative ease if we just learn the proper syntax. The ability to graph these surfaces will give us the ability to more accurately analyze the behaviour of a particular function.
The first thing we must learn in order to plot our
functions in Maple is whether the function is being defined explicitly or implicitly. All
of our functions will be functions of 3 variables, x,y and z. If the function is solved
for one variable in terms of the other two we call that an explicitly defined function. An
example would be z=3x+4y-2. Sometimes, however, it is not feasible to solve an equation
for one of the variables involved; these equations are implicitly defined. For example,
is the
equation of the sphere centered at the origin with radius 2. If we try to get z by itself
on one side of the equation we'd have to use a square root. That's not necessarily a
problem but it would be better if we could just use the format the equation is given in.
And, as it turns out, Maple will let us plot either way as long as we know how to ask it
in the right way.
Before we can actually start plotting complicated functions in Maple we need to prepare the program. In order to get the program to open more quickly, Maple doesn't automatically load every command every time you turn the program on. Instead it loads a basic amount of mathematical commands and if you want more advanced commands, you must ask it to load that package. Since we are going to be doing some fairly advanced graphing we'll need to tell Maple to go into its memory and load up those extra commands. We do this with the following command:
> with(plots):
By using this command we've told Maple to load up its advanced graphing capabilities so that it will be prepared to handle what we'll ask it to do. You must reload these commands everytime you start a new session on Maple.
We'll start by graphing an ellipsoid,
=1. To
get Maple to do a 3D plot like this, we must realize that the equation of 3 variables
isn't solved for any one variable which tells us this is an implicitly defined function.
Thus, we'll use the "implicitplot3d" command.
> implicitplot3d(x^2/4+y^2/9+z^2/16=1,x=-4..4,y=-4..4,z=-4..4);
Note that the "implicitplot3d" command is typed first, then a set of parentheses, then the function, then the values for the x,y and z axes. After all this the parentheses were closed and the line ends with a semicolon. YOU MUST ALWAYS TYPE A SEMICOLON AT THE END OF A COMMAND!! If you don't use a semicolon at the end of a command, the computer won't understand that you're done with the command. Go ahead and type the command in on a Maple session. Notice that the computer just plots the ellipsoid with no axes. We have no idea how big the ellipsoid is or where its located in the coordinate system. To get it to add the axes to give us a sense of orientation, click on the graph. This will put a box around the graph and add some buttons to your menu. Once the box appears, look at the top of the screen about 1 inch from the top and in the middle. There will be 4 buttons that look like they have a big red circle in them. These are the four different ways you can display your coordinate axes. Try them out. Now, just to the left of the axes buttons, you have the choice of how you want your surface drawn- do you want level curves or points on the surface? Try the different options out. Also notice that if you click on your graph you can drag the surface around to look at it from different angles.
Now, let's look at an explicit plot. Let
. Note
that this is the same as
which is a function of 3 variables that will produce
a 3D plot. Since the z is all by itself on one side of the equation, we know this is an
explicit plot. To graph this, we use the command "plot3d" and then type in the
function. Notice, we don't have to type z=, the computer understands that the function is
z=.
> plot3d(4*x^3+3*y^2,x=-5..5,y=-5..5);
Again, note that we type the command, then the function we wish to graph and the x-values and y-values we wish to cover. Also note that to get Maple to multiply 4 times x we had to use the "*" symbol. Maple won't understand multiplication without this symbol.
Now, what if the surface we want to plot isn't given
in the forms above but instead is given as a set of parametric equations. Then, as long as
we let Maple know that that's what we're working with, the program will take care of the
problem for us. For example, let's say we want to graph the surface defined by the
parametric equations given in the vector
. Then we use the command
"spacecurve" to tell the computer we'll be giving it a three dimensional
parametric curve problem.
> spacecurve([sin(t),cos(t),t^2],t=0..2*Pi);
This curve traces out the x, y and z coordinates
that will be obtained when t is allowed to range from 0 to
. Here,
after the command, we list the 3 parametric equations in order inside a set of square
brackets and then we list the values of t we'd like to use.
Cylindrical and Spherical Coordinates
Sometimes it's easier to do a problem in cylindrical
or spherical coordinates rather than in rectangular form. Remember that to convert from
cylindrical to rectangular coordinates we use the equations
,
and
z=z whereas to convert from rectangular to cylindrical we use
,
and
z=z, where x is non-zero. If the equation of the surface is of the form
simply
type the funciton straight into the "cylinderplot" command followed by the
appropriate ranges for
and z. So, here we plot
. If
we have multiple cylindrical expressions we can use the command
"cylinderplot({expr1,expr2,...},theta=a..b,z=c..d); where expr1 represents the first
function that gives r from
and z and expr2 represents the second and so on.
> cylinderplot(2*cos(theta),theta=0..2*Pi,z=-10..10);
Spherical coordinates are plotted in much the same
fashion. If we have an expression that determines
from
and
, we
simply type "sphereplot(expr,theta=a..b,phi=c..d);" and the form for multiple
spherical equations is just the same as the one that arises in cylindrical coordinates.
> sphereplot(2*cos(phi),theta=0..2*Pi,phi=0..2*Pi);
Now here are some problems for you to try. Print your answers for the following problems. Make sure the computer is including an axis for each graph. (Remember that to do this, you click on the graph to make a box around it, then select one of the axis choices from the button bar above.)
1) Plot the following:
. On
your graph show x and y values between -10 and 10. This is a hyperbolic paraboloid. Once
you've graphed the surface, twist it so you can clearly see the saddle. (Remember this is
done by clicking on the surface so that it's surrounded by a box then dragging it in
whichever direction you want it to rotate.)
2) Plot the curve given by the vector
with t
ranging from 0 to 2
.
3) Plot the cylinder with radius 3. Make the height of the cylinder 20.
4) Plot the following surface:
.
Allow your x, y and z values to range from -10 to 10. This surface is a hyperboloid of two
sheets. Twist the surface so that you can clearly see the two sheets.
5) Plot the surface r cos(f )=2cos(q). Remember that to plug the equation into Maple, you must have r in terms of
and
.
Twist the graph around until you can see what shape it generates. (Hint: you see it in the
sea.)
The tools you've learned in this lab have given you a foundation of how to do simple plots in Maple. Now, as more difficult plots come up in your coursework, you can use the commands you've learned here to help generate their graphs.