Contour Plots

The interactive version of this worksheet is in the Math 210 folder in the Workspace volume in MSB 203. (For instructions on accessing it remotely, refer to the Space Curves worksheet.)

Maple can generate plots of level curves and surfaces for functions of two and three variables, The syntax is similar to Mathematica's. The following routine illustrates this for the function : ® with formula . To execute the plot, position the cursor after the last line of code, and press the Enter key at the lower right of the keyboard.

> with(plots):
f := (x, y) -> x^2 + y^2:
contourplot( f(x, y), x = -4..4, y = -4..4 );

Note that the curves, which of course are circles with center at the origin, appear to be elliptical. This is due to different scaling on the two coordinate axes. To correct that, Maple has a plotting option
scaling = constrained , which forces identical scales on the coordinate axes. To apply it to the above plot, simply add that option to the contourplot command:

> with(plots):
f := (x, y) -> x^2 + y^2:
contourplot( f(x, y), x = -4..4, y = -4..4, scaling = constrained);

There is another plotting command of this type:
densityplot . It produces a grayscale graph, the lighter areas of which correspond to function values of larger size. This can be useful in estimating whether a function has a discontinuity near a point (a, b, f(a, b)) . The following routine illustrates the discontinuity of the function g whose value is , for and whose value at the origin is 0. (Note that as (x, y) approaches the origin along or near the y -axis, the values of the function are much larger than those along the x -axis.)

> with(plots):
g := (x, y) -> piecewise(x <> 0 or y <> 0,(x^2 + y^3)/(x^2 + y^2), 0);
densityplot( g(x, y), x = -1..1, y = -1..1, grid = [25, 25] );

Three-dimensional contour plots.

Maple can also give a three-dimensional plot of the graph of a function
f : ® , and display the level curves at their various z -heights in three-space. To make such a plot, use the three-dimensional contourplot3d command. The following routine illustrates this command, which notice is fundamentally different from the corresponding command in Mathematica. (That gives plots of level surfaces of functions of three variables.)

> f := (x, y) -> x^2 + y^2 ;
contourplot3d( f(x, y),x = -5..5, y = -5..5, color = blue, labels = ["x", "y", "z"], axes = boxed);

>