next up previous
Next: About this document ... Up: lab_template Previous: lab_template

Subsections


MA 1024: Surfaces

Purpose

The purpose of this lab is to introduce you to some of the Maple commands that can be used to plot surfaces in three dimensions.

Background

For functions of two variables in Cartesian coordinates, the graph is a set of points $(x,y,f(x,y))$ in three-dimensional space. For this reason, visualizing functions of two variables is usually more difficult.

One of the most valuable services provided by computer software such as Maple is that it allows us to produce intricate graphs with a minimum of effort on our part. This becomes especially apparent when it comes to functions of two variables, because there are many more computations required to produce one graph, yet Maple performs all these computations with only a little guidance from the user.

The simplest way of describing a surface in Cartesian coordinates is as the graph of a function $z = f(x,y)$ over a domain, e.g. a set of points in the $xy$ plane. The domain can have any shape, but a rectangular one is the easiest to deal with. Another common, but more difficult way of describing a surface is as the graph of an equation $F(x,y,z) = C$, where $C$ is a constant. In this case, we say the surface is defined implicitly. A third way of representing a surface $z = f(x,y)$ is through the use of level curves. The idea is that a plane $z=c$ intersects the surface in a curve. The projection of this curve on the $xy$ plane is called a level curve. A collection of such curves for different values of $c$ is a representation of the surface called a contour plot. Similar to the idea of level curves is to look at cross sections of the surface to see what two-dimensional shape is traced, not only in the $xy$ plane by letting $z$ be constant, but also in the $yz$ plane by holding $x$ constant and the $xz$ plane by holding $y$ constant.

Defining Functions of Two Variables

Defining functions of two variables in Maple is very similar to the way it is done for functions of one variable - just remember the parentheses.

>f:=(x,y)->x^2+y^2;
Evaluating the function at a specific (x,y) value is easy:
>f(3,1);

Plotting Three-dimensional Surfaces

The plot3d command is similar to the plot command except the domain has both x and y values.However, there is a lot more you can do with plot3d. First try moving the plot by clicking and dragging. Also, a menu of options will appear if you right click on the graph.

>plot3d(f(x,y),x=-2..2,y=-2..2);
Instead of using the right-click menu you can put the options into the plot command.
plot3d(f(x,y),x=-2..2,y=-2..2,scaling=constrained,axes=boxed,color=magenta);

Cross Sections

The easiest way to get cross sections (parallel to the x-y plane) is to use the Maple command contourplot which is included in the package plots. The following command will show 15 cross sections using z-values that the computer will choose.

>with(plots):
>contourplot(f(x,y),x=-2..2,y=-2..2,contours=15);
Thefollowing command will show 4 cross sections using z-values that you choose.
>contourplot(f(x,y),x=-2..2,y=-2..2,contours=[-1,0,1,2]);
In the above commands the z-value was held constant thus giving a two-dimensional plot. You can hold x or y constant to get a cross section perpendicular to the y-z or x-z plane. To get these cross sections use the plot command.
>plot(f(5,y),y=-2..2,labels=[y,z]);
Note how easy it is to hold the x (or y) constant when you have entered a function, f(5,y). Also note that the axes were labeled to emphasize what the two remaining variables are. Next is an example of four contours parallel to the x-z plane.
>plot({f(x,-1),f(x,0),f(x,1),f(x,2)},x=-2..2,labels=[x,z]);

Partial Derivatives

The Maple commands for computing partial derivatives are D and diff. The diff command can be used on both expressions and functions whereas the D command can be used only on functions. The commands below show examples of first order and second order partials in Maple.

> f := (x,y) -> x^2*y^2-x*y;
> diff(f(x,y),x);
> diff(f(x,y),y,y);
> D[1](f)(x,y);
> D[2,2](f)(x,y);
Note in the above D command that the 1 in the square brackets means x and the 2 means y. The next example shows how to evaluate the mixed partial derivative of the function given above at the point $\displaystyle (3,-1)$.

> eval(diff(f(x,y),x,y),{x=3,y=-1});
> D[1,2](f)(3,-1);

The tangent plane for explicitly defined surfaces

The tangent plane like the tangent line to a single variable function is based on derivatives, however the partial derivatives are used for the tangent plane. Let's start with the equation of the tangent line to the function $\displaystyle f(x)$ at the point where $\displaystyle x=a$. Recall, the general equation of a line at the point $\displaystyle (a,f(a)$ having slope $\displaystyle m$ is $\displaystyle y-f(a) = m(x-a)$. This can be rewritten knowing that the derivative is the slope of a tangent line as $\displaystyle y = f'(a)(x-a) + f(a)$. Similarly for a funcion of two variables, the equation of the plane tangent to $z = f(x,y)$ at the point $(a,b)$ has the equation $\displaystyle z = f_x(a,b)(x-a)+f_y(a,b)(y-b)+f(a,b)$. The following examples will show you how to find the tangent plane to the function $\displaystyle f(x,y)=\frac{1}{1+x^2+y^2}$ at $\displaystyle
(\frac{1}{8},\frac{1}{4})$. You could write the partials with diff or D. This example uses D as it is easier to plug in the the point with this syntax; with diff, the eval or subs command would be used.

> f:=(x,y)->1/(1+x^2+y^2);
> tp:=D[1](f)(1/8,1/4)*(x-1/8)+D[2](f)(1/8,1/4)*(y-1/4)+f(1/8,1/4);
> plot3d({f(x,y),tp},x=-1..1,y=-1..1);

Exercises

  1. Generate a surface plot with boxed axes and contour plot with 22 contours for the following function on the given domain:

    \begin{displaymath}f(x,y) = (x^2-y^2)e^{(-x^2-y^2)},   -3\leq x \leq 3,   -3\leq y\leq 3 \end{displaymath}

    A
    Describe the difference in proximity between the contour lines in the regions where the surface plot has a steep incline compared to where the surface plot is almost flat?
    B
    What does the contour plot look like in regions where the surface plot has local extrema?
    C
    Estimate the local maximum and minimum by rotating the 3-dimensional plot and state your estimations in text.
    D
    Evaluate the funtion at all four $(x,y)$ coordinate pairs for approximately where the contourplot indicates a local extrema to see if your estimates were close.

  2. Compute the two first order and three distinct second order partial derivatives of

    \begin{displaymath}f(x,y)=\frac{\sin(x+y)}{(1+y^2)} \end{displaymath}

    at the point $(-1,1)$ using the diff command and then again using the D command.

  3. Given:

    \begin{displaymath}f(x,y)=\frac{3x^2}{5}+\frac{2y^2}{3}+1 \end{displaymath}

    Find the plane tangent to the given surface at $(0.2,-0.3)$. Plot the surface $f(x,y)$ and the tangent plane on the same graph and rotate the 3-D plot to show the point of tangency. Use plotting ranges $-1 \leq x \leq 1$ and $-1 \leq y \leq 1$.

next up previous
Next: About this document ... Up: lab_template Previous: lab_template
Dina J. Solitro-Rassias
2018-09-05