A First Surface Plot in Maple
Copyright © 1998, 1999, 2001 by James F. Hurley, University of Connecticut Department of Mathematics, Unit 3009, Storrs CT 06269-3009. All rights reserved.
Maple's powerful three-dimensional graphics can produce high-resolution plots of surfaces in . Real-time rotation of such plots is easy, and reveals the shape and geometry of the surfaces. The following short routine illustrates basic plotting of the graph of a function : ® . The steps to carry out the plot:
¥ call the Maple plots library. The command with(plots): loads all plotting tools,
without listing them all. (The colon suppresses output from the command.)
¥ define the function f. Maple does that via the symbolic notation ( x, y) ® f ( x, y ) .
¥ use the command plot3d(f(x,y), x = a..b, y = c..d) to plot the function over
a rectangle [ a, b ] ´ [ c, d ] in the xy -plane. The specification axes = boxed surrounds the
plot with a box showing the three coordinate axes and tick marks.
To generate a plot, position the cursor after the last line of code, and press the Enter key (located at the lower right of the keyboard). Try that with the routine below, to genreate the graph of the function f with formula f ( x , y ) = .
f := (x, y) -> y^2 + 4;
plot3d( f(x, y), x = -3..3, y = -3..3, axes =boxed, labels = ["x", "y", "z"] );
If you click on the plot, bounding lines appear around it, as well as a new plotting menu bar and a new context bar at the top of the screen. Depresssing the mouse button and draging the mouse rotates the graph to allow viewing from any angle. Try it! (The above image resulted from such rotation of Maple's default plot.)
The following enhanced version of the basic routine adds coordinate axes and labels (magenta in color) to the plot at their actual positions in . The result looks similar to textbook graphs, so you can use this routine to recreate those, and explore them further. Try that with the plot that the next routine generates. Since a colon at the end of a command suppresses output, nothing appears until all the elements have been created. Then Maple display s them all in a single image.
f := (x, y) -> y^2 + 4:
surf := plot3d( f(x, y), x = -3..3, y = -3..3, axes = boxed ):
xaxis := spacecurve([t, 0, 0, t = -3..3, color = magenta]) :
yaxis := spacecurve([0, t, 0, t = -3..3, color = magenta]) :
zaxis := spacecurve([0, 0, t, t = -3..10, color = magenta]) :
labx := textplot3d([3.8, 0, -.2, `x`], color = magenta):
laby := textplot3d([0,3.8, -.2, `y`], color = magenta):
labz := textplot3d([0, 0, 12, `z`], color = magenta):
display(surf, xaxis, yaxis, zaxis, labx, laby,labz);
Warning, the name changecoords has been redefined
A more complicated surface.
The last plot of this worksheet is of the graph of the function f whose value at any point ( x, y ) other than (0, 0) is and whose value at (0, 0) is 0. (Compare with the cover of Multivariable Calculus , Saunders College Publishing, 1981.) The command grid = [30,30] produces a smoother plot with more detail than the default 25-by-25 point sampling. (To see the effect, remove the grid command and generate a plot.)
g := (x, y) -> piecewise(x <> 0 or y <> 0,(x^3*y - x*y^3)/(x^2 + y^2), 0):
plot3d(g(x, y), x = -3..3, y = -3..3, grid = [30,30], axes = boxed);