Mathematica has a command to generate plots of the level surfaces of a function f of three variables. It is part of the Standard Package Graphics, which you must load into memory before you can invoke it. The syntax of the command is the three-variable version of the syntax of the ContourPlot command to generate the level curves of a function of two variables:

ContourPlot3D[F[x, y, z], {x, xmin, xmax},
{y, ymin, ymax}, {z, zmin, zmax}]

where F[x, y, z] is an expression in the variables x, y, and z, which range over the respective intervals [xmin, xmax], [ymin, ymax]  and  [zmin, zmax].

The 3-dimensional contour plotting command differs from
ContourPlot in one major way. The default command generates a plot of only one level surface: the one with equation f(x, y, z)  = 0. For the function f with formula f(x, y, z) = + + -- 9, with x, y and z each varying between --3 and 3, execution of this command produces just the single level surface (sphere) that results from setting w = f(x, y, z) equal to 0. (The following routine adds coordinate axes and labels to the default box that surrounds the plot, which normally does not have labels. Try it, and exercise patience while Mathematica carries out the many computations it needs!)

``(* Mathematica Command to plot level surface of f (x, y, z) =         x^2 + y^2 + z^2 -- 9 *)         Needs["Graphics`ContourPlot3D`"]ContourPlot3D[x^2 + y^2 + z^2 - 9, {x, -3, 3},               {y, -3, 3}, {z, -3, 3},                Axes -> True, AxesLabel -> {x, y, z}]    ``

More than whimsy limits ContourPlot3D to plotting a single level surface. Like most 3-dimensional graphics packages, Mathematica's uses a hidden line algorithm, which does not show any part of a plot that occurs behind plotted points closer to the viewpoint. In this example, any sphere that corresponds to a nonzero value c > 0 has smaller radius than that of the sphere f(x, y, z) = 0 -- the sphere centered at the origin of radius 3. (For example, the level surface corresponding to c = 1 is the sphere + + = 8.) Since its graph lies entirely inside the level surface for c = 0, Mathematica does not show any of it. So plotting more than one level surface may not produce several visible surfaces.

The following routine plots the level surfaces of the function
f(x, y, z) = + for w = 1 , 4 and 9, for x and y ranging between --3 and 3 with z positive. Try executing it (place the cursor at the end and press the Enter key). (Note: it takes considerable time to complete all the computations!)

(* Mathematica Routine to plot level curves of f (x, y) =
x^
2 + z^2 in color, with built-in smoothing *)

Needs["Graphics`ContourPlot3D`"]

ContourPlot3D[x^2 + z^2, {x, -3, 3}, {y, -3, 3},
{z, 0, 3}, Contours -> {1., 4., 9.},
Axes -> True, AxesLabel -> {x, y, z}]

Converted by Mathematica      September 28, 2001