Given a function $z=f(x,y)\text{,}$ we are often interested in points where $z$ takes on the largest or smallest values. For instance, if $z$ represents a cost function, we would likely want to know what $(x,y)$ values minimize the cost. If $z$ represents the ratio of a volume to surface area, we would likely want to know where $z$ is greatest. This leads to the following definition.

##### Definition12.8.1Relative and Absolute Extrema

Let $z=f(x,y)$ be defined on a set $S$ containing the point $P=(x_0,y_0)\text{.}$

1. If there is an open disk $D$ containing $P$ such that $f(x_0,y_0) \geq f(x,y)$ for all $(x,y)$ in $D\text{,}$ then $f$ has a relative maximum at $P\text{;}$ if $f(x_0,y_0) \leq f(x,y)$ for all $(x,y)$ in $D\text{,}$ then $f$ has a relative minimum at $P\text{.}$

2. If $f(x_0,y_0)\geq f(x,y)$ for all $(x,y)$ in $S\text{,}$ then $f$ has an absolute maximum at $P\text{;}$ if $f(x_0,y_0)\leq f(x,y)$ for all $(x,y)$ in $S\text{,}$ then $f$ has an absolute minimum at $P\text{.}$

3. If $f$ has a relative maximum or minimum at $P\text{,}$ then $f$ has a relative extrema at $P\text{;}$ if $f$ has an absolute maximum or minimum at $P\text{,}$ then $f$ has a absolute extrema at $P\text{.}$

If $f$ has a relative or absolute maximum at $P=(x_0,y_0)\text{,}$ it means every curve on the surface of $f$ through $P$ will also have a relative or absolute maximum at $P\text{.}$ Recalling what we learned in Section 3.1, the slopes of the tangent lines to these curves at $P$ must be 0 or undefined. Since directional derivatives are computed using $f_x$ and $f_y\text{,}$ we are led to the following definition and theorem.

##### Definition12.8.2Critical Point

Let $z = f(x,y)$ be continuous on an open set $S\text{.}$ A critical point $P=(x_0,y_0)$ of $f$ is a point in $S$ such that

• $f_x(x_0,y_0) = 0$ and $f_y(x_0,y_0) = 0\text{,}$ or

• $f_x(x_0,y_0)$ and/or $f_y(x_0,y_0)$ is undefined.

Therefore, to find relative extrema, we find the critical points of $f$ and determine which correspond to relative maxima, relative minima, or neither. The following examples demonstrate this process.

##### Example12.8.4Finding critical points and relative extrema

Let $f(x,y) = x^2+y^2-xy-x-2\text{.}$ Find the relative extrema of $f\text{.}$

Solution
##### Example12.8.6Finding critical points and relative extrema

Let $f(x,y) = -\sqrt{x^2+y^2}+2\text{.}$ Find the relative extrema of $f\text{.}$

Solution

In each of the previous two examples, we found a critical point of $f$ and then determined whether or not it was a relative (or absolute) maximum or minimum by graphing. It would be nice to be able to determine whether a critical point corresponded to a max or a min without a graph. Before we develop such a test, we do one more example that sheds more light on the issues our test needs to consider.

##### Example12.8.8Finding critical points and relative extrema

Let $f(x,y) = x^3-3x-y^2+4y\text{.}$ Find the relative extrema of $f\text{.}$

Solution

Let $P=(x_0,y_0)$ be in the domain of $f$ where $f_x=0$ and $f_y=0$ at $P\text{.}$ $P$ is a saddle point of $f$ if, for every open disk $D$ containing $P\text{,}$ there are points $(x_1,y_1)$ and $(x_2,y_2)$ in $D$ such that $f(x_0,y_0)>f(x_1,y_1)$ and $f(x_0,y_0)\lt f(x_2,y_2)\text{.}$

At a saddle point, the instantaneous rate of change in all directions is 0 and there are points nearby with $z$-values both less than and greater than the $z$-value of the saddle point.

Before Example 12.8.8 we mentioned the need for a test to differentiate between relative maxima and minima. We now recognize that our test also needs to account for saddle points. To do so, we consider the second partial derivatives of $f\text{.}$

Recall that with single variable functions, such as $y=f(x)\text{,}$ if $\fp'(c)>0\text{,}$ then $f$ is concave up at $c\text{,}$ and if $\fp(c) =0\text{,}$ then $f$ has a relative minimum at $x=c\text{.}$ (We called this the Second Derivative Test.) Note that at a saddle point, it seems the graph is “both” concave up and concave down, depending on which direction you are considering.

It would be nice if the following were true:

 $f_{xx}$ and $f_{yy} >0$ $\Rightarrow$ relative minimum $f_{xx}$ and $f_{yy} \lt 0$ $\Rightarrow$ relative maximum $f_{xx}$ and $f_{yy}$ have opposite signs $\Rightarrow$ saddle point.

However, this is not the case. Functions $f$ exist where $f_{xx}$ and $f_{yy}$ are both positive but a saddle point still exists. In such a case, while the concavity in the $x$-direction is up (i.e., $f_{xx}>0$) and the concavity in the $y$-direction is also up (i.e., $f_{yy}>0$), the concavity switches somewhere in between the $x$- and $y$-directions.

To account for this, consider $D = f_{xx}f_{yy}-f_{xy}f_{yx}\text{.}$ Since $f_{xy}$ and $f_{yx}$ are equal when continuous (refer back to Theorem 12.3.11), we can rewrite this as $D = f_{xx}f_{yy}-f_{xy}^{\,2}\text{.}$ $D$ can be used to test whether the concavity at a point changes depending on direction. If $D>0\text{,}$ the concavity does not switch (i.e., at that point, the graph is concave up or down in all directions). If $D\lt 0\text{,}$ the concavity does switch. If $D=0\text{,}$ our test fails to determine whether concavity switches or not. We state the use of $D$ in the following theorem.

We first practice using this test with the function in the previous example, where we visually determined we had a relative maximum and a saddle point.

##### Example12.8.12Using the Second Derivative Test

Let $f(x,y) = x^3-3x-y^2+4y$ as in Example 12.8.8. Determine whether the function has a relative minimum, maximum, or saddle point at each critical point.

Solution
##### Example12.8.13Using the Second Derivative Test

Find the relative extrema of $f(x,y) = x^2y+y^2+xy\text{.}$

Solution

# Subsection12.8.1Constrained Optimization

When optimizing functions of one variable such as $y=f(x)\text{,}$ we made use of Theorem 3.1.4, the Extreme Value Theorem, that said that over a closed interval $I\text{,}$ a continuous function has both a maximum and minimum value. To find these maximum and minimum values, we evaluated $f$ at all critical points in the interval, as well as at the endpoints (the “boundary”) of the interval.

A similar theorem and procedure applies to functions of two variables. A continuous function over a closed set also attains a maximum and minimum value (see the following theorem). We can find these values by evaluating the function at the critical values in the set and over the boundary of the set. After formally stating this extreme value theorem, we give examples.

##### Example12.8.16Finding extrema on a closed set

Let $f(x,y) = x^2-y^2+5$ and let $S$ be the triangle with vertices $(-1,-2)\text{,}$ $(0,1)$ and $(2,-2)\text{.}$ Find the maximum and minimum values of $f$ on $S\text{.}$

Solution

This portion of the text is entitled “Constrained Optimization” because we want to optimize a function (i.e., find its maximum and/or minimum values) subject to a constraint — some limit to what values the function can attain. In the previous example, we constrained ourselves by considering a function only within the boundary of a triangle. This was largely arbitrary; the function and the boundary were chosen just as an example, with no real “meaning” behind the function or the chosen constraint.

However, solving constrained optimization problems is a very important topic in applied mathematics. The techniques developed here are the basis for solving larger problems, where more than two variables are involved.

We illustrate the technique once more with a classic problem.

##### Example12.8.21Constrained Optimization

The U.S. Postal Service states that the girth+length of Standard Post Package must not exceed 130''. Given a rectangular box, the “length” is the longest side, and the “girth” is twice the width+height.

Given a rectangular box where the width and height are equal, what are the dimensions of the box that give the maximum volume subject to the constraint of the size of a Standard Post Package?

Solution

It is hard to overemphasize the importance of optimization. In “the real world,” we routinely seek to make something better. By expressing the something as a mathematical function, “making something better” means “optimize some function.

The techniques shown here are only the beginning of an incredibly important field. Many functions that we seek to optimize are incredibly complex, making the step of “find the gradient and set it equal to $\vec 0$” highly nontrivial. Mastery of the principles here are key to being able to tackle these more complicated problems.

# Subsection12.8.2Exercises

Terms and Concepts

In the following exercises, find the critical points of the given function. Use the Second Derivative Test to determine if each critical point corresponds to a relative maximum, minimum, or saddle point.

In the following exercises, find the absolute maximum and minimum of the function subject to the given constraint.