# How to Solve Second-Order Partial Derivatives

#### Introduction

A frequent concern among students is how to carry out higher order partial derivatives where a change of variables and the chain rule are involved. There is often uncertainty about exactly what the “rules” are. This tutorial aims to clarify how the higher-order partial derivatives are formed in this case.

Note that in general second-order partial derivatives are more complicated than you might expect. It’s important, therefore, to keep calm and pay attention to the details.

#### The General Case

Imagine we have a function ##f(u, v)## and we want to compute the partial derivatives with respect to ##x## and ##y## in terms of those with respect to ##u## and ##v##. Here we assume that ##u, v## may be expressed as functions of ##x, y##. The first derivative usually cause no problems. We simply apply the chain rule:

$$\frac{\partial f}{\partial x} = \frac{\partial f}{\partial u}\frac{\partial u}{\partial x} + \frac{\partial f}{\partial v}\frac{\partial v}{\partial x} \ \ \ \text{(Chain Rule)}$$

$$\frac{\partial f}{\partial y} = \frac{\partial f}{\partial u}\frac{\partial u}{\partial y} + \frac{\partial f}{\partial v}\frac{\partial v}{\partial y} \ \ \ \text{(Chain Rule)}$$

A key point is that partial derivatives are regular functions. The same rules of differentiation apply to them as to the function ##f## itself. If we look closely at the chain rule here we see that we have something of the form:

$$\frac{\partial f}{\partial x} = g_1(u, v)\frac{\partial u}{\partial x} + g_2(u, v)\frac{\partial v}{\partial x}$$

Where ##g_1(u, v) = \frac{\partial f}{\partial u}, \ g_2(u, v) = \frac{\partial f}{\partial v}## are functions of ##u## and ##v##.

Note also that ##\frac{\partial u}{\partial x}## and ##\frac{\partial v}{\partial x}## are simply functions of ##x## and ##y##.

Writing it like this hopefully gives an insight into what is going to happen when we take the second derivative. The first step is to apply the product rule:

$$\frac{\partial^2 f}{\partial x^2} = \frac{\partial}{\partial x} \frac{\partial f}{\partial x} =g_1\frac{\partial^2 u}{\partial x^2} + \frac{\partial g_1}{\partial x}\frac{\partial u}{\partial x} + g_2\frac{\partial^2 v}{\partial x^2} + \frac{\partial g_2}{\partial x} \frac{\partial v}{\partial x}\ \ \ \text{(Product Rule)} \ \ \ (1)$$

For the partial derivatives of ##g_1## and ##g_2## we have the chain rule again:

$$\frac{\partial g_1}{\partial x} = \frac{\partial g_1}{\partial u}\frac{\partial u}{\partial x} + \frac{\partial g_1}{\partial v}\frac{\partial v}{\partial x} \ \ \ \text{(Chain Rule)}$$

And, plugging in ##g_1 = \frac{\partial f}{\partial u}## we see that:

$$\frac{\partial}{\partial x}\frac{\partial f}{\partial u} =\frac{\partial g_1}{\partial x} = \frac{\partial^2 f}{\partial u^2}\frac{\partial u}{\partial x} + \frac{\partial^2 f}{\partial v \partial u}\frac{\partial v}{\partial x} \ \ \ (2)$$

Likewise:

$$\frac{\partial g_2}{\partial x} = \frac{\partial g_2}{\partial u}\frac{\partial u}{\partial x} + \frac{\partial g_2}{\partial v}\frac{\partial v}{\partial x} \ \ \ \text{(Chain Rule)}$$

And:

$$\frac{\partial}{\partial x}\frac{\partial f}{\partial v} =\frac{\partial g_2}{\partial x} = \frac{\partial^2 f}{\partial u \partial v}\frac{\partial u}{\partial x} + \frac{\partial^2 f}{\partial v^2}\frac{\partial v}{\partial x} \ \ \ (3)$$

Combing equations ##(1), (2)## and ##(3)## we have:

$$\frac{\partial^2 f}{\partial x^2} = \frac{\partial f}{\partial u}\frac{\partial^2 u}{\partial x^2} + (\frac{\partial^2 f}{\partial u^2}\frac{\partial u}{\partial x} + \frac{\partial^2 f}{\partial v \partial u}\frac{\partial v}{\partial x})\frac{\partial u}{\partial x} + \frac{\partial f}{\partial v}\frac{\partial^2 v}{\partial x^2} + (\frac{\partial^2 f}{\partial u \partial v}\frac{\partial u}{\partial x} + \frac{\partial^2 f}{\partial v^2}\frac{\partial v}{\partial x})\frac{\partial v}{\partial x} \ \ \ (4)$$

This equation seems to be difficult for the student to derive, and often arises with one or more terms missing! As we have seen, the key to obtaining all the terms is to treat the partial derivatives (##\frac{\partial f}{\partial u}## and ##\frac{\partial f}{\partial v}##) as functions themselves and to apply the chain rule properly.

We can tidy up equation ##(4)## to get:

$$\frac{\partial^2 f}{\partial x^2} = \frac{\partial f}{\partial u}\frac{\partial^2 u}{\partial x^2} + \frac{\partial^2 f}{\partial u^2}(\frac{\partial u}{\partial x})^2 + 2\frac{\partial^2 f}{\partial u \partial v}\frac{\partial u}{\partial x}\frac{\partial v}{\partial x} + \frac{\partial f}{\partial v}\frac{\partial^2 v}{\partial x^2} + \frac{\partial^2 f}{\partial v^2}(\frac{\partial v}{\partial x})^2 \ \ \ (5)$$

We can see immediately by symmetry that:

$$\frac{\partial^2 f}{\partial y^2} = \frac{\partial f}{\partial u}\frac{\partial^2 u}{\partial y^2} + \frac{\partial^2 f}{\partial u^2}(\frac{\partial u}{\partial y})^2 + 2\frac{\partial^2 f}{\partial u \partial v}\frac{\partial u}{\partial y}\frac{\partial v}{\partial y} + \frac{\partial f}{\partial v}\frac{\partial^2 v}{\partial y^2} + \frac{\partial^2 f}{\partial v^2}(\frac{\partial v}{\partial y})^2 \ \ \ (6)$$

The mixed term I leave as an exercise. The result is:

$$\frac{\partial^2 f}{\partial x \partial y} = \frac{\partial f}{\partial u}\frac{\partial^2 u}{\partial x \partial y} + \frac{\partial^2 f}{\partial u^2}\frac{\partial u}{\partial x}\frac{\partial u}{\partial y} + \frac{\partial^2 f}{\partial u \partial v}(\frac{\partial u}{\partial x}\frac{\partial v}{\partial y} + \frac{\partial u}{\partial y}\frac{\partial v}{\partial x}) + \frac{\partial f}{\partial v}\frac{\partial^2 v}{\partial x \partial y} + \frac{\partial^2 f}{\partial v^2}\frac{\partial v}{\partial x}\frac{\partial v}{\partial y} \ \ \ (7)$$

Which, as promised, is more complicated than we may have expected.

#### Example

We now look at the simple but common case:

$$u = ax + by, \ \ v = cx + dy$$

Where ##a, b, c, d## are constants.

We have:

$$\frac{\partial u}{\partial x} = a, \ \ \frac{\partial u}{\partial y} = b, \ \ \frac{\partial v}{\partial x} = c, \ \ \frac{\partial v}{\partial y} = d$$

And the second derivatives of ##u## and ##v## vanish. Equations ##(5), (6)## and ##(7)## reduce to:

$$\frac{\partial^2 f}{\partial x^2} = a^2 \frac{\partial^2 f}{\partial u^2} + 2ac \frac{\partial^2 f}{\partial u \partial v} + c^2\frac{\partial^2 f}{\partial v^2} \ \ \ (5a)$$

$$\frac{\partial^2 f}{\partial y^2} = b^2 \frac{\partial^2 f}{\partial u^2} + 2bd \frac{\partial^2 f}{\partial u \partial v} + d^2\frac{\partial^2 f}{\partial v^2} \ \ \ (6a)$$

$$\frac{\partial^2 f}{\partial x \partial y} = ab \frac{\partial^2 f}{\partial u^2} + (ad + bc) \frac{\partial^2 f}{\partial u \partial v} + cd\frac{\partial^2 f}{\partial v^2} \ \ \ (7a)$$

#### The Inverse Case

If we have ##x## and ##y## expressed as functions of ##u## and ##v##, then we can invert the above equations simply by exchanging the roles of ##x, y## and ##u, v##. By inverting equation ##(5)##, for example, we get:

$$\frac{\partial^2 f}{\partial u^2} = \frac{\partial f}{\partial x}\frac{\partial^2 x}{\partial u^2} + \frac{\partial^2 f}{\partial x^2}(\frac{\partial x}{\partial u})^2 + 2\frac{\partial^2 f}{\partial x \partial y}\frac{\partial x}{\partial u}\frac{\partial y}{\partial u} + \frac{\partial f}{\partial y}\frac{\partial^2 y}{\partial u^2} + \frac{\partial^2 f}{\partial y^2}(\frac{\partial y}{\partial u})^2 \ \ \ (8)$$

#### Some Technical Points

Here we make a couple of technical observations. We have assumed above that the function ##f## is sufficiently well-behaved that ##\frac{\partial^2 f}{\partial u \partial v} = \frac{\partial^2 f}{\partial v \partial u}##. This is generally assumed to be the case for functions arising in applied mathematics and physics.

We blithely used the symbol ##f## as a function of both ##x, y## and ##u, v##. Technically, if we have ##u = u(x, y)## and ##v = v(x, y)##, then we should actually write something like:

$$F(x, y) = f(u(x, y), v(x, y))$$

And we can see that we are actually differentiating the function ##F## with respect to ##x## and ##y## above, where ##F## is a composition of the functions ##f, u, v##. And, we could have written, for example:

$$\frac{\partial F}{\partial x} = \frac{\partial f}{\partial u}\frac{\partial u}{\partial x} + \frac{\partial f}{\partial v}\frac{\partial v}{\partial x} \ \ \ \text{(Chain Rule)}$$

Again, in general, this distinction is often suppressed.

It depends how the change of variables arises. For polar coordinates we generally start from:

$$x = r\cos \phi, \ \ y = r\sin \phi$$

Which is the "inverse" case in the tutorial.

The important point is that, if you have a function of ##r, \phi##, then you must calculate the inverse functions:

$$r = \sqrt{x^2 + y^2}, \ \ \ \phi = \arctan \frac y x$$