**Investigating Extreme Values in Maple**

**Copyright © 2001 by James F. Hurley, University of Connecticut Department of Mathematics, Unit 3009, Storrs CT 06269-3009. All rights reserved.**

The interactive version of this worksheet is in MSB 203 (g3server) in the Workspace volume. For instructions on how to access it remotely, see the
*Space Curves *
worksheet.

Plotting the graph of a function
:
** **
®
** **
usually reveals the approximate location of local extreme-value points. A local-maximum point is at the
*peak*
of a region of the graph that resembles a mountain. Similarly, a local-minimum point is at the
*pit*
of a portion of the graph that resembles a deep valley. Finally, saddle points are often in what appears to be a
*pass*
between two mountains. Exercise 3, Section 15.7, from James Stewart,
*Calculus, 4th Editon*
, ITP Brooks/Cole, 1999) illustrates Maple's ability to check partial differentiation of
*f*
and solution of the equation
**Ñ**
*f*
(
*x*
,
*y*
) =
**0,**
and its use to confirm the nature of stationary points graphically.

**Example 1**
. Consider the function
*f*
for which
*f*
(
*x, y) = *
. Find all stationary points, and classify each as a local-maximum point, a local-minimum point, or a saddle point.

**Solution. **
While it is good practice to carry out all differentiation by hand (to build facility for exams and later use of multivariable calculus), you can use Maple to check such hand calculations. For instance, the next routine checks the calculation of the partial derivatives of
*f*
with respect to
*x*
and
*y*
.
** **

Note that for Maple to handle vectors, such as
**Ñ**
*f*
(
*x*
,
*y*
)
, you use its linear algebra library
linalg
. Also notice that vectors are entered within pointed brackets but with vertical bars rather than commas between coordinates. To compute partial derivatives, use the commands
diff(f(x, y), x)
and
diff(f(x, y), y)
.
Observe also that Maple won't display the formulas it calculates unless you include the additional command to evaluate the gradient vector:
evalf(grad_f(x, y));

`> `
**with(linalg):
f := (x, y) -> 4 + x^3 + y^3 - 3*x*y;
grad_f := (x, y) -> < diff(f(x, y), x) | diff(f(x, y), y) >;
evalf(grad_f(x, y));
**

As you can see, Maple indeed calculates
(
*x*
,
*y*
) and
(
*x*
,
*y*
), and displays them in a vector surrounded by standard brackets. To find the stationary points of
*f*
, solve the equations
(
*x*
,
*y*
) = 0 and
(
*x*
,
*y*
) = 0 for
*x*
and
*y*
. You can check the stationary points found by hand ((0, 0) and (1, 1)) by having Maple solve the vector equation
**Ñ**
*f*
(
*x*
,
*y*
) =
**0**
= < 0, 0 >. The next routine illustrates this. Try it!

`> `
**f_x := (x, y) -> diff(f(x, y), x);
evalf(f_x(x, y));
f_y := (x, y) -> diff(f(x, y), y);
evalf(f_y(x, y));
solve({evalf(f_x(x, y))= 0, evalf(f_y(x, y))= 0});**

Notice that Maple is not limited by the fact that calculus seeks only real solutions! Besides the confirming the accuracy of the hand solution that found the pairs (0, 0) and (1, 1) of real roots, it also found floating-point approximations to two complex solutions, which are safe to ignore.

Although we could have Maple use the second-derivative test on the points (0, 0) and (1, 1), it is easier to plot the graph of
*f*
, and examine that near the two stationary points. The next routine generates that graph over
*R*
= [
]
´
[
] = {(
*x*
,
*y*
) | -1 ²
*x *
² 2, -1 ²
* y *
² 2}.

`> `
**with(plots):
f := (x, y) -> 4 + x^3 + y^3 - 3*x*y:
surf := plot3d( f(x, y), x = -1..2, y = -1..2, axes = boxed ):
xaxis := spacecurve([t, 0, 0, t = -1..2, color = magenta]) :
yaxis := spacecurve([0, t, 0, t = -1..2, color = magenta]) :
zaxis := spacecurve([0, 0, t, t = -1..15, color = magenta]) :
labx := textplot3d([2.2, 0, -.2, `x`], color = magenta):
laby := textplot3d([0,2.2, -.2, `y`], color = magenta):
labz := textplot3d([0, 0, 16, `z`], color = magenta):
display(surf, xaxis, yaxis, zaxis, labx, laby,labz);**

The view in the figure above strongly suggests that (1, 1, 3) is a local minimum point, but it doesn't show the nature of the graph around the other stationary point (0, 0, 4). The next view, which is simply a rotated version of the above one, suggests that the latter point is not a local extreme-value point. The second-derivative test confirms both these visual impressions.

**Example 2**
. (Exercise 10, Section 15.7). Find and classify the stationary points of
*g*
if
*g*
(
*x*
,
*y*
) =
.

Solution. Execute the following routine to find the partial derivatives of
*g*
and solve for the points (
*x*
,
*y*
) at which both are 0.

`> `
**g := (x, y) -> 2*x^3 + x*y^2 + 5*x^2 + y^2;
g_x := (x, y) -> diff(g(x, y), x);
evalf(g_x(x, y));
g_y := (x, y) -> diff(g(x, y), y);
evalf(g_y(x, y));
solve({evalf(g_x(x, y))= 0, evalf(g_y(x, y))= 0});**

Conventional 3-dimensional plots of the graph of
*g*
that show its behavior accurately near the critical points are hard to generate, but Maple's 3-dimensional level-curve routine does so easily. The following plot suggests strongly that the second stationary point is a local-maximum point. Try this approach on the other stationary points!

`> `
**g := (x, y) -> 2*x^3 + x*y^2 + 5*x^2 + y^2;
contourplot3d( g(x, y),x = -2..-1.4, y = -1/4..1/4, color = blue, labels = ["x", "y", "z"], axes = boxed);**