Calculus/The chain rule and Clairaut's theorem

 ← Derivatives of multivariate functions Calculus Inverse function theorem, implicit function theorem → The chain rule and Clairaut's theorem
Theorem

Let ${\displaystyle f:\mathbb {R} ^{m}\to \mathbb {R} ^{n}}$ be a function and let ${\displaystyle g:\mathbb {R} ^{n}\to \mathbb {R} ^{l}}$ be another function. Assume that ${\displaystyle g}$ is differentiable at ${\displaystyle x_{0}}$ and that ${\displaystyle f}$ is differentiable at ${\displaystyle g(x_{0})}$ .

Then ${\displaystyle f\circ g}$ is differentiable at ${\displaystyle x_{0}}$ and

${\displaystyle (f\circ g)'(x_{0})=f'{\big (}g(x_{0}){\big )}\circ g'(x_{0})}$
Proof

We prove that ${\displaystyle f'(g(x_{0}))\circ g'(x_{0})}$ is a valid differential of ${\displaystyle f\circ g}$ , thereby proving differentiability.

We begin by noting from the second triangle inequality, that

${\displaystyle \left|{\frac {{\big \|}g(x_{0}+\mathbf {h} )-g(x_{0}){\big \|}}{\|\mathbf {h} \|}}-{\frac {\|g'(x_{0})\mathbf {h} \|}{\|\mathbf {h} \|}}\right|\leq {\frac {{\Big \|}g(x_{0}+\mathbf {h} )-{\big [}g(x_{0})+g'(x_{0})\mathbf {h} {\big ]}{\Big \|}}{\|\mathbf {h} \|}}\to 0,\mathbf {h} \to 0}$

and hence the boundedness of

${\displaystyle {\frac {\|g'(x_{0})\mathbf {h} \|}{\|\mathbf {h} \|}}\leq {\frac {mn\max \limits _{1\leq i\leq n \atop 1\leq j\leq m}|a_{i,j}|\|\mathbf {h} \|}{\|\mathbf {h} \|}}}$

implies that of

${\displaystyle {\frac {{\big \|}g(x_{0}+\mathbf {h} )-g(x_{0}){\big \|}}{\|\mathbf {h} \|}}}$

where ${\displaystyle A=(a_{i,j})_{1\leq i\leq n \atop 1\leq j\leq m}}$ is the matrix of ${\displaystyle g'(x_{0})}$ .

Now we note by the triangle inequality, that

{\displaystyle {\begin{aligned}&{\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} \|}}\\&\leq {\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{aligned}}}

We shall first treat the first summand, which is more difficult, but not so difficult still. We rewrite it as

${\displaystyle {\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 ${\displaystyle h\to 0}$ (and thus ${\displaystyle g(x_{0}+h)\to g(x_{0})}$ due to the same boundedness (multiply with ${\displaystyle \|h\|}$); in fact, differentiability thus implies continuity).

Now for the second summand, which, by elementary cancellation and linearity of differentials, equals

${\displaystyle {\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} \|}}\leq mn\max _{1\leq i\leq l \atop 1\leq j\leq n}|b_{i,j}|{\frac {{\Big \|}{\big [}g(x_{0}+h)-g(x_{0}){\big ]}-g'(x_{0})\mathbf {h} {\Big \|}}{\|\mathbf {h} \|}}}$

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

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 ${\displaystyle f:\mathbb {R} ^{n}\to \mathbb {R} }$, that is, the image is one-dimensional (in the special case ${\displaystyle n=2}$ these functions look like "mountains" of a function on the plane ${\displaystyle \mathbb {R} ^{2}}$).

Definition

Let ${\displaystyle f:\mathbb {R} ^{n}\to \mathbb {R} }$ be differentiable. Then the column vector

${\displaystyle \nabla f(x):={\begin{pmatrix}{\dfrac {\partial f}{\partial x_{1}}}\\\vdots \\{\dfrac {\partial f}{\partial x_{n}}}\end{pmatrix}}}$

Theorem:

Let ${\displaystyle f,g:\mathbb {R} ^{n}\to \mathbb {R} }$ be two functions totally differentiable at ${\displaystyle x_{0}}$. Since they both map to ${\displaystyle \mathbb {R} }$, their product is defined, and we have

${\displaystyle \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 ${\displaystyle h:\mathbb {R} ^{n}\to \mathbb {R} ^{2},h(x):={\big (}f(x),g(x){\big )}}$ and ${\displaystyle i:\mathbb {R} ^{2}\to \mathbb {R} ,i(x,y):=x\cdot y}$. Then the function ${\displaystyle f\times g}$ equals ${\displaystyle i\circ h}$. Now the differential of ${\displaystyle i}$ is given by the Jacobian matrix

${\displaystyle J_{i}(x,y)=(y\ x)}$

and the differential of ${\displaystyle h}$ is given by the Jacobian matrix

${\displaystyle J_{h}(x)={\begin{pmatrix}{\dfrac {\partial f}{\partial x_{1}}}(x)&\cdots &{\dfrac {\partial f}{\partial x_{n}}}(x)\\{\dfrac {\partial g}{\partial x_{1}}}(x)&\cdots &{\dfrac {\partial g}{\partial x_{n}}}(x)\end{pmatrix}}}$

Hence, the product rule implies that the differential of ${\displaystyle i\circ h}$ at ${\displaystyle x}$ is given by

${\displaystyle {\begin{pmatrix}g(x)&f(x)\end{pmatrix}}{\begin{pmatrix}{\dfrac {\partial f}{\partial x_{1}}}(x)&\cdots &{\dfrac {\partial f}{\partial x_{n}}}(x)\\{\dfrac {\partial g}{\partial x_{1}}}(x)&\cdots &{\dfrac {\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).${\displaystyle \Box }$

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 ${\displaystyle f:\mathbb {R} ^{n}\to \mathbb {R} }$ be totally differentiable, and let ${\displaystyle a\neq b\in \mathbb {R} ^{n}}$. Then there exists ${\displaystyle t\in [0,1]}$ such that

${\displaystyle f(b)-f(a)={\bigl \langle }b-a,\nabla f{\bigl (}tb+(1-t)a{\bigr )}{\bigr \rangle }}$

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

Proof:

This is actually a straightforward application of the chain rule.

We set

${\displaystyle g(\lambda ):=f{\bigl (}(1-\lambda )a+\lambda b{\bigr )}}$

thus ${\displaystyle g(0)=f(a)}$ and ${\displaystyle g(1)=f(b)}$. By the one-dimensional mean-value theorem,

${\displaystyle g(1)-g(0)=g'(t)}$

for a suitable ${\displaystyle t\in [0,1]}$. Now by the chain rule,

${\displaystyle g'(t)={\bigl \langle }b-a,\nabla f{\bigl (}tb+(1-t)a{\bigr )}{\bigr \rangle }}$.${\displaystyle \Box }$

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.

Theorem (Clairaut's theorem):

Let ${\displaystyle f:\mathbb {R} ^{n}\to \mathbb {R} }$ be such that the partial derivatives up to order 2 exist and are continuous. Then

${\displaystyle \partial _{i}\partial _{j}f=\partial _{j}\partial _{i}f}$.

Proof:

We begin with the following lemma:

Lemma:

${\displaystyle \partial _{j}\partial _{i}f(x)=\lim _{\delta \to 0}{\frac {f(x)-f(x+\delta e_{i})-f(x+\delta e_{j})+f{\bigl (}x+\delta (e_{i}+e_{j}){\bigr )}}{\delta ^{2}}}}$

Proof: We first apply the fundamental theorem of calculus to obtain that the above limit equals

${\displaystyle \lim _{\delta \to 0}{\frac {1}{\delta ^{2}}}\left(\int \limits _{0}^{\delta }\partial _{i}f(x+se_{i})ds-\int \limits _{0}^{\delta }\partial _{i}f(x+\delta e_{j}+se_{i})ds\right)}$

Using integration by substitution and linearity of the integral, we may rewrite this as

${\displaystyle \lim _{\delta \to 0}{\frac {1}{\delta }}\int \limits _{0}^{1}{\bigl (}\partial _{i}f(x+\delta se_{i})-\partial _{i}f(x+\delta e_{j}+\delta se_{i}){\bigr )}ds}$

Now we apply the mean value theorem in one variable to obtain

${\displaystyle \partial _{i}f(x+\delta se_{i})-\partial _{i}f(x+\delta e_{j}+\delta se_{i})=\delta \partial _{j}\partial _{i}f(x+\delta se_{i}+t_{\delta }e_{j})}$

for a suitable ${\displaystyle t_{\delta }\in [0,\delta ]}$. Hence, the above limit equals

${\displaystyle \lim _{\delta \to 0}\int \limits _{0}^{1}\partial _{j}\partial _{i}f(x+\delta se_{i}+t_{\delta }e_{j})ds}$

This is the average of ${\displaystyle \partial _{j}\partial _{i}f}$ over a certain subset of ${\displaystyle B_{\delta }(x)}$ and therefore converges to ${\displaystyle \partial _{j}\partial _{i}f(x)}$ by the continuity of ${\displaystyle \partial _{j}\partial _{i}f}$ (you can prove this rigorously by using

${\displaystyle \partial _{j}\partial _{i}f(x)=\int \limits _{0}^{1}\partial _{j}\partial _{i}f(x)ds}$

and subtracting the integrals and applying the triangle inequality for integrals).${\displaystyle \Box }$

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