Differentiation and Integration in Several Real Variables/The chain rule and Clairaut's theorem

Let $$f:\R^m\to\R^n$$ be a function and let $$g:\R^n\to\R^l$$ be another function. Assume that $$g$$ is differentiable at $$x_0$$ and that $$f$$ is differentiable at $$g(x_0)$$.
 * Theorem

Then $$f\circ g$$ is differentiable at $$x_0$$ and
 * $$(f\circ g)'(x_0)=f'\big(g(x_0)\big)\circ g'(x_0)$$

We prove that $$f'(g(x_0))\circ g'(x_0)$$ is a valid differential of $$f\circ g$$, thereby proving differentiability.
 * Proof

We begin by noting from the second triangle inequality, that
 * $$\left|\frac{\Big\|g(x_0+\mathbf h)-g(x_0)\Big\|}{\|\mathbf h\|}-\frac{\|g'(x_0)\mathbf h\|}{\|\mathbf h\|}\right|\le\frac{\Big\|g(x_0+\mathbf h)-\big[g(x_0)+g'(x_0)\mathbf h\big]\Big\|}{\|\mathbf h\|}\to0,\mathbf h\to0$$

and hence the boundedness of
 * $$\frac{\|g'(x_0)\mathbf h\|}{\|\mathbf h\|}\le\frac{mn\max\limits_{1\le i\le n\atop1\le j\le m}|a_{i,j}|\|\mathbf h\|}{\|\mathbf h\|}$$

implies that of
 * $$\frac{\Big\|g(x_0+\mathbf h)-g(x_0)\Big\|}{\|\mathbf h\|}$$

where $$A=(a_{i,j})_{1\le i\le n\atop1\le j\le m}$$ is the matrix of $$g'(x_0)$$.

Now we note by the triangle inequality, that
 * $$\begin{align}

&\frac{\Big\|(f\circ g)(x_0+\mathbf h)-\big[(f\circ g)(x_0)+f'\big(g(x_0)\big)g'(x_0)\mathbf h\big]\Big\|}{\|\mathbf h\|}\\ &\le\frac{\bigg\|f\big(g(x_0+h)\big)-\Big[f\big(g(x_0)\big)+f'\big(g(x_0)\big)\big[g(x_0+h)-g(x_0)\big]\Big]\bigg\|}{\|\mathbf h\|}\\ &+\frac{\bigg\|f\big(g(x_0)\big)+f'\big(g(x_0)\big)\big[g(x_0+h)-g(x_0)\big]-\Big[(f\circ g)(x_0)+f'\big(g(x_0)\big)g'(x_0)\mathbf h\Big]\bigg\|}{\|\mathbf h\|} \end{align}$$ We shall first treat the first summand, which is more difficult, but not so difficult still. We rewrite it as
 * $$\frac{\bigg\|f\big(g(x_0+h)\big)-\Big[f\big(g(x_0)\big)+f'\big(g(x_0)\big)\big[g(x_0+h)-g(x_0)\big]\Big]\bigg\|}{\Big\|g(x_0+h)-g(x_0)\Big\|}\cdot\frac{\Big\|g(x_0+h)-g(x_0)\Big\|}{\|\mathbf h\|}$$

The latter factor is bounded due to the above considerations, and the first one converges to 0 as $$h\to0$$ (and thus $$g(x_0+h)\to g(x_0)$$ due to the same boundedness (multiply with $$\|h\|$$); in fact, differentiability thus implies continuity).

Now for the second summand, which, by elementary cancellation and linearity of differentials, equals
 * $$\frac{\bigg\|f'\big(g(x_0)\big)\Big[\big[g(x_0+h)-g(x_0)\big]-g'(x_0)\mathbf h\Big]\bigg\|}{\|\mathbf h\|}\le mn\max_{1\le i\le l\atop1\le j\le n}|b_{i,j}|\frac{\Big\|\big[g(x_0+h)-g(x_0)\big]-g'(x_0)\mathbf h\Big\|}{\|\mathbf h\|}$$

where $$B=(b_{i,j})_{1\le i\le l\atop1\le j\le n}$$ is the matrix of the differential of $$f$$. This goes to 0 as $$\mathbf h\to0$$ due to the definition of the differential of $$f$$.

$$\blacksquare$$

The gradient
The first application of the chain rule that we shall present has something to do with a thing called gradient, which is defined for functions $$f: \mathbb R^n \to \mathbb R$$, that is, the image is one-dimensional (in the special case $$n=2$$ these functions look like "mountains" of a function on the plane $$\mathbb R^2$$).

Definition:

Let $$f: \mathbb R^n \to \mathbb R$$ be differentiable. Then the column vector
 * $$\nabla f (x) := \begin{pmatrix}

\frac{\partial f}{\partial x_1} \\ \vdots \\ \frac{\partial f}{\partial x_n} \end{pmatrix}$$ is called the gradient.

Theorem:

Let $$f, g: \mathbb R^n \to \mathbb R$$ be two functions totally differentiable at $$x_0$$. Since they both map to $$\mathbb R$$, their product is defined, and we have
 * $$\nabla (fg) = f \nabla g + g \nabla f$$.

Proof:

Now one could compute this directly from the definition of the gradient and the usual one-dimensional product rule (which actually has the merit of not requiring total differentiability), but there is a clever trick using the chain rule, which I found in Terence Tao's lecture notes, on which I based my repetition of this part of mathematics.

We simply define $$h: \mathbb R^n \to \mathbb R^2, h(x) := (f(x), g(x))$$ and $$i : \mathbb R^2 \to \mathbb R, i(x, y) := x \cdot y$$. Then the function $$f \times g$$ equals $$i \circ h$$. Now the differential of $$i$$ is given by the Jacobian matrix
 * $$J_i(x, y) = \begin{pmatrix}

y & x \end{pmatrix}$$, and the differential of $$h$$ is given by the Jacobian matrix
 * $$J_h(x) = \begin{pmatrix}

\frac{\partial f}{\partial x_1}(x) & \cdots & \frac{\partial f}{\partial x_n}(x)\\ \frac{\partial g}{\partial x_1}(x) & \cdots & \frac{\partial g}{\partial x_n}(x) \end{pmatrix}$$. Hence, the product rule implies that the differential of $$i \circ h$$ at $$x$$ is given by
 * $$\begin{pmatrix}

g(x) & f(x) \end{pmatrix}\begin{pmatrix} \frac{\partial f}{\partial x_1}(x) & \cdots & \frac{\partial f}{\partial x_n}(x)\\ \frac{\partial g}{\partial x_1}(x) & \cdots & \frac{\partial g}{\partial x_n}(x) \end{pmatrix}$$, and from the definition of the gradient we see that the differential is nothing but the transpose of the gradient (and vice versa, as taking transpose is idempotent).

Now we shall use the chain rule to generalize a well-known theorem from one dimension, the mean value theorem, to several dimensions.

Theorem:

Let $$f: \mathbb R^n \to \mathbb R$$ be totally differentiable, and let $$a \neq b \in \mathbb R^n$$. Then there exists $$t \in [0, 1]$$ such that
 * $$f(b) - f(a) = \langle b - a, \nabla f(t b + (1 - t)a) \rangle$$,

where $$\langle \cdot, \cdot \rangle$$ is the standard scalar product on $$\mathbb R^n$$.

Proof:

This is actually a straightforward application of the chain rule.

We set
 * $$g(\lambda) := f((1 - \lambda) a + \lambda b)$$;

thus $$g(0) = f(a)$$ and $$g(1) = f(b)$$. By the one-dimensional mean-value theorem,
 * $$g(1) - g(0) = g'(t)$$

for a suitable $$t \in [0,1]$$. Now by the chain rule,
 * $$g'(t) = \langle b - a, \nabla f(t b + (1 - t)a) \rangle$$.

Clairaut's theorem
The next theorem shows that the order of differentiation does not matter, provided that the considered function is sufficiently differentiable. We will not need the general chain rule or any of its consequences during the course of the proof, but we will use the one-dimensional mean-value theorem.

Proof:

We begin with the following lemma:

Lemma:
 * $$\partial_j \partial_i f(x) = \lim_{\delta \to 0} \frac{f(x) - f(x + \delta e_i) - f(x + \delta e_j) + f(x + \delta(e_i + e_j))}{\delta^2}$$.

Proof: We first apply the fundamental theorem of calculus to obtain that the above limit equals
 * $$\lim_{\delta \to 0} \frac{\int_0^\delta \partial_i f(x + s e_i) ds - \int_0^\delta \partial_i f(x + \delta e_j + s e_i) ds}{\delta^2}$$.

Using integration by substitution and linearity of the integral, we may rewrite this as
 * $$\lim_{\delta \to 0} \frac{\int_0^1 \left( \partial_i f(x + \delta s e_i) - \partial_i f(x + \delta e_j + \delta s e_i) \right) ds}{\delta}$$.

Now we apply the mean value theorem in one variable to obtain
 * $$\partial_i f(x + \delta s e_i) - \partial_i f(x + \delta e_j + \delta s e_i) = \delta \partial_j \partial_i f(x + \delta s e_i + t_\delta e_j)$$

for a suitable $$t_\delta \in [0, \delta]$$. Hence, the above limit equals
 * $$\lim_{\delta \to 0} \int_0^1 \partial_j \partial_i f(x + \delta s e_i + t_\delta e_j) ds$$.

This is the average of $$\partial_j \partial_i f$$ over a certain subset of $$B_\delta(x)$$ and therefore converges to $$\partial_j \partial_i f(x)$$ by the continuity of $$\partial_j \partial_i f$$ (you can prove this rigorously by using
 * $$\partial_j \partial_i f(x) = \int_0^1 \partial_j \partial_i f(x) ds$$

and subtracting the integrals and applying the triangle inequality for integrals).

Now the expression of the lemma is totally symmetric in $$i$$ and $$j$$, which is why Clairaut's theorem follows.