|
![]() |
Relief Functions and Level Curves
Purpose
Background One problem that comes up again and again in engineering and science is how to graphically represent functional relationships between more than two variables. The basic problem is one of trying to represent objects in three (or more) dimensions as two-dimensional plots. You may already have experience with Maple's plot3d command which allows you to view a two-dimensional representation of a surface in three dimensions from various angles. This is not the only representation method, however. Another extremely useful method involves plotting what are known as the contours or level curves. Suppose z = f(x, y) is the equation of a surface in three dimensions and C is a constant. The solution of the equation f(x, y) = C can be visualized graphically by plotting the function together with the plane z = C. The curve generated by this intersection is often referred to as a level curve. Note that this curve lies on the surface. For example, the intersection of the two surfaces displayed by the Maple command > plot3d({x^2 + y^2, 4}, x=-3..3, y=-3..3, style=patch, axes=boxed, labels=[x,y,z]); ![]() would be the solution of the equation x2 + y2 = 4. There are several cases where it is important to be able to find the curves f(x, y) = C as the parameter C is varied, including the following
In fact, drawing the contours of a function z = f(x, y) in the xy plane is a way of representing a surface in two dimensions. That is, given the contour lines, you should be able to reconstruct the surface and vice-versa. There are several ways you can get Maple to generate the contours on a plot. One way is with the style=contour option when using the plot3d command as in the following example. > plot3d(x^2 + y^2, x=-3..3, y=-3..3, style=contour, axes=boxed, labels=[x,y,z]); ![]() However, it is probably easier to generate the contours after you have used plot3d to render the surface, by using the Contour or Patch and contour options in the Style menu on the Maple 3D plotting window. One thing to note is that Maple plots the contours right on the surface. Usually, by a contour plot, one means the projection of the contour curves onto the xy plane. To see this in Maple, just view the plot from above or below; that is, along the z axis. Alternatively, you can use the contourplot command which produces a 2D plot. This command is preferable unless you specifically want to see the contour lines plotted on the surface.
Examples
> with(plots): We first define a function of two variables > F := (x,y) -> -(x^2 + y^2); ![]() then use plot3d to see this 3-dimensional graph. > plot3d(F(x,y), x=-1..1, y=-1..1, axes=framed, style=patch, title=`z = F(x, y)`, labels=[x,y,z]); ![]() To see level curves of this function, we can use the contourplot command. > contourplot(F(x,y), x=-1..1, y=-1..1, title=`Level curves of z = F(x, y)`); ![]() If we want to view one specific level curve, that is, where z is fixed, we can specify that value in contourplot. In this example, we fix z = -0.5. > contourplot(F(x,y), x=-1..1, y=-1..1, title=`F(x, y) = -0.5`, contours=[-0.5]); ![]() In order to display this curve and the plot of the original function on the same graph, we must convert the above 2D curve into 3D curve. (display only allows you to combine plots having the same dimension) We can do this by creating a function that transforms a 2D plot into a 3D one. Be sure to load the plottools package before issuing the following commands.
> level_plot := contourplot(F(x,y), x=-1..1, y=-1..1, color=black, thickness=2, contours=[-0.5]): ![]() An alternative (and easier) way to accomplish the same result is to use contourplot3d instead of contourplot. This will produce a contour plot in 3D without requiring you to perform a conversion. The following commands are equivalent to those above.
> level_plot := contourplot3d(F(x,y), x=-1..1, y=-1..1, color=black, thickness=2, contours=[-0.5]): Remember, you can get help at any time on a topic by using a question mark followed by the command name. > ?contourplot You should read through the help on contourplot by issuing the above command to find out how to utilize many of the options available. For example, you can either specify the number of equally spaced contour lines to display or choose exactly which values to use. > contourplot(F(x,y), x=-1..1, y=-1..1, title=`Level curves of F(x, y) = -.2, -.7 and -1`, contours=[-0.2, -0.7, -1]);
![]()
Exercises
|
![]() |