Using Plot3D

As you probably recall from Lab 1, the Plot3D function is used to graph functions of two variables as follows.

[Graphics:3dgraphinggr2.gif][Graphics:3dgraphinggr1.gif]
[Graphics:3dgraphinggr2.gif][Graphics:3dgraphinggr3.gif]
[Graphics:3dgraphinggr2.gif][Graphics:3dgraphinggr4.gif]

There are many options to the Plot3D function. We can list the options together with their default values.

[Graphics:3dgraphinggr2.gif][Graphics:3dgraphinggr5.gif]
[Graphics:3dgraphinggr2.gif][Graphics:3dgraphinggr6.gif]

Fortunately, the defaults chosen by Mathematica gave a reasonable rendition of the above graph. You will find that you do not have to become familiar with very many of the options of Plot3D to be effective in graphing in 3-space. We can illustrate the effect of a few of the options by making some adjustments on the previous graph. Since the options we are adjusting below do not affect the sample points computed by Plot3D in the previous graph, we can just pass the options along to Show.

[Graphics:3dgraphinggr2.gif][Graphics:3dgraphinggr7.gif]
[Graphics:3dgraphinggr2.gif][Graphics:3dgraphinggr8.gif]
[Graphics:3dgraphinggr2.gif][Graphics:3dgraphinggr9.gif]

The Plot Algorithm

To gain some insight into the method used by the Plot3D function to construct graphs, let's consider what would happen if we graphed the same function from the previous section using a larger region in the xy-plane.

[Graphics:3dgraphinggr2.gif][Graphics:3dgraphinggr10.gif]
[Graphics:3dgraphinggr2.gif][Graphics:3dgraphinggr11.gif]
[Graphics:3dgraphinggr2.gif][Graphics:3dgraphinggr12.gif]

What a mess. In looking at the graph, it is apparent that there is no adaptive algorithm operating with Plot3D which automatically increases the density of sampled points whenever sharp bends are encountered like there is with the Plot function for plane graphs. Instead, what happens is that there are PlotPoints number of equally spaced points sampled in both the x and y directions. From the above list of options, we see that PlotPoints has a default value of 15. Thus, there are 225 sample points used to construct the above graph. From the computed graph, we see that the number of sample points needs to be increased. We can do this with the following.

[Graphics:3dgraphinggr2.gif][Graphics:3dgraphinggr13.gif]
[Graphics:3dgraphinggr2.gif][Graphics:3dgraphinggr14.gif]
[Graphics:3dgraphinggr2.gif][Graphics:3dgraphinggr15.gif]

Now a much clearer picture of the function emerges.

Miscellaneous Options for Plot3D

From the list of options for Plot3D in the previous subsection, you see that there are many which are available. Nevertheless, we have been able to obtain reasonably good graphs of functions by changing the defaults of only a few of the options. In this subsection, we will consider some of the options we have not used yet.

Let's begin with the default graph of a particular cubic polynomial and see what we might want to change to improve it. The surface occuring as the graph of this funciton is often called a "monkey saddle". Can you see why?

[Graphics:3dgraphinggr2.gif][Graphics:3dgraphinggr16.gif]
[Graphics:3dgraphinggr2.gif][Graphics:3dgraphinggr17.gif]
[Graphics:3dgraphinggr2.gif][Graphics:3dgraphinggr18.gif]

That's not bad as it is. But suppose we want to eliminate the bounding box and the axes. Additionally, we can try to uncompress the z-axis relative to the other two axes, and modify the perspective so we can see more of the underside of the surface. To avoid recomputing all the points, we use the Show command.

[Graphics:3dgraphinggr2.gif][Graphics:3dgraphinggr19.gif]
[Graphics:3dgraphinggr2.gif][Graphics:3dgraphinggr20.gif]
[Graphics:3dgraphinggr2.gif][Graphics:3dgraphinggr21.gif]

In order to understand the ViewPoint value, you have to understand that Mathematica uses relative (not absolute) coordinates for this option. In particular, Mathematica treats the bounding box as being one relative unit long in each dimension. So the center of the bounding box has relative coordinates (.5,.5,.5). Now you can follow how the adjustment on the ViewPoint option was made. When you need to experiment with the ViewPoint, a convenient way to do this is to choose the 3D ViewPoint Selector from the Prepare Input selection of the Action menu.

The BoxRatios option is similar to the AspectRatio option used in two-dimensional plots. It determines the ratios of the side lengths of the box bounding the graphic.