If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

### Course: Multivariable calculus>Unit 3

Lesson 4: Optimizing multivariable functions (articles)

# Second partial derivative test

Learn how to test whether a function with two inputs has a local maximum or minimum.

## Background

Not strictly necessary, but used in one section:
Also, if you are a little rusty on the second derivative test from single-variable calculus, you might want to quickly review it here since it's a good comparison for the second partial derivative test.

## The statement of the second partial derivative test

If you are looking for the local maxima/minima of a two-variable function $f\left(x,y\right)$, the first step is to find input points $\left({x}_{0},{y}_{0}\right)$ where the gradient is the $\mathbf{\text{0}}$ vector.
$\mathrm{\nabla }f\left({x}_{0},{y}_{0}\right)=\mathbf{\text{0}}$
These are basically points where the tangent plane on the graph of $f$ is flat.
The second partial derivative test tells us how to verify whether this stable point is a local maximum, local minimum, or a saddle point. Specifically, you start by computing this quantity:
$H={f}_{xx}\left({x}_{0},{y}_{0}\right){f}_{yy}\left({x}_{0},{y}_{0}\right)-{{f}_{xy}\left({x}_{0},{y}_{0}\right)}^{2}$
Then the second partial derivative test goes as follows:
• If $H<0$, then $\left({x}_{0},{y}_{0}\right)$ is a saddle point.
• If $H>0$, then $\left({x}_{0},{y}_{0}\right)$ is either a maximum or a minimum point, and you ask one more question:
• If ${f}_{xx}\left({x}_{0},{y}_{0}\right)<0$, $\left({x}_{0},{y}_{0}\right)$ is a local maximum point.
• If ${f}_{xx}\left({x}_{0},{y}_{0}\right)>0$, $\left({x}_{0},{y}_{0}\right)$ is a local minimum point.
(You could also use ${f}_{yy}\left({x}_{0},{y}_{0}\right)$ instead of ${f}_{xx}\left({x}_{0},{y}_{0}\right)$, it actually doesn't matter)
• If $H=0$, we do not have enough information to tell.

## Loose intuition

Focus first on this term:
${f}_{xx}\left({x}_{0},{y}_{0}\right){f}_{yy}\left({x}_{0},{y}_{0}\right)$
You can think of it as cleverly encoding whether or not the concavity of $f$'s graph is the same in both the $x$ and $y$ directions.
For example, look at the function
$f\left(x,y\right)={x}^{2}-{y}^{2}$
This function has a saddle point at $\left(x,y\right)=\left(0,0\right)$. The second partial derivative with respect to $x$ is a positive constant:
$\begin{array}{rl}{f}_{xx}\left(x,y\right)& =\frac{\partial }{\partial x}\frac{\partial }{\partial x}\left({x}^{2}-{y}^{2}\right)\\ \\ & =\frac{\partial }{\partial x}2x\\ \\ & =2>0\end{array}$
In particular, ${f}_{xx}\left(0,0\right)=2>0$, and the fact that this is positive means $f\left(x,y\right)$ looks like it has upward concavity as we travel in the $x$-direction. On the other hand, the second partial derivative with respect to $y$ is a negative constant:
$\begin{array}{rl}{f}_{yy}\left(x,y\right)& =\frac{\partial }{\partial y}\frac{\partial }{\partial y}\left({x}^{2}-{y}^{2}\right)\\ \\ & =\frac{\partial }{\partial y}-2y\\ \\ & =-2<0\end{array}$
This indicates downward concavity as we travel in the $y$-direction. This mismatch means we must have a saddle point, and it is encoded as the product of the two second partial derivatives:
${f}_{xx}\left(0,0\right){f}_{yy}\left(0,0\right)=\left(2\right)\left(-2\right)=-4<0$
Since ${{f}_{xy}\left(0,0\right)}^{2}$ can only be positive, subtracted it will only make the full expression more negative.
${f}_{xx}\left({x}_{0},{y}_{0}\right){f}_{yy}\left({x}_{0},{y}_{0}\right)-{{f}_{xy}\left({x}_{0},{y}_{0}\right)}^{2}$
On the other hand, when the signs of ${f}_{xx}\left({x}_{0},{y}_{0}\right)$ and ${f}_{yy}\left({y}_{0},{y}_{0}\right)$ are either both positive or both negative, the $x$ and $y$ directions agree about what the concavity of $f$ should be. In either of these cases, the term ${f}_{xx}\left({x}_{0},{y}_{0}\right){f}_{yy}\left({x}_{0},{y}_{0}\right)$ will be positive.
But this is not enough!

## The ${f}_{xy}^{2}$‍  term

Consider the function
$\begin{array}{r}f\left(x,y\right)={x}^{2}+{y}^{2}+pxy\end{array}$
where $p$ is some constant.
Concept check: With this definition of $f$, compute its second derivatives:
${f}_{xx}\left(x,y\right)=$
${f}_{yy}\left(x,y\right)=$
${f}_{xy}\left(x,y\right)=$

Because the second derivatives ${f}_{xx}\left(0,0\right)$ and ${f}_{yy}\left(0,0\right)$ are both positive, the graph will appear concave up as we travel in either the pure $x$ direction or the pure $y$ direction (no matter what $p$ is).
However, watch the following video where we show how this graph changes as we let the constant $p$ vary from $1$ to $3$, then back to $1$:
What's going on here? How can the graph have a saddle point even though it is concave up in both the $x$ and $y$ directions? The short answer is that other directions matter too, and in this case, they are captured by the term $pxy$.
For example, if we isolate this $xy$ term and look at the graph of $g\left(x,y\right)=xy$, here's what it looks like:
It has a saddle point at $\left(0,0\right)$. This is not because the $x$ and $y$ directions disagree about concavity, but instead because the concavity appears positive along the diagonal direction $\left[\begin{array}{c}1\\ 1\end{array}\right]$ and negative in the direction $\left[\begin{array}{c}-1\\ 1\end{array}\right]$.
Let's see what the second derivative test tells us about the function $f\left(x,y\right)={x}^{2}+{y}^{2}+pxy$. Using the values for the second derivatives you were asked to compute above, Here's what we get:
${f}_{xx}\left(0,0\right){f}_{yy}\left(0,0\right)-{{f}_{xy}\left(0,0\right)}^{2}=\left(2\right)\left(2\right)-{p}^{2}$
When $p>2$, this is negative, so $f$ has a saddle point. When $p<2$, it is positive, so $f$ has a local minimum.
You can think of the quantity ${f}_{xy}\left({x}_{0},{y}_{0}\right)$ as measuring how much the function $f$ looks like the graph of $g\left(x,y\right)=xy$ near the point $\left({x}_{0},{y}_{0}\right)$.
Considering how many directions have to agree with each other, it is actually quite surprising that we only need to consider three values, ${f}_{xx}\left(0,0\right)$, ${f}_{yy}\left(0,0\right)$ and ${f}_{xy}\left(0,0\right)$.
The next article gives more detailed reasoning behind the second partial derivative test.

## Summary

• Once you find a point where the gradient of a multivariable function is the zero vector, meaning the tangent plane of the graph is flat at this point, the second partial derivative test is a way to tell if that point is a local maximum, local minimum, or a saddle point.
• The key term of the second partial derivative test is this:
$H={f}_{xx}\left({x}_{0},{y}_{0}\right){f}_{yy}\left({x}_{0},{y}_{0}\right)-{{f}_{xy}\left({x}_{0},{y}_{0}\right)}^{2}$
• If $H>0$, the function definitely has a local maximum/minimum at the point $\left({x}_{0},{y}_{0}\right)$.
• If ${f}_{xx}\left({x}_{0},{y}_{0}\right)>0$, it is a minimum.
• If ${f}_{xx}\left({x}_{0},{y}_{0}\right)<0$, it is a maximum.
• If $H<0$, the function definitely has a saddle point at $\left({x}_{0},{y}_{0}\right)$.
• If $H=0$, there is not enough information to tell.

## Want to join the conversation?

• We often get the type of problem on our exams where a point (x,y) gives H=0.
We are then told to use the "definition" of a saddle point to check if this is the case. My teacher used an example where the point was (0,0)=0, and the function f(x,y) = x^2
y + xy^3 + xy^2. He then replaced (0,0) --> (a,a), which in turn made f(a,a)= a^3(a+2) and chose a just above and below zero. Since f>0 when a>0 and f<0 when a<0, the conclusion was that the point (0,0) was a saddle point.

If you've made it this far, I applaud you.
Now for my question: If we apply the same test to a max, would BOTH "(a,a)" then gives us values just below the value of f at the actual point?
Likewise, would the test give two values just ABOVE the value of f at the actual point, if the point was a minimum?

This seems right to me. If the graph looked like a traffic cone, all points below the max would compute smaller values of f, right?
• Great question! Can we get an answer on this one?
• What options are available if H=0?
• How can we apply the second partial derivative test for functions with more than 2 variables (like f(x,y,z))?
• How do I find the second partial derivatives for a function with 3 variables and how does this test work for that? Thanks :)
• You actually need to look at the eigenvalues of the Hessian Matrix, if they are all positive, then there is a local minimum, if they are all negative, there is a local max, and if they are of different signs, then there is a saddle.
• What do you do if the second partial derivative still has variables in it? How do you know if fxx or fyy is positive or negative?
(1 vote)
• If the second partial derivative is dependent on x and y, then it is different for different x and y. fxx(0, 0) is different from fxx(1, 0) which is different from fxx(0, 1) and fxx(1, 1) and so on. There's nothing wrong with that. You need to decide which point you care about and plug in the x and y values.

Recall that was also the case with the second derivative test in single var calculus. You calculate the first or second derivative at some point.
• Is the formula for the second partial derivative test (fxx*fyy - (fxy)^2) just the determinant of the Hessian matrix learned earlier in this section?
• In a way, yes. It is a boiled-down version of the Hessian's determinant that excludes non-negative numerical factors.
(1 vote)
• What if AC-Bˆ2 is positive but A is 0?
Is it possible?
(1 vote)
• Not possible:
A = 0 => AC = 0
and:
B^2 has to be either 0 or positive (and is then subtracted from AC)...
so if A is 0, the result will never be positive.
• We were taught that the test actually was H = (f_12)^2 - (f_11)(f_22) and that if H > 0, the point is a saddle point and of course the opposite for local max/min. This contradicts what you have written here.
• It's absolutelly OK.
lets say...
fxx*fyy - (fxy)^2 > 0 meaning it's max/min.
What you have provided here is this inequality*(-1). Proof:
-(fxx*fyy) + (fxy)^2 < 0 is still a local maximum/minimum.
Was my explanation clear enough?
• Under '[Phrased using the Hessian determinant]', we say that the second derivative test can be done using the determinant of the Hessian. This is only true for functions with input space in R2, right? With higher-dimensional input space, we need H to be positive definite. Correct?
(1 vote)
• In the equation for H, what is fxx (x,y) and fyy(x,y) and fxy(x,y)^2?
Are those the partial derivates?
(1 vote)