next up previous
Next: About this document ... Up: Labs and Projects for Previous: Labs and Projects for


Advanced 3D Graphing and
Applied Extremal Problems


There are many practical situations in which it is necessary or useful to know the largest and smallest values of a function of more than one variable. The present lab is composed to give you experience in applying both Calculus and graphing techniques relating to finding extrema of functions of two variables. In a sense of graphing, this Lab is a sort of continuation of the previous one; it addresses more powerful Maple tools for 3D representation.


Theoretical Remarks

For some relatively simple functions of two variables, it is not difficult to determine their relative extrema by first finding the critical point and then applying the Second Partial Test (SPT) to discriminate among relative maxima, relative minima, and saddle points.

A brief account of the relevant theory is given in the text (Section 15.8). The corresponding Theorem establishes that if the function is differentiable, then (x0,y0) is a critical point if $\nabla f(x_0,y_0) = 0$. With
D = f_{xx}(x_0,y_0)f_{yy}(x_0,y_0) - [f_{xy}(x_0,y_0)]^2 ,\end{displaymath}\end{maplelatex}
the SPT is as follows:

If D > 0 and fxx(x0,y0) > 0, then f has a relative minimum at (x0,y0);

If D > 0 and fxx(x0,y0) < 0, then f has a relative maximum at (x0,y0);

If D < 0, then (x0,y0) is a saddle point of f;

If D = 0, then the test is inconclusive.

Many applications associated with functions of two variables can be studied by purely analytical means, but some contemporary software and computer algebra system might be of substantial help in gaining further insight or obtaining information that cannot be found analytically. In this way, Maple offers a variety of excellent opportunities.

Maple Commands and Options

In order to implement the SPT by Maple means, you may use diff, solve, and fsolve commands. To find critical points, the grad command appears to be the most convenient. (The example of their use is given in the Example of Problem 2.) Along with special tools for 3D visualization, these commands represent major Maple means for efficient and comprehensive studying of functions of two variables with minima and maxima.

Although plotting in R3 bears many similarities to the corresponding process in R2, these similarities are rather superficial. It can be difficult to achieve a convincing representation of a 3-dimensional object on a 2-dimensional screen. Thus in the case of 3D graphics, the optional arguments used within main plotting commands have more significant impact on the final result than they have in the 2D case. An incorrect use of perspective can produce distortion to the shape we want to graph. Maple plotting options also allow control of color and lighting, and their wrong use can hide or exaggerate certain features of plotted objects. Consequently, when dealing with 3D plotting, these topics require as much attention as the syntax of Maple commands.

The most important command in 3-dimensional graphics is the plot3d command already used in Lab 3. The purpose of this command is to draw surfaces that can be parameterized by two parameters varying over a region in the plane. Generally, the plot3d command is written as

plot3d (formula, range of variable1, range of variable2, options); (1)

All explicitly given surfaces we can plot in Maple are defined via a math formula depending on 2 variables. In (1), formula may be either a single real-valued expression depending on these two variables (non-parametric plot), or a list of three such expressions (parametric plot). Their ranges are specified similarly to 2D graphics:

x = a..b, y = c..d

In the case of a non-parametric plot, y-range can depend on x, or to be x-dependent, so if c and d are not constant, the region appears to be non-rectangular.

For instance, try the following examples (either typing the commands directly, or starting them from the Getting Started Worksheet):

  > plot3d([y*cos(4*x), 2*x, sqrt(y)], x=0..Pi, y=0..2*Pi); 
  > plot3d(y*cos(4*x), x=0..Pi, y=-sin(x)..sin(x));

By definition, options in (1) may be omitted; by doing so, we allow Maple to substitute some default values which in certain cases provide satisfactory representation. In many situations, however, mastering the options favors the efficient computer analysis.

Two options (grid and orientation) were used when graphing in 3D in Lab 3. The following list adds several other options; most of them can be used also with other 3D Maple graphics commands. Some can be assessed via the task bar, but putting them into command produces the same plot every time the command is executed.

axes=N - The option determines how and whether the coordinate axes are drawn; N can be assigned one of the following values: BOXED, FRAMED, NORMAL, or NONE (the default).

color=N - The value N determines the color of the plot. It can be one of the following: the name of a color, COLOR(RGB,R,G,B), or COLOR(HUE,H), where R, G, B, and H are numbers between 0 and 1. The number H defines the hue of the color whereas the numbers R, G, and B correspond to the red, green, and blue components, respectively, of the chosen color. More importantly, colors can be controlled by functions, that is, N can be a single expression H or a list of three expressions R, G, and B, usually written in terms of the plot variables. If a single expression is used, its values control the hue of a color (at maximum saturation and brightness). If three expressions are used, they control the red, green and blue components of the color. If the range of the second variable involved in the plot depends on the first variable, only the first variable may be used in a color function. Among the allowed color names are:

blue, brown, cyan, gold, gray, magenta, navy, orange, pink, red, violet, yellow, etc.

contours=N - If N is a positive integer, it determines how many contours are to be drawn; the default is 8. This option works only in conjunctions with style=contour option.

coords=N - Allows the user to choose between various coordinate systems by replacing N with the name of a coordinate system - cartesian, spherical, cylindrical or any of 30 predefined in Maple (see help for details); the default is rectangular.

label=[stringx, stringy, stringz] - By default, there are no axis labels, but these labels can be specified by any character strings.

scaling=N - The parameter N can assume one of two values: constrained or unconstrained (the default). If unconstrained scaling is applied, Maple tries to fit the plotted object into the plot area. This often results in scaling the plot differently in the 3 directions of the 3 axes. Constrained scaling preserves the natural proportions.

style=N - Specifies how the surface is to be plotted. The value of N can be one of the following: point, hidden, patch (the default), wireframe, contour, patchnogrid, patchnocontour, line.

view=[${\bf x_1..x_2,y_1..y_2,z_1..z_2}$] - If this option is invoked, only the part of the plotted object is contained within the cuboid defined by the xyz-ranges ${\bf x_1..x_2,y_1..y_2,z_1..z_2}$ will be displayed. An alternative is to use the option view=[${\bf z_1..z_2}$], in which case only the points of the plotted object whose z-coordinate is between z1 and z2 will be shown. (A cuboid containing the entire plotted object is the default.)

The setoptions3d command allows the user to set the default options for 3D plots in a worksheet. Its syntax is as follows:

setoptions3d (options separated by commas);

More detailed description of these options as well as some others (light, view, etc.) can be found in help.

A reminder: some of the graphics commands in Maple are loaded into memory automatically; others (for example, sphereplot) have to be loaded with the command

  > with(plots):
which invokes the plots package. To learn about the plot package, one can execute the command:
  > ?plots;

Problem 1


In order to feel the powerful and flexible capacity of the plot3d command and other relevant Maple tools, it is recommended that you study the following examples.

(a) Curvature vs Color

  > f := (x,y) -> sin(3*x)*sin(3*y):
  > MC := z -> ((1+diff(z,y)^2)*diff(z,x,x)
- 2*diff(z,x)*diff(z,y)*diff(z,x,y) + 
(1 + diff(z,x)^2)*diff(z,y,y))/(1 + diff(z,x)^2 + 
  > plot3d(f(x,y), x=0..Pi, y=0..Pi, color=[MC(f(x,y)), .6, .5],
  ambientlight=[.9, .6, .2], light=[70, 50, .9, .6, .2], 
orientation=[33, 23],grid=[69, 69]);

(b) Rose in Spherical Coordinates
  > setoptions3d(style=patchnogrid, scaling=constrained, projection=.5);
  > f := [cos(3*y)^2 - sin(x)-sin(y), x+1, y+1]:
  > c := [1, cos(6*y)^2 - sin(x) - sin(y), .3:
  > sphereplot(f, x=0..1*Pi, y=-1*Pi..1*Pi, color=c, ambientlight=[.6,.6,.6],
  light=[90,45,.8,.7,.6], orientation=[175,90], grid=[100,100]);

(c) Pear & Apple

  > setoptions3d(style=patchnogrid, scaling=constrained, projection=.5);
  > Xa := (4 + 3.8*cos(y))*cos(x):
  > Ya := (4 + 3.8*cos(y))*sin(x):
  > Za := (cos(y) + sin(y) - 1)*(1 + sin(y))*log(1 - Pi/10*y) +
  > apple := plot3d([Xa, Ya, Za], x=-Pi..Pi, y=-Pi..Pi,
  color=[sin(x + 1) + cos(y), sin(y), .3], ambientlight=[.5, .5, .5],
  light=[85, 50, .6, .8, .2], grid=[59, 59]):
  > Xp := (4 + 3.8*cos(y))*cos(x):
  > Yp := (4 + 3.8*cos(y))*sin(x):
  > Zp := ((cos(y) - 3.5)*(1 + sin(y))*log(1 - Pi/10*y) + 10*sin(y))*
  (1 - .4*cos(.5*y)*(1 + .2*sin(y^2))):
  > pear := plot3d([Xp, Yp - 17, Zp], x=-Pi..Pi, y=-Pi..Pi,
  color=[cos(y) + sin(y), cos(y) + sin(y) + .5*sin(x + 3), .3],
  view=-9..16.5, grid=[59, 59]):
  > display(apple, pear, orientation=[-3, 67]);


Run Examples (a), (b), (c) with the original options, and then try changing the options grid, orientation, and others in the list. Comment briefly on your major observations regarding each option and answer the following questions:

NOTE: You may avoid typing these sets of commands by using the Getting Started Worksheet attached to this lab; the texts are already there.

Experiment with various graphing techniques used in these examples in order to obtain different graphical representations of the surface
f(x,y) = \displaystyle\frac{\sin x \sin y}{1 + x^2 + y^2},\;\; -3 < x < 3,\;\;
-3 < y < 3.\end{displaymath}\end{maplelatex}

Check with various orientations, styles and colors; create the most representative graph, and argue in the favor of your choice. Plot the same function in other (spherical and cylindrical) coordinate systems; give a qualitative explanation why the graphs look so different.

Problem 2

Preliminary Remarks

Extrema of functions of several variable are important in numerous applications in engineering, economics, and business, where particularly valuable variables are profit, revenue, and cost. Practical profit problems usually involve several models of one type of product, with process per unit and profits per unit varying from model to model, and demand for each model which is a function of the price of the other models as well its own price, etc.

Radio location of any type deals with a reflected signal that is the function of coordinates of an object. Examples include such things as traditional location of aircrafts and other military targets, remote sensing, detecting mines and other subsurface objects.


Assume the function f(x,y) = -x3 + 4xy - 2y2 + 1 describes some applied process. To find its relative extrema, first find the critical points by determining fx(x,y) = fy(x,y) = 0. Solving these equations analytically leads to the two critical points (0,0) and (4/3,4/3). Applying the SPT to the critical points, you find that (0,0) corresponds to a saddle point of f, whereas f has a relative maximum at (4/3,4/3).

The following Maple commands allow one to determine the gradient of function
f(x,y) = (x^2 + 4y^2)e^{(1-x^2-y^2)}:\end{displaymath}\end{maplelatex}

  > f:=(x,y)->(x^2+4*y^2)*exp(1-x^2-y^2);

f := (x,y)\rightarrow (x^2 + 4y^2) \exp(1 - x^2 - y^2)\end{displaymath}\end{maplelatex}
  > with(linalg):
  > gradf:=(x,y)->grad(f(x,y),[x,y]);

gradf := (x,y)\rightarrow grad(f(x,y), [x,y])\end{displaymath}\end{maplelatex}
  > solve({gradf(x,y)[1]=0, gradf(x,y)[2]=0}, {x,y});

\{y = 0, x = 0\},\;\;\{y = 1, x = 0\},\;\...
 ... 0\},\;\;\{x =
1, y = 0\},\;\;\{x = -1, y = 0\}\end{displaymath}\end{maplelatex}
  > gradf(x,y);

\begin{displaymath}[2x \%1 - 2(x^2 + 4y^2)x \%1,\;\; 8y \%1 - 2(x^2 + 4y^2)y \%1]\end{displaymath}\end{maplelatex}

\%1 := exp(1 - x^2 - y^2)\end{displaymath}\end{maplelatex}


An aircraft equipped with a special electronic system for remote sensing of ground does some work in Iowa during Spring for agricultural purposes. It flies above the plantations and measures the moisture of soils. Since crops may be planted only if the contents of water in soil is less than some specific value wm, the areas possessing excessive moisture have to be specified, and planting there should be postponed.

The measurement is made with the use of special wide-angle scan receiving antenna array able to gather information from a rectangular region R. After appropriate digital processing, the distribution of moisture over the region appears in the form of point-by-point database which after electronic spline interpolation is described in the analytical form available for its further analysis by a built-in processor.

Assume this form appears to be:
W(x,y) = \mid \sin 3y + \cos(\ln2x)\mid,\end{displaymath}\end{maplelatex}

where x and y are rectangular coordinates of points in the measured region (x > 0, y > 0).

Find the gradient of the function W(x,y) and use the SPT and find the coordinates of the maxima in the area $R = 2 \times 3$ mi.
Represents the distribution of the moisture over this area visualizing the function W(x,y) in R3. Putting the wider side along the x-axis, make sure that the extrema found analytically in (a) correspond to the top points of the upper areas of the 3D graph.

Manipulating with the 3D representation of the graph (particularly, the orientation option), specify the areas in the R where the normalized moisture exceeds wm = 1. From the graph, provide the approximate coordinate description of these areas. (The use of option view is recommended.)

Problem 3

Preliminary Remarks

Extrema problems in more than one variable are usually quite complicated, and their solution may require simplifying approximations, a measure of ingenuity, numerical computations, etc. These are typical characteristics of practical problems which bear little resemblance to the routine textbook minima/maxima exercises.

The problem outlined below brings one a little closer to reality. It is considered from initial formulation to final mathematical statement. Perhaps at least the flavor of the real applied extreme analysis can be conveyed in this problem.

Example & Exercise

Bonnie & Clyde, a newly married couple of college graduates, intend to settle in a part of the country where they will see their respective parents as little as possible each year. The newlyweds decide to use their Calculus knowledge to specify the position of their home. (Figure out their reasoning in this exercise, but think hard whether it is worthwhile to follow their example in real life.)

They find that even in a simple but plausible model various ideas can be explored and tested. A reasonable assumption suggests that a number of visits per year and the length of each in days are correlated with the travel distance involved. If the travel distance is great, visits will be few in numbers but of extended duration.

As the result of thought and trial and error, they assume that the number of visits per year V by either set of parents is approximated by the simple relationship:
V = 1 + \displaystyle\frac{1000}{L},\end{displaymath}\end{maplelatex}
where L is the distance between the parents and their child (obviously, L is not 0, since the young couple has no intention of living in the same house with their parents).

For the duration D of each visit, they find the following formula:
D = \displaystyle\frac{1}{20}\left(1 + \displaystyle\frac{L}{10} \right).\end{displaymath}\end{maplelatex}
Thus the number N of days per year that either set of parents will visit is approximately:
N = DV = \displaystyle\frac{1}{2}\left(10 + l +
where l = L/100 is the new scaling distance.

Supposing that the distance from their supposed home to Bonnie's parents' house is l1 and to Clyde's parents' house is l2, the newlyweds establish a coordinate system as follows: x-axis passes through the homes of the parents, and the origin is situated at the midpoint of the line segment of length 2a that connects these positions, and point P(x,y) becomes the possible homesite of the young couple.

The total number of days per year that they can expect to see the parents of both is therefore the sum of the days each one will be visiting:
T(x,y) = \displaystyle\frac{1}{2}\left(10...
 ...ft(10 + l_2 +
l_1^2 = (x - a)^2 + y^2;\;\; l_2^2 = (x + a)^2 + y^2,\end{displaymath}\end{maplelatex}

It remains to find the relative minima of the function T(x,y). Clearly, the coordinates (x,y) providing these minimal values of T(x,y) will specify the possible positions of Bonnie & Clyde's home.

Unfortunately, at this point, the newlyweds recognize that neither of them took Calculus IV in college and thus don't know how to find the minimum value of a function of two variables. So help them do the following:

Give an appropriate interpretation to the fact that two cases should be considered:
a < 1, and
a > 1.
For both (i) and (ii), compute the gradient of the function T(x,y) and then apply the SPT to find its minima.

Again, for both (i) and (ii), find the extrema by 3D graphing the function T(x,y). Compare the results.

NOTE:Color graphs could be a nice supplement for your report. However, the color printing is not required. If you provide monochrome illustrations, make sure that appropriate comments on any relevant color features involved appear in your text.


Examples of 3D plotting used in Problem 1 have been borrowed from Discovering Curves and Surfaces with Maple, by G.Klimek, M.Klimek, Springer Verlag, New York, 1997.
The idea and the model of the Exercise in Problem 3 have been suggested by H.P. Greenspan, D.J. Benney, & J.E. Turner.

next up previous
Next: About this document ... Up: Labs and Projects for Previous: Labs and Projects for

Christine Marie Bonini