** Next:** About this document ...
**Up:** Labs and Projects for
** Previous:** Labs and Projects for

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.

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 (*x _{0}*,

the SPT is as follows:

If *D* > 0 and *f*_{xx}(*x _{0}*,

If *D* > 0 and *f*_{xx}(*x _{0}*,

If *D* < 0, then (*x _{0}*,

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.

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 *R ^{3}* bears many similarities to the corresponding process in

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=[string _{x}, string_{y}, string_{z}]` - 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=[]` - If this option
is invoked, only the part of the plotted object is contained within
the cuboid defined by the *xyz*-ranges will be displayed. An alternative is to use the
option `view=[]`, in which case only the points of the
plotted object whose *z*-coordinate is between *z _{1}* and

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;

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 + diff(z,y)^2)^(3/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]);

> 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]);

> 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) + 7.5*sin(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]);

- 1.
- 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:
- How the curvature at various points of the surface in (a) is represented by color?
- What does the
`ambientlight`option do in (b)? - What options make the fruits in (c) look so natural?

**NOTE:**You may avoid typing these sets of commands by using the Getting Started Worksheet attached to this lab; the texts are already there. - 2.
- Experiment with various graphing techniques used in these examples in
order to obtain different graphical representations of the
surface

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.

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*) = -*x ^{3}* + 4

The following Maple commands allow one to determine the gradient of function

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

> with(linalg):

> gradf:=(x,y)->grad(f(x,y),[x,y]);

> solve({gradf(x,y)[1]=0, gradf(x,y)[2]=0}, {x,y});

> gradf(x,y);

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 *w*_{m}, 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:

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

- (a)
- Find the gradient of the function
*W*(*x*,*y*) and use the SPT and find the coordinates of the maxima in the area mi. - (b)
- Represents the distribution of the moisture over this area visualizing
the function
*W*(*x*,*y*) in*R*. Putting the wider side along the^{3}*x*-axis, make sure that the extrema found analytically in (a) correspond to the top points of the upper areas of the 3D graph. - (c)
- Manipulating with the 3D representation of the graph (particularly, the
`orientation`option), specify the areas in the*R*where the normalized moisture exceeds*w*_{m}= 1. From the graph, provide the approximate coordinate description of these areas. (The use of option`view`is recommended.)

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.

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:

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:

Thus the number *N* of days per year that either set of parents will
visit is approximately:

where *l* = *L*/100 is the new scaling distance.

Supposing that the distance from their supposed home to Bonnie's parents'
house is *l _{1}* and to Clyde's parents' house is

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:

where

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:

- (a)
- Give an appropriate interpretation to the fact that two cases should be
considered:
- (i)
*a*< 1, and- (ii)
*a*> 1.

- (b)
- For both (i) and (ii), compute the gradient of the function
*T*(*x*,*y*) and then apply the SPT to find its minima. - (c)
- 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.

- 1.
- 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. - 2.
- The idea and the model of the Exercise in Problem 3 have been suggested by H.P. Greenspan, D.J. Benney, & J.E. Turner.

4/13/1999