The chain rule is a formula used to find the derivative of the composition of two functions, commonly referred to as a 'function of a function'.
Given two differentiable functions $f(x)$ and $g(x)$, the derivative with respect to $x$ of $f(g(x))$ ('$f$ composed with $g$') is given by
\[\frac{\mathrm{d} }{\mathrm{d}x}\Bigl[f\bigl(g(x)\bigl)\Bigl]=\dfrac{\mathrm{d}f}{\mathrm{d}g}\dfrac{\mathrm{d}g}{\mathrm{d}x}.\]
Note: The chain rule can be extended to compute the derivative of a composition of more than two functions.
Example: Given three functions $f(x)$, $g(x)$ and $h(x)$, the derivative of the composite function $f\bigl(g\bigl(h(x)\bigl)\bigl)$ is:
\begin{align}\dfrac{ \mathrm{d} }{\mathrm{d}x}\biggl[f\bigl(g\bigl(h(x)\bigl)\bigl)\biggl] =\dfrac{\mathrm{d}f}{\mathrm{d}g}\dfrac{\mathrm{d}g}{\mathrm{d}h}\dfrac{\mathrm{d}h}{\mathrm{d}x}. \end{align}
The chain rule can be used to find general formulae for the derivatives of an exponential function $ e^{ f(x) }$ and a logarithmic function $\ln\left\lvert f(x) \right\rvert$.
Consider $\dfrac{\mathrm{d{\mathrm{d} x}\left[ e^{f(x) }\right]$. By the chain rule:
\begin{align} \dfrac{\mathrm{d}}{\mathrm{d} x}\left[ e^{ f(x) }\right] &= \dfrac{\mathrm{d}}{\mathrm{d} f}\left[ e^{ f(x) }\right]\dfrac{\mathrm{d} f}{\mathrm{d} x} \\ &= e^{ f(x) }\dfrac{\mathrm{d} f}{\mathrm{d} x} \end{align}
Rearranging and introducing the prime notation gives the formula for the derivative of an exponential function $ e^{f(x) }$:
\[\dfrac{\mathrm{d}}{\mathrm{d} x}\left[ e^{ f(x) }\right]=f'(x) e^{ f(x) }.\]
Now consider $\dfrac{\mathrm{d}}{\mathrm{d} x}\Bigl[ \ln\left\lvert f(x) \right\rvert \Bigr]$. By the chain rule:
\begin{align} \dfrac{\mathrm{d}}{\mathrm{d} x}\Bigl[ \ln\left\lvert f(x) \right\rvert \Bigr] &= \dfrac{\mathrm{d}}{\mathrm{d} f}\Bigl[ \ln \left\lvert f(x) \right\rvert \Bigr] \dfrac{\mathrm{d} f}{\mathrm{d} x} \\ &=\dfrac{1}{f(x)}\dfrac{\mathrm{d} f}{\mathrm{d} x}. & & \left(\frac{\mathrm{d}}{\mathrm{d} f} \Bigl[ \ln f \Bigr] = \frac{1}{f} \right) \end{align}
In prime notation, this is:
\[\dfrac{\mathrm{d}}{\mathrm{d} x}\Bigl[ \ln \left\lvert f(x) \right \rvert \Bigr]=\dfrac{f'(x)}{f(x)}.\] }}
Given $f(x)=\ln{\vert x^2+1\vert}$, find $\dfrac{\mathrm{d}f}{\mathrm{d}x}$.
Let $g(x)=x^2+1$, so that $f(x) = \ln{\lvert x^2+1 \rvert} =\ln{\lvert g(x) \rvert}$.
By the chain rule, the derivative of $f$ with respect to $x$ is given by:
\begin{align} \dfrac{\mathrm{d} f}{\mathrm{d} x} &= \dfrac{\mathrm{d} f}{\mathrm{d} g}\dfrac{\mathrm{d} g}{\mathrm{d} x} \\ &= \dfrac{\mathrm{d} }{\mathrm{d} g}\Bigl[\ln{\vert g \vert}\Bigl] \cdot \dfrac{\mathrm{d} }{\mathrm{d} x}\Bigl[x^2+1\Bigl] \\ &= \dfrac{1}{g(x)} \cdot 2x \end{align}
This can be expressed in terms of $x$ by substituting $g(x)=x^2+1$:
\begin{align} \dfrac{\mathrm{d}f}{\mathrm{d}x} &= \dfrac{1}{g(x)} \cdot 2x \\ &=\dfrac{1}{x^2+1} \cdot 2x \\ &= \dfrac{2x}{x^2+1} \text{.} \end{align}
Given $f(x)=\mathrm{e}^{3x }+\cos({3x^2+5})$, find $\dfrac{\mathrm{d} f}{\mathrm{d} x}$.
We have
\[\dfrac{\mathrm{d} f}{\mathrm{d} x}=\dfrac{\mathrm{d} }{\mathrm{d} x}\Bigl[\mathrm{e}^{3x}+\cos({3x^2+5)}\Bigl].\]
Since differentiation is a linear operation, this is equivalent to
\[\dfrac{\mathrm{d} f}{\mathrm{d} x}=\dfrac{\mathrm{d} }{\mathrm{d} x}\Bigl[\mathrm{e}^{3x}\Bigl]+\dfrac{\mathrm{d} }{\mathrm{d} x}\Bigl[\cos{(3x^2+5)}\Bigl].\]
Set $g(x)=3x$ and $h(x)=3x^2+5$. Then by the chain rule,
\[\dfrac{\mathrm{d} f}{\mathrm{d} x}=\dfrac{\mathrm{d} g}{\mathrm{d} x}\dfrac{\mathrm{d} }{\mathrm{d} g}\Bigl[\mathrm{e}^{g}\Bigl]+\dfrac{\mathrm{d} h}{\mathrm{d} x}\dfrac{\mathrm{d} }{\mathrm{d} h}\Bigl[\cos{(h)}\Bigl].\]
By the standard rules of differentiation;
Thus,
\[\dfrac{\mathrm{d} f}{\mathrm{d} x}=3\mathrm{e}^{g}-6x\sin{(h)}.\]
Substitute the expressions for $g(x)$ and $h(x)$ back into the equation to obtain the derivative of $f(x)$:
\[\dfrac{\mathrm{d} f}{\mathrm{d} x}=3\mathrm{e}^{3x}-6x\sin{(3x^2+5)}.\]
Prof. Robin Johnson differentiates $\cos{(x^2+x^3)}$.
Prof. Robin Johnson differentiates $(2-3x)^8.$
Prof. Robin Johnson differentiates $\sqrt{\strut{\mathrm{e}^{\large{-x}}+\cos{2x} }}.$
Prof. Robin Johnson differentiates $\sin{\Bigl(\tan{(\mathrm{e}^{\large{2x} }-x)}\Bigl)}.$
This workbook produced by HELM is a good revision aid, containing key points for revision and many worked examples.
Test yourself: Numbas test on the chain rule
Test yourself: Numbas test on differentiation, including the chain, product and quotient rules