#### xaktly | Vector calculus

Maxima & minima in $\mathbb{R}^3$

### Review: Critical points in $\mathbb{R}^2$

Before we work on maxima and minima for 3D functions, it might help to review what we know about 2D functions. We found critical points when the first derivative of a function is zero — when the tangent line to the function is horizontal:

$$\frac{df}{dx} = 0$$

For example, recall that the parabola $f(x) = x^2$ has a minimum at $(0, 0)$, and that

$$\frac{df}{dx} = 2x$$

is zero at $x = 0$, where $y = 0$. And we can confirm that $(0,0)$ is a minimum by the second-derivative test:

$$\frac{d^2 f}{dx^2} = 2 \gt 0.$$

Because the second derivative is positive, the function is concave upward (everywhere in this case). Here's the function with its derivative at $(0,0)$.

Likewise for $f(x) = -x^2$, which we know to be an upside-down parabola,

$$\frac{df}{dx} = -2x \phantom{00} \text{ and } \phantom{00} \frac{d^2 f}{dx^2} = -2$$

which gives us a critical point at $(0,0)$ and a negative second derivative, which means concave-downward. Here's the graph:

We call these local maxima and minima, but in these cases they are the global maximum and minimum, respectively. Now let's look at one more 2D function, $f(x) = x^3$. The critical point is

$$\frac{df}{dx} = 3x^2 = 0 \; \rightarrow \; x = 0$$

The second derivative is $6x$, and evaluated at the critical point $(0, 0)$ we get $0$, which is indeterminate for the curvature of the function — it's between concave upward and concave downward. For 2D graphs, we know this kind of point as an inflection point, a point where the curvature changes between the two concavities. Here's the graph:

### Max-min in $\mathbb{R}^3$

For functions in $\mathbb{R}^3$ — functions of two variables like $f(x,y) = x^2 - y^2$, shown below, we'll be able to make some analogies with the 2D case.

To have a critical point in a function $f(x,y)$, we require that both partial derivatives equal zero:

$$\frac{\partial f}{\partial x} = \frac{\partial f}{\partial y} = 0$$

We can find those partials for $f(x,y) = x^2 - y^2$ and set them equal to zero to find our critical point(s):

$$\frac{\partial f}{\partial x} = 2x \phantom{00} \text{and} \phantom{00} \frac{\partial f}{\partial y} = 2y$$

$$2x = 0 \; \rightarrow x = 0 \phantom{00} \text{and} \phantom{00} 2y = 0 \; \rightarrow y = 0$$

Our single critical point is $(x, y) = (0, 0)$.

Now our partial derivative with respect to $x$ treats $y$ as a constant, and locks us into the $x-z$ plane. That leaves us with the parabola $z = x^2$ in red in the graph. That's an upward-opening parabola, so we'd expect a second-derivative test to indicate upward curvature. In fact,

$$\frac{\partial^2 f}{\partial x^2} = 2 \gt 0$$

... so that matches our finding from the 2D case. Likewise, the green, downward-opening parabola traced in the $y-z$ plane has a negative second partial derivative,

$$\frac{\partial^2 f}{\partial y^2} = -2 \lt 0$$

So our critical point is both a local minimum (in the $xz$ plane) and a local maximum (in the $yz$ plane). This kind of point, which is analogous to the inflection point in 2D, is called a saddle point.

#### 2nd derivative test

Now we're going to jump straight to the general second-derivative test for multidimensional functions without much explanation. Then we'll rationalize it afterward. Here are the key elements of the 2nd derivative test:

1. Critical point(s): $\frac{\partial f}{\partial x} = \frac{\partial f}{\partial y} = 0$ defines a critical point $(a, b)$ of a function.

2. We'll calculate all second derivatives of $f(x,y)$: $\frac{\partial ^2}{\partial x^2},\frac{\partial ^2}{\partial y^2}$ and $\frac{\partial ^2}{\partial y \partial x}$ or $f_{xx}$, $f_{yy}$ and $f_{xy}$, recalling that $f_{xy} = f_{yx}$.

3. Calculate the 2D determinant,

\begin{align} D &= \text{det} \left( \begin{array}{rr} f_{xx} & f_{xy} \\ f_{yx} & f_{yy} \end{array} \right) \\[5pt] &= f_{xx} f_{yy} - (f_{xy})^2 \end{align}

4. If $D(a,b) \gt 0$ and $f_{xx}(a,b) \gt 0$, then $(a, b)$ is a local minimum of $f(x,y)$.

If $D(a,b) \gt 0$ and $f_{xx}(a,b) \lt 0$, then $(a, b)$ is a local maximum of $f(x,y)$.

If $D(a,b) \lt 0$, then $(a, b)$ is a saddle point of $f(x,y)$.

Let's perform this second-derivative test for our function $f(x,y)=x^2-y^2$. We have

\begin{align} f_{xx} &= 2 \phantom{00} f_{yy} = -2 \phantom{00} f_{xy} = 0 \\[10pt] D &= f_{xx} f_{yy} - (f_{xx})^2 \\[5pt] &= 2(-2) - 0 = -4 \lt 0 \end{align}

Now look at our value $D$. If $f_{xx}$ and $f_{yy}$ are of opposite signs, as they are in our example, then $f_{xx}f_{yy}$ is negative, so $D = f_{xx} f_{yy} - (f_{xx})^2$ must be negative, and we have a saddle point.

If both $f_{xx}$ and $f_{yy}$ have the same sign, then $D$ can be positive or negative. In the latter case, $f_{xx}$ evaluated at the critical point, is positive, then so is $f_{yy}$, and curves analogous to our two parabolas are both concave-upward, so we have a local minimum. Conversely, if $f_{xx} \lt 0$ then we have a local maximum.

If $D = 0$ the second derivative test is inconclusive.

### Example 1

Find and characterize any critical points of the function $f(x,y) = x \, e^{-2x^2-2y^2}$

First calculate the first partial derivatives — this is a tricky function requiring the product and chain rules; be careful. I've skipped some steps for brevity in calculating these partial derivatives.

\begin{align} f_x &= e^{-2x^2-2y^2}[1-4x^2] = 0 \\[5pt] 1 - 4x^2 &= 0 \tag{1} \\[5pt] x &= \pm \frac{1}{2} \\[8pt] f_y &= -4xy \, e^{-2x^2-2y^2} = 0 \\[5pt] y &= 0 \end{align}

Notice that in (1), we used the fact that $e^{-2x^2-2y^2}$ is never equal to zero, which makes finding the zeros of the first partials. So our critical points are $\left( \frac{1}{2}, 0 \right), \; \left( -\frac{1}{2}, 0 \right)$.

Now our second derivatives are

\begin{align} f_{xx} &= e^{-2x^2-2y^2}[16x^3 - 12x] \\[5pt] f_{yy} &= e^{-2x^2-2y^2}[-4x+16y^2] \\[5pt] f_{xy} &= -4y \, e^{-2x^2-2y^2}[1-4x^2] \end{align}

As a shorcut, we can calculate $e^{-2x^2-2y^2}$ for $x = \pm \frac{1}{2}, \; y = 0$. It's value (regardless of the sign of $x$) is $e^{1/2}$. What will matter most to us is that it's a positive number.

Now we can calculate

\begin{align} f_{xx}\left( \frac{1}{2}, 0 \right) &= \frac{-4}{\sqrt{e}} \\[5pt] f_{xx}\left( -\frac{1}{2}, 0 \right) &= \frac{4}{\sqrt{e}} \\[5pt] f_{yy}\left(\pm \frac{1}{2}, 0 \right) &= \frac{-2}{\sqrt{e}} \\[5pt] f_{xy} \left(\pm \frac{1}{2}, 0 \right) &= 0 \end{align}

Now we can caclulate the determinant, $D$

$$D = \text{det} \left( \begin{array}{rr} \frac{-4}{\sqrt{e}} & 0 \\ 0 & \frac{-2}{\sqrt{e}} \end{array} \right) = \frac{8}{e} \gt 0$$

Finally, we can evaluate each critical point:

\begin{align} \left( \frac{1}{2}, 0 \right): &\phantom{00} D \gt 0 \phantom{00} f_{xx} \lt 0 \rightarrow \text{max} \\[5pt] \left( -\frac{1}{2}, 0 \right): &\phantom{00} D \gt 0 \phantom{00} f_{xx} \gt 0 \rightarrow \text{max} \end{align}

Our critical points include a local maximum (which is also the global max in this case) at $(x,y) = \left( \frac{1}{2}, 0 \right)$ and a local minimum (also the global min) at $(x,y) = \left( -\frac{1}{2}, 0 \right)$. These findings are consistent with the 3D plot below:

This function does not have a saddle point.

### Example 2

Find and characterize any critical points of the function $f(x,y) = x - x^2y - y + xy^2$

The first partial derivatives are

\begin{align} f_x &= 1 - 2xy + y^2 = 0\\[5pt] f_y &= -1 + 2xy - x^2 = 0 \end{align}

If we add those two equations, we can eliminate the first two terms of each:

$$y^2 - x^2 = 0 \; \rightarrow \; x = \pm y$$

Now let's plug that result into $f_x$, including the $\pm$.

\begin{align} f_x = 1 - 2x(\pm x) + (\pm x)^2 &= 0 \\[5pt] 1 \pm 2x^2 + x^2 &= 0 \\[5pt] \end{align}

This reduces to $1 - x^2 = 0$ for the (+) solution, which gives $x = \pm 1$. For the (-) solution there are no real zeros, so we have $x = \pm 1$. Now we plug that in (with the $\pm$) to either $f_x$ or $f_y$:

\begin{align} -1 + 2(\pm 1) y - (\pm y)^2 &= 0 \\[5pt] -1 \pm 2y - 1 &= 0 \\[5pt] \pm 2y &= 2 \\[5pt] y &= \pm 1 \end{align}

So our candidates for critical points are $(1, 1), \; (1, -1), \; (-1, 1)$ and $(-1, -1)$.

Now our second-derivative test. The second derivatives are

$$f_{xx} = -2y \phantom{000} f_{yy} = 2x\phantom{000} f_{xy} = -2(x-y)$$

Then our determinant is

$$D = \text{det} \left( \begin{matrix} -2y & -2(x-y) \\ -2(x-y) & 2y \end{matrix} \right) = -4y^2 -4(x-y)^2$$

Here is a table of our $D$ and $f_{xx}$ values at our four candidate critical points.

Qty. (1,1) (1,-1) (-1,1) (-1,-1)
$D(a,b)$ -4 -20 -20 -4
$f_{xx}(a,b)$ -2 2 -2 2
$f_{yy}(a,b)$ 2 2 -2 -2

All of the $D$ values are negative, indicating saddle points rather than local maxima or minima. But in this case we need to look closer — that's why both second partials $f_{xx}$ and $f_{yy}$ are included in the table. For a true saddle point, the partial derivatives in the $x$ and $y$ directions must have opposite signs. that is only true for our critical points $(1, 1)$ and $(-1,-1)$.

Here's a 3-D plot showing those saddle points. Notice that this function has no local maxima or minima.

### Example 3

Find and characterize any critical points of the function $f(x,y) = (x^2+y^2)e^{-x}$

The first partial derivatives are

\begin{align} f_x &= -e^{-x}(x^2 + y^2) + e^{-x}(2x) \\[5pt] &= e^{-x}[2x - (x^2 + y^2)] \\[5pt] &= e^{-x}[-x^2 - y^2 + 2x] = 0\\[8pt] f_y &= -2y e^{-x} = 0 \\[5pt] &\rightarrow y = 0 \end{align}

Now plug $y = 0$ into the $f_x$ expression:

\begin{align} f_x(y = 0) &= -e^{-x}[-x^2 - 0 + 2x] \\[5pt] x^2 &= 2x \\[5pt] &\rightarrow \; x = 0 \text{ or } 2 \end{align}

So our critical points are $(0, 0)$ and $(2, 0)$. Now the second partials:

$$f_{xx} = e^{-x}[x^2 + y^2 - 4x + 2] \phantom{000} f_{yy} = 2 e^{-x}$$

$$f_{xy} = f{yx} = -2y \, e^{-x}$$

The discriminant, $D$, is

$$D = \text{det} \left( \begin{matrix} e^{-x}[-x^2-y^2+2x] & -2y \, e^{-x} \\ -2y \, e^{-x} & 2y \, e^{-x} \end{matrix} \right) = 2e^{-2x}[-x -y^2 + 2x + 2y]$$

Now we can make a table of our second-derivative test key values:

 Qty. (0,0) (2,0) $D(a,b)$ 4 -4 e-4 $f_{xx}(a,b)$ 2 2 e-2

Finally, critical point $(0, 0)$ is a local minimum because $D \gt 0$ and $f_{xx} \gt 0$ (the curvature is concave upward). And $(2, 0)$ is a saddle point because $D \lt 0$. Here's a graph of that function.

### Practice problems

Find the critical points of the following $\mathbb{R}^3$ functions, and determine whether each is a local minimum, a local maximum or a saddle point.

1.   $f(x,y) = x^2-y-ln(x+y)$

Solution

\begin{align} f_x &= 2x - \frac{1}{x+y} = 0 \\[5pt] 2x &= \frac{1}{x+y} \\[5pt] 2x^2 + 2xy - 1 &= 0 \tag{1} \\[8pt] f_y &= -1 - \frac{1}{x+y} \\[5pt] y &= -x - 1 \tag{2} \end{align}

We can solve for $x$ by inserting (2) into (1):

\begin{align} 2x^2 + 2x(-x-1) - 1 &= 0 \\[5pt] -2x &= 1 \\[5pt] x &= -\frac{1}{2} \end{align}

Then we use this in $y = -x -1$ to get $y = -\frac{1}{2}$, thus our one critical point is $\left( -\frac{1}{2}, -\frac{1}{2} \right)$.

We can actually stop here because that point is not in the domain of our function — we can't take the log of a negative number. So we conclude that this function has no local minima, maxima or saddle points. Here's a graph:

2.   $f(x,y) = ln(x) + 4ln(y) - x - 4y$

Solution

\begin{align} f_x &= \frac{1}{x}-1 = 0 \\[5pt] x &= 1 \\[5pt] f_y &= \frac{4}{y} - 4 = 0 \\[5pt] y &= 1 \end{align}

So our only critical point is $(1, 1)$.

Then we use this in $y = -x -1$ to get $y = -\frac{3}{2}$, thus our one critical point is $\left( -\frac{1}{2}, -\frac{3}{2} \right)$.

The second partials are

\begin{align} f_{xx} &= \frac{-1}{x^2} \\[5pt] f_{yy} &= \frac{-4}{x^2} \\[5pt] f_{xy} &= 0 \end{align}

$$D = \text{det} \left( \begin{matrix} \frac{-1}{x^2} & 0 \\ 0 & \frac{-4}{y^2} \end{matrix} \right) = \frac{4}{x^2 y^2}$$

$D$ is always positive. Then $f_{xx}(1,1) = -1$. Because this is less than zero and $D > 0$, the critical point is a local maximum.

1.   $f(x,y) = x^3 + 2xy - 2y^2 - 10x$

Solution

\begin{align} f_x &= 3x^2+2y-10 = 0 \\[5pt] f_y &= 2x - 4y = 0 \\[5pt] 4y &= 2x \; \rightarrow \; x = 2y \end{align}

Plugging $x=2y$ into the $f_x$ equation gives

\begin{align} 3(2y)^2 + 2y -10 &= 0 \\[5pt] 4(4y^2) + 2y -10 &= 0 \\[5pt] 12y^2 + 2y &= 10 \\[5pt] y^2 + \frac{y}{6} + \left( \frac{1}{12} \right)^2 &= \frac{5}{6} + \frac{1}{144} \tag{*} \\[5pt] \left( y + \frac{1}{12} \right)^2 &= \frac{120 + 1}{144} \tag{*} \\[5pt] y &= \frac{-1 \pm \sqrt{121}}{\sqrt{144}} \tag{*} \\ y &= \frac{-1 \pm 11}{12} = -1, \frac{5}{6} \end{align}

The starred steps above are solving the quadratic by completing the square. We can get the x-coordinates for each of those $y$ values using $f_y = 0$:

\begin{align} f_y(y = -1) = 2x + 4 = 0 \; \rightarrow \; x &= -2 \\[5pt] f_y\left(y = \frac{5}{6} \right) = 2x - 4 \left( \frac{5}{6} \right) = 0 \; \rightarrow \; x &= \frac{5}{3} \end{align}

So our two critical points are $(-2, -1)$ and $\left( \frac{5}{3}, \frac{5}{6} \right)$

The second partials are

\begin{align} f_{xx} &= 6x \\[5pt] f_{yy} &= -4 \\[5pt] f_{xy} &= 2 \end{align}

$$D = \text{det} \left( \begin{matrix} 6x & 2 \\ 2 & -4 \end{matrix} \right) = \frac{4}{x^2 y^2} = -24x - 4$$

Here is a table of $D$ and $f_{xx}$ values for our two critical points.

 Qty. (-2,-1) (5/3,5/6) $D(a,b)$ 44 -24 $f_{xx}(a,b)$ -12 10

Based on these quantities, $(-2,-1)$ is a local maximum and $\left( \frac{5}{3}, \frac{5}{6} \right)$ is a saddle point.

2.   $f(x,y) = x^2 + y^2 - xy + x$

Solution

The first partial derivatives are

\begin{align} f_x &= 2x - y + 1 = 0 \\[5pt] f_y &= 2y -x = 0 \; \rightarrow \; y = \frac{x}{2} \\[5pt] \end{align}

Plugging that value of y back into $f_x$ gives

\begin{align} 2x - \frac{x}{2} + 1 &= 0 \\[5pt] \frac{3}{2} y = -1 \; \rightarrow \; y &= -\frac{3}{2} \end{align}

The $x$-coordinate is $-\frac{2}{3}$, so our critical point is $\left( -\frac{2}{3}, -\frac{3}{2} \right)$.

The partial derivatives are

\begin{align} f_{xx} = 2 \\[5pt] f_{yy} = 2 \\[5pt] f_{xy} = -1 \end{align}

That makes $D$ easy, $D = 3 \gt 0$. Now $f_{xx}(-2/3,-1/3) = 2$, also positive, so the critical point must be a local minimum.

xaktly.com by Dr. Jeff Cruzan is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. © 2024, Jeff Cruzan. All text and images on this website not specifically attributed to another source were created by me and I reserve all rights as to their use. Any opinions expressed on this website are entirely mine, and do not necessarily reflect the views of any of my employers. Please feel free to send any questions or comments to jeff.cruzan@verizon.net.