2.10 Partial derivatives

As problems get more complicated, there are almost always multiple variables involved. Suppose we have the function

f(x,y)=x2yf(x,y) = x^2y

and we are told to find its derivative. This is an ambiguous request, and could mean several different things. For a function of several variables, a partial derivative of ff with respect to xx means to calculate the ordinary derivative treating ff as a function of xx alone with all the other variables held constant. This is denoted f/x\partial f / \partial x.

For the example above, taking the derivative with respect to xx would yield 2xy2xy, whereas taking the derivative with respect to yy, would yield x2x^2.

To give a further example, as well as introduce notation, for the function f(x,y,z)=x3z/yf(x,y,z) = x^3z/y, the partial derivatives with respect to x, y, and z would be written as:

x(x3zy)=3x2zyy(x3zy)=x3zy2z(x3zy)=x3y\begin{align*} \frac{\partial}{\partial x} \left( \frac{x^3z}{y} \right) &= \frac{3x^2z}{y} \\ \frac{\partial}{\partial y} \left( \frac{x^3z}{y} \right) &= \frac{-x^3z}{y^2} \\ \frac{\partial}{\partial z} \left( \frac{x^3z}{y} \right) &= \frac{x^3}{y} \end{align*}

In each partial derivative, two of the input variables are treated as constants. For example, when we take x\frac{\partial}{\partial x}, the z/yz/y portion of the function is treated as a constant, and so on. Conceptually, a partial derivative represents the instantaneous rate of change in a function when only one of its input variables is changed while keeping all other input variables constant. Thus, ff is changing at the rate 3(2)2(4)/33(2)^2(4)/3 as we increase xx from, say, 2 to 2.001 when x=2x=2, y=3y=3, and z=4z=4.

Higher orders

Partial derivatives can also be taken to the second order, such as

2x2(x3zy)=x(x(x3zy))=x(3x2zy)=6xzy2z2(x3zy)=z(z(x3zy))=z(x3y)=0.\begin{align*} \frac{\partial^2}{\partial x^2} \left( \frac{x^3z}{y} \right) &= \frac{\partial}{\partial x}(\frac{\partial}{\partial x}(\frac{x^3z}{y})) \\ &= \frac{\partial}{\partial x}(\frac{3x^2z}{y}) \\ &= \frac{6xz}{y} \\ \\ \frac{\partial^2}{\partial z^2} \left( \frac{x^3z}{y} \right) &= \frac{\partial}{\partial z}(\frac{\partial}{\partial z}(\frac{x^3z}{y})) \\ &= \frac{\partial}{\partial z}(\frac{x^3}{y}) \\ &= 0. \end{align*}

Higher-order partial derivatives can also be “mixed”, meaning that we take a derivative first with respect to one variable, then with respect to a different variable. In terms of mathematical symbols, 2f/xy\partial^2 f / \partial x \partial y is the same as /x(f/y)\partial / \partial x ( \partial f / \partial y). A couple examples using the same f(x,y,z)=x3z/yf(x,y,z) = x^3z/y are given below:

2xy(x3zy)=xy(x3zy)=x(x3zy2)=3x2zy22zx(x3zy)=zx(x3zy)=z(3x2zy)=3x2y\begin{align*} \frac{\partial^2}{\partial x\partial y} \left( \frac{x^3z}{y} \right) &= \frac{\partial}{\partial x}\frac{\partial}{\partial y} (\frac{x^3z}{y}) \\ &= \frac{\partial}{\partial x} (\frac{-x^3z}{y^2}) \\ &= \frac{-3x^2z}{y^2} \\ \\ \frac{\partial^2}{\partial z\partial x} \left( \frac{x^3z}{y} \right) &= \frac{\partial}{\partial z}\frac{\partial}{\partial x} (\frac{x^3z}{y}) \\ &= \frac{\partial}{\partial z} (\frac{3x^2z}{y}) \\ &= \frac{3x^2}{y} \end{align*}

It is worth noting (and a bit surprising) that the order is irrelevant, a result known as Clairaut’s Theorem. If 2f/xy\partial^2 f / \partial x \partial y and 2f/yx\partial^2 f / \partial y \partial x are both continuous, then

2fxy=2fyx.\frac{\partial^2 f}{\partial x \partial y} = \frac{\partial^2 f}{\partial y \partial x}.

Partial derivatives have many uses in statistics, but the main ideas above are all you really need to know for the first year. Later years will have an increasing focus on multivariable mathematical statistics.

Gradients

A closely related idea to the partial derivative is that of the gradient, which simply collects all of the partial derivatives of a function into a vector, symbolized by f(x)\nabla f(\mathbf{x}), where x\mathbf{x} represents the vector (x1,x2,,xn)(x_1, x_2, \ldots, x_n):

f(x1,...,xn)=[f(x)x1f(x)x2f(x)xn]\nabla f(x_1, ..., x_n) = \begin{bmatrix} \frac{\partial f(\mathbf{x})}{\partial x_1} \\ \frac{\partial f(\mathbf{x})}{\partial x_2} \\ \vdots \\ \frac{\partial f(\mathbf{x})}{\partial x_n} \end{bmatrix}

Again, gradients will play a larger role in later years than they do in the first year, but familiarity with the basic idea now will help. One reason (among many) that gradients are useful is that in multiple dimensions, there are infinitely many ways we could change the input: we could increase xx a little while decreasing yy at the same rate but change zz three times as fast, and so on. With the gradient, we can calculate these changes by taking the inner product of the gradient and direction: f(x)d\nabla f(\mathbf{x}) ^{\scriptstyle\top}\mathbf{d}, where d\mathbf{d} is the direction.