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.

## Multivariable calculus

### Course: Multivariable calculus>Unit 2

Lesson 3: Partial derivative and gradient (articles)

# Second partial derivatives

A brief overview of second partial derivative, the symmetry of mixed partial derivatives, and higher order partial derivatives.

## Generalizing the second derivative

Consider a function with a two-dimensional input, such as
$f\left(x,y\right)={x}^{2}{y}^{3}$.
Its partial derivatives $\frac{\partial f}{\partial x}$ and $\frac{\partial f}{\partial y}$ take in that same two-dimensional input $\left(x,y\right)$:
$\begin{array}{rl}& \frac{\partial f}{\partial x}=\frac{\partial }{\partial x}\left({x}^{2}{y}^{3}\right)=2x{y}^{3}\\ \\ & \frac{\partial f}{\partial y}=\frac{\partial }{\partial y}\left({x}^{2}{y}^{3}\right)=3{x}^{2}{y}^{2}\end{array}$
Therefore, we could also take the partial derivatives of the partial derivatives.
These are called second partial derivatives, and the notation is analogous to the $\frac{{d}^{2}f}{d{x}^{2}}$ notation for the ordinary second derivative in single-variable calculus:
$\begin{array}{rl}\frac{\partial }{\partial x}\left(\frac{\partial f}{\partial x}\right)& =\frac{{\partial }^{2}f}{\partial {x}^{2}}\\ \\ \frac{\partial }{\partial x}\left(\frac{\partial f}{\partial y}\right)& =\frac{{\partial }^{2}f}{\partial x\partial y}\\ \\ \frac{\partial }{\partial y}\left(\frac{\partial f}{\partial x}\right)& =\frac{{\partial }^{2}f}{\partial y\partial x}\\ \\ \frac{\partial }{\partial y}\left(\frac{\partial f}{\partial y}\right)& =\frac{{\partial }^{2}f}{\partial {y}^{2}}\end{array}$
Using the ${f}_{x}$ notation for the partial derivative (in this case with respect to $x$), you might also see these second partial derivatives written like this:
$\begin{array}{rl}\left({f}_{x}{\right)}_{x}& ={f}_{xx}\\ \\ \left({f}_{y}{\right)}_{x}& ={f}_{yx}\\ \\ \left({f}_{x}{\right)}_{y}& ={f}_{xy}\\ \\ \left({f}_{y}{\right)}_{y}& ={f}_{yy}\end{array}$
The second partial derivatives which involve multiple distinct input variables, such as ${f}_{yx}$ and ${f}_{xy}$, are called "mixed partial derivatives"

## Example 1: The full tree

Problem: Find all the second partial derivatives of $f\left(x,y\right)=\mathrm{sin}\left(x\right){y}^{2}$
Solution: First, find both partial derivatives:
$\begin{array}{rl}\frac{\partial }{\partial x}\left(\mathrm{sin}\left(x\right){y}^{2}\right)& =\mathrm{cos}\left(x\right){y}^{2}\\ \\ \frac{\partial }{\partial y}\left(\mathrm{sin}\left(x\right){y}^{2}\right)& =2\mathrm{sin}\left(x\right)y\end{array}$
Then for each one, write both partial derivatives:
$\begin{array}{rl}\frac{\partial }{\partial x}\left(\frac{\partial }{\partial x}\left(\mathrm{sin}\left(x\right){y}^{2}\right)\right)& =\frac{\partial }{\partial x}\left(\mathrm{cos}\left(x\right){y}^{2}\right)=-\mathrm{sin}\left(x\right){y}^{2}\\ \\ \frac{\partial }{\partial x}\left(\frac{\partial }{\partial y}\left(\mathrm{sin}\left(x\right){y}^{2}\right)\right)& =\frac{\partial }{\partial x}\left(2\mathrm{sin}\left(x\right)y\right)=2\mathrm{cos}\left(x\right)y\\ \\ \frac{\partial }{\partial y}\left(\frac{\partial }{\partial x}\left(\mathrm{sin}\left(x\right){y}^{2}\right)\right)& =\frac{\partial }{\partial y}\left(\mathrm{cos}\left(x\right){y}^{2}\right)=2\mathrm{cos}\left(x\right)y\\ \\ \frac{\partial }{\partial y}\left(\frac{\partial }{\partial y}\left(\mathrm{sin}\left(x\right){y}^{2}\right)\right)& =\frac{\partial }{\partial y}\left(2\mathrm{sin}\left(x\right)y\right)=2\mathrm{sin}\left(x\right)\end{array}$
$\begin{array}{cc}& \mathrm{sin}\left(x\right){y}^{2}\\ \\ & \frac{\partial }{\partial x}↙\phantom{\rule{1em}{0ex}}↘\frac{\partial }{\partial y}\\ \\ & \mathrm{cos}\left(x\right){y}^{2}\phantom{\rule{2em}{0ex}}\phantom{\rule{2em}{0ex}}\phantom{\rule{2em}{0ex}}2\mathrm{sin}\left(x\right)y\\ \\ \frac{\partial }{\partial x}↙& ↘\frac{\partial }{\partial y}\phantom{\rule{2em}{0ex}}\phantom{\rule{2em}{0ex}}\phantom{\rule{2em}{0ex}}\frac{\partial }{\partial x}↙& ↘\frac{\partial }{\partial y}\\ \\ \mathrm{sin}\left(x\right){y}^{2}& \underset{\text{Mixed partial derivatives are the same!}}{\underset{⏟}{2\mathrm{cos}\left(x\right)y\phantom{\rule{2em}{0ex}}2\mathrm{cos}\left(x\right)y}}& 2\mathrm{sin}\left(x\right)\end{array}$

## Symmetry of second derivatives

Notice, in the example above, the two mixed partial derivatives $\frac{{\partial }^{2}f}{\partial x\partial y}$ and $\frac{{\partial }^{2}f}{\partial y\partial x}$ are the same. This is not a coincidence; it happens for almost every function you encounter in practice. For example, look at what happens to a general polynomial term ${x}^{n}{y}^{k}$:
$\begin{array}{rl}\frac{\partial }{\partial x}\left(\frac{\partial }{\partial y}\left({x}^{n}{y}^{k}\right)\right)& =\frac{\partial }{\partial x}\left(k{x}^{n}{y}^{k-1}\right)=nk{x}^{n-1}{y}^{k-1}\\ \\ \frac{\partial }{\partial y}\left(\frac{\partial }{\partial x}\left({x}^{n}{y}^{k}\right)\right)& =\frac{\partial }{\partial y}\left(n{x}^{n-1}{y}^{k}\right)=nk{x}^{n-1}{y}^{k-1}\end{array}$
Technically, the symmetry of second derivatives is not always true. There is a theorem, referred to variously as Schwarz's theorem or Clairaut's theorem, which states that symmetry of second derivatives will always hold at a point if the second partial derivatives are continuous around that point. To really get into the meat of this, we'd need some real analysis.
You should keep in the back of your mind that exceptions exist, but the symmetry of second derivatives work for just about every "normal" looking function that you will come across.

## Example 2: Higher order derivatives

Why stop at second partial derivatives? We could also take, say, five partial derivatives with respect to various input variables.
Problem: If $f\left(x,y,z\right)=\mathrm{sin}\left(xy\right){e}^{x+z}$, what is ${f}_{zyzyx}$?
Solution: The notation ${f}_{zyzyx}$ is shorthand for $\left(\left(\left(\left({f}_{z}{\right)}_{y}{\right)}_{z}{\right)}_{y}{\right)}_{x}$, so we differentiate with respect to $z$, then with respect to $y$, then $z$, then $y$, then $x$. That is, we read left to right.
It's worth pointing out that the order is different in the other notation:
$\begin{array}{r}\phantom{\rule{1em}{0ex}}\frac{\partial }{\partial x}\frac{\partial }{\partial y}\frac{\partial }{\partial z}\frac{\partial }{\partial y}\frac{\partial f}{\partial z}=\frac{{\partial }^{5}f}{\underset{{5}^{th}}{\underset{⏟}{\partial x}}\underset{{4}^{th}}{\underset{⏟}{\partial y}}\underset{{3}^{rd}}{\underset{⏟}{\partial z}}\underset{{2}^{nd}}{\underset{⏟}{\partial y}}\underset{{1}^{st}}{\underset{⏟}{\partial z}}}\end{array}$
So the order of differentiation is indicated by the order of the terms in the denominator from right to left.
Anyway, back to the problem at hand. This is one of those tasks where you just have to roll up your sleeves and slog through it, but to help things let's color the variables $x,y,z$ to keep track of where they all are:
$\begin{array}{rl}\phantom{\rule{1em}{0ex}}f\left(x,y,z\right)& =\mathrm{sin}\left(xy\right){e}^{x+z}\\ \\ {f}_{z}\left(x,y,z\right)& =\frac{\partial f}{\partial z}\left(\mathrm{sin}\left(xy\right){e}^{x+z}\right)\\ \\ & =\mathrm{sin}\left(xy\right){e}^{x+z}\\ \\ {f}_{zy}\left(x,y,z\right)& =\frac{\partial f}{\partial y}\left(\mathrm{sin}\left(xy\right){e}^{x+z}\right)\\ \\ & =\mathrm{cos}\left(xy\right)x{e}^{x+z}\\ \\ {f}_{zyz}\left(x,y,z\right)& =\frac{\partial f}{\partial z}\left(\mathrm{cos}\left(xy\right)x{e}^{x+z}\right)\\ \\ & =\mathrm{cos}\left(xy\right)x{e}^{x+z}\\ \\ {f}_{zyzy}\left(x,y,z\right)& =\frac{\partial f}{\partial y}\left(\mathrm{cos}\left(xy\right)x{e}^{x+z}\right)\\ \\ & =-\mathrm{sin}\left(xy\right){x}^{2}{e}^{x+z}\\ \\ {f}_{zyzyx}\left(x,y,z\right)& =\frac{\partial f}{\partial x}\left(-\mathrm{sin}\left(xy\right){x}^{2}{e}^{x+z}\right)\\ \\ & =\underset{\frac{\partial }{\partial x}\left(-\mathrm{sin}\left(xy\right)\right)}{\underset{⏟}{-\mathrm{cos}\left(xy\right)y}}{x}^{2}{e}^{x+z}\\ \\ & \phantom{=}-\mathrm{sin}\left(xy\right)\underset{\frac{\partial }{\partial x}{x}^{2}}{\underset{⏟}{2x}}{e}^{x+z}\\ \\ & \phantom{=}-\mathrm{sin}\left(xy\right){x}^{2}\underset{\frac{\partial }{\partial x}{e}^{x+z}}{\underset{⏟}{{e}^{x+z}}}\end{array}$
This last step uses the extended product rule,
$\begin{array}{rl}& \phantom{=}\frac{d}{dx}\left(f\left(x\right)g\left(x\right)h\left(x\right)\right)\\ \\ & ={f}^{\prime }\left(x\right)g\left(x\right)h\left(x\right)+f\left(x\right){g}^{\prime }\left(x\right)h\left(x\right)+f\left(x\right)g\left(x\right){h}^{\prime }\left(x\right)\end{array}$
Man! That was a tedious example. But if you could follow all the way through, computing multiple partial derivatives should not be an issue for you. It's one of those things that just requires more bookkeeping than anything else.

## Want to join the conversation?

• I would very much appreciate at least some geometric or visual component to this article because doing algebra's relatively easy but understanding what it actually means to take the partial derivative with respect to y of the partial derivative with respect to x of a function is not super clear to me
• http://facstaff.cbu.edu/wschrein/media/M232%20Notes/M232L73.pdf Gives an example. It essentially looks at how the slope of the tangent line changes as you go in some direction. (In case this is helpful, the original function in that example appears to be the function for the unit sphere in the first quadrant, x^2+y^2+z^2=1, or f(x,y) = sqrt(1-x^2-y^2))
• In example 2 - step 4 (f_zyzy), why does e^(x+z) change to e^(x+y)?
• Typo in tree? f_xx = -sin(x).y^2
• sorry.... shouldn't the final solution include 2x, not x^2? Why did it change back to x^2?
• It does seem confusing but it's part of the power rule. The solution is a big equation
(-cos(xy)y(x^2)(e^x+z)) + (-sin(xy)2x(e^x+z)) + (-sin(xy)(x^2)(e^x+z))
• f(x,y) = xy e^y , show that f_xy=fyx.
• f_x=(ye^y)1 and thus f_xy=(1e^y)+(ye^y)
f_y=x((1e^y)+(ye^y)) and thus f_yx= ((1e^y)+(ye^y))
Thus f_xy=f_yx
(1 vote)
• Why is e^x+z multiplied by x when we are taking a derivative with respect to y? Isn't x considered a constant and therefore the derivative of e^x+z be equal to e^x+z ?