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(x,y)=x2y3f(x, y) = x^2 y^3.
Its partial derivatives fx\dfrac{\partial f}{\partial x} and fy\dfrac{\partial f}{\partial y} take in that same two-dimensional input (x,y)(x, y):
fx=x(x2y3)=2xy3\begin{aligned} \dfrac{\partial f}{\partial \blueE{x}} = \dfrac{\partial}{\partial \blueE{x}}(\blueE{x}^2 y^3) = 2\blueE{x} y^3 \end{aligned}
fy=y(x2y3)=3x2y2\begin{aligned} \dfrac{\partial f}{\partial \redE{y}} = \dfrac{\partial}{\partial \redE{y}}(x^2 \redE{y}^3) = 3x^2 \redE{y}^2 \end{aligned}
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 d2fdx2\dfrac{d^2 f}{dx^2} notation for the ordinary second derivative in single-variable calculus:
x(fx)=2fx2x(fy)=2fxyy(fx)=2fyxy(fy)=2fy2\begin{aligned} \dfrac{\partial}{\partial \blueE{x}} \left(\dfrac{\partial f}{\partial \blueE{x}} \right) &= \dfrac{\partial^2 f}{\partial \blueE{x}^2} \\ \dfrac{\partial}{\partial \blueE{x}} \left(\dfrac{\partial f}{\partial \redE{y}} \right) &= \dfrac{\partial^2 f}{\partial \blueE{x} \partial \redE{y}} \\ \dfrac{\partial}{\partial \redE{y}} \left(\dfrac{\partial f}{\partial \blueE{x}} \right) &= \dfrac{\partial^2 f}{\partial \redE{y} \partial \blueE{x}} \\ \dfrac{\partial}{\partial \redE{y}} \left(\dfrac{\partial f}{\partial \redE{y}} \right) &= \dfrac{\partial^2 f}{\partial \redE{y}^2} \\ \end{aligned}
Using the fxf_x notation for the partial derivative (in this case with respect to xx), you might also see these second partial derivatives written like this:
(fx)x=fxx(fy)x=fyx(fx)y=fxy(fy)y=fyy\begin{aligned} (f_\blueE{x})_\blueE{x} &= f_{\blueE{x}\blueE{x}} \\ (f_\redE{y})_\blueE{x} &= f_{\redE{y}\blueE{x}} \\ (f_\blueE{x})_\redE{y} &= f_{\blueE{x}\redE{y}} \\ (f_\redE{y})_\redE{y} &= f_{\redE{y}\redE{y}} \\ \end{aligned}
The second partial derivatives which involve multiple distinct input variables, such as fyxf_{\redE{y}\blueE{x}} and fxy f_{\blueE{x}\redE{y}}, are called "mixed partial derivatives"

Example 1: The full tree

Problem: Find all the second partial derivatives of f(x,y)=sin(x)y2f(x, y) = \sin(x)y^2
Solution: First, find both partial derivatives:
x(sin(x)y2)=cos(x)y2y(sin(x)y2)=2sin(x)y\begin{aligned} \dfrac{\partial}{\partial \blueE{x}} (\sin(\blueE{x})y^2) &= \cos(\blueE{x})y^2 \\ \\ \dfrac{\partial}{\partial \redE{y}} (\sin(x)\redE{y}^2) &= 2\sin(x)\redE{y} \end{aligned}
Then for each one, write both partial derivatives:
x(x(sin(x)y2))=x(cos(x)y2)=sin(x)y2x(y(sin(x)y2))=x(2sin(x)y)=2cos(x)yy(x(sin(x)y2))=y(cos(x)y2)=2cos(x)yy(y(sin(x)y2))=y(2sin(x)y)=2sin(x)\begin{aligned} \dfrac{\partial}{\partial \blueE{x}}\left( \dfrac{\partial}{\partial x}(\sin(x)y^2) \right) &= \dfrac{\partial}{\partial \blueE{x}}(\cos(\blueE{x})y^2) = -\sin(\blueE{x})y^2 \\ \\ \dfrac{\partial}{\partial x}\left( \dfrac{\partial}{\partial y}(\sin(x)y^2) \right) &= \dfrac{\partial}{\partial \blueE{x}}(2\sin(\blueE{x})y) = 2\cos(\blueE{x})y \\ \\ \dfrac{\partial}{\partial \redE{y}}\left( \dfrac{\partial}{\partial x}(\sin(x)y^2) \right) &= \dfrac{\partial}{\partial \redE{y}}(\cos(x)\redE{y}^2) = 2\cos(x)\redE{y} \\ \\ \dfrac{\partial}{\partial \redE{y}}\left( \dfrac{\partial}{\partial y}(\sin(x)y^2) \right) &= \dfrac{\partial}{\partial \redE{y}}(2\sin(x)\redE{y}) = 2\sin(x) \\ \end{aligned}
Second partial derivative tree

Symmetry of second derivatives

Notice, in the example above, the two mixed partial derivatives 2fxy\dfrac{\partial^2 f}{\partial x \partial y} and 2fyx\dfrac{\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 xnykx^n y^k:
x(y(xnyk))=x(kxnyk1)=nkxn1yk1y(x(xnyk))=y(nxn1yk)=nkxn1yk1\begin{aligned} \frac{\partial}{\partial \blueE{x}}\left( \frac{\partial}{\partial \redD{y}}(\blueE{x}^n \redD{y}^k) \right) &= \frac{\partial}{\partial \blueE{x}}(k \blueE{x}^n \redD{y}^{k-1}) = nk \blueE{x}^{n-1} \redD{y}^{k-1} \\ \frac{\partial}{\partial \redD{y}}\left( \frac{\partial}{\partial \blueE{x}}(\blueE{x}^n \redD{y}^k) \right) &= \frac{\partial}{\partial \redD{y}}(n \blueE{x}^{n-1} \redD{y}^k) = nk \blueE{x}^{n-1} \redD{y}^{k-1} \\ \end{aligned}
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.
These mixed derivatives 2fxy\dfrac{\partial^2 f}{\partial x \partial y} and 2fyx\dfrac{\partial^2 f}{\partial y \partial x} evaluated at the origin (0,0)(0, 0) turn out to be 11 and 1-1 respectively. Computing this is actually pretty tricky, and requires looking directly at the limit-based definition of the derivative. Wikipedia provides a nice explanation, should you find yourself feeling ambitious.

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(x,y,z)=sin(xy)ex+zf(x, y, z) = \sin(xy)e^{x + z}, what is fzyzyxf_{zyzyx}?
Solution: The notation fzyzyxf_{zyzyx} is shorthand for ((((fz)y)z)y)x((((f_z)_y)_z)_y)_x, so we differentiate with respect to zz, then with respect to yy, then zz, then yy, then xx. That is, we read left to right.
It's worth pointing out that the order is different in the other notation:
xyzyfz=5fx5thy4thz3rdy2ndz1st\begin{aligned} \quad \dfrac{\partial}{\partial x} \dfrac{\partial}{\partial y} \dfrac{\partial}{\partial z} \dfrac{\partial}{\partial y} \dfrac{\partial f}{\partial z} = \dfrac{\partial^5 f}{ \underbrace{\partial x}_{5^{th}} \underbrace{\partial y}_{4^{th}} \underbrace{\partial z}_{3^{rd}} \underbrace{\partial y}_{2^{nd}} \underbrace{\partial z}_{1^{st}} } \end{aligned}
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\blueD{x}, \redD{y}, \greenE{z} to keep track of where they all are:
f(x,y,z)=sin(xy)ex+zfz(x,y,z)=fz(sin(xy)ex+z)=sin(xy)ex+zfzy(x,y,z)=fy(sin(xy)ex+z)=cos(xy)xex+zfzyz(x,y,z)=fz(cos(xy)xex+z)=cos(xy)xex+zfzyzy(x,y,z)=fy(cos(xy)xex+z)=sin(xy)x2ex+zfzyzyx(x,y,z)=fx(sin(xy)x2ex+z)=cos(xy)yx(sin(xy))x2ex+z=sin(xy)2xxx2ex+z=sin(xy)x2ex+zxex+z\begin{aligned} \quad f(\blueD{x}, \redD{y}, \greenE{z}) &= \sin(\blueD{x}\redD{y})e^{\blueD{x} + \greenE{z}} \\\\\\ f_{\greenE{z}}(\blueD{x}, \redD{y}, \greenE{z}) &= \dfrac{\partial f}{\partial \greenE{z}} \left( \sin(\blueD{x}\redD{y})e^{\blueD{x} + \greenE{z}} \right) \\\\ &= \sin(\blueD{x}\redD{y})e^{\blueD{x} + \greenE{z}} \\\\\\ f_{\greenE{z}\redD{y}}(\blueD{x}, \redD{y}, \greenE{z}) &= \dfrac{\partial f}{\partial \redD{y}} \left( \sin(\blueD{x}\redD{y})e^{\blueD{x} + \greenE{z}} \right) \\\\ &= \cos(\blueD{x}\redD{y})\blueD{x}e^{\blueD{x} + \greenE{z}} \\\\\\ f_{\greenE{z}\redD{y}\greenE{z}}(\blueD{x}, \redD{y}, \greenE{z}) &= \dfrac{\partial f}{\partial \greenE{z}} \left( \cos(\blueD{x}\redD{y})\blueD{x}e^{\blueD{x} + \greenE{z}} \right) \\\\ &= \cos(\blueD{x}\redD{y})\blueD{x}e^{\blueD{x} + \greenE{z}} \\\\\\ f_{\greenE{z}\redD{y}\greenE{z}\redD{y}}(\blueD{x}, \redD{y}, \greenE{z}) &= \dfrac{\partial f}{\partial \redD{y}} \left( \cos(\blueD{x}\redD{y})\blueD{x}e^{\blueD{x} + \greenE{z}} \right) \\\\ &= -\sin(\blueD{x}\redD{y})\blueD{x}^2 e^{\blueD{x} + \greenE{z}} \\\\\\ f_{\greenE{z}\redD{y}\greenE{z}\redD{y}\blueD{x}}(\blueD{x}, \redD{y}, \greenE{z}) &= \dfrac{\partial f}{\partial \blueD{x}} \left( -\sin(\blueD{x}\redD{y})\blueD{x}^2 e^{\blueD{x} + \greenE{z}} \right) \\\\ &= \underbrace{-\cos(\blueD{x}\redD{y})\redD{y}}_{ \frac{\partial}{\partial x} (-\sin(\blueD{x}\redD{y})) }\blueD{x}^2 e^{\blueD{x} + \greenE{z}} \\ &\phantom{=}-\sin(\blueD{x}\redD{y}) \underbrace{2\blueD{x}}_{ \frac{\partial}{\partial x}\blueD{x}^2 }e^{\blueD{x} + \greenE{z}} \\ &\phantom{=}-\sin(\blueD{x}\redD{y})\blueD{x}^2 \underbrace{e^{\blueD{x} + \greenE{z}}}_{ \frac{\partial}{\partial x} e^{\blueD{x} + \greenE{z}} } \end{aligned}
This last step uses the extended product rule,
=f(x)g(x)h(x)=f(x)g(x)h(x)+f(x)g(x)h(x)+f(x)g(x)h(x)\begin{aligned} &\phantom{=} f(x)g(x)h(x) \\\\ &= f'(x)g(x)h(x) + f(x)g'(x)h(x) + f(x)g(x)h'(x) \end{aligned}
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.
Loading