# Chain rule

1,016pages on
this wiki

The chain rule is a formula for finding the derivative of a composite function. It uses a variable $y$ depending on a second variable, $u$ , which in turn depend on a third variable, $x$.

$\frac{dy}{dx}=\frac{dy}{du}\cdot\frac{du}{dx}$

The derivative of any function is the derivative of the function itself, as per the power rule, then the derivative of the inside of the function.

$\frac{d}{dx}f(g(x))=f'(g(x))\cdot g'(x)$

and so on, for as many interwoven functions as there are.

For a multivariable function of $n$ variables, the chain rule becomes the dot product of the gradient and the derivative of a vector function.

$\frac{\partial}{\partial t}f(\mathbf{r}(t))=\frac{df}{dx_1}\cdot\frac{dx_1}{dt}\cdots\frac{df}{dx_n}\cdot\frac{dx_n}{dt}=\nabla f\cdot\mathbf{r}'(t)$

## Examples

• $f(g(x))=(3x+1)^2$
$f(g)=g^2\ ,\ g(x)=3x+1$
$f'(g)=2g\ ,\ g'(x)=3$
$f(g(x))'=2(3x+1)(3)=18x+6$

• $f(g(x))=\sin(x^2+2)$
$f(g)=\sin(g)\ ,\ g(x)=x^2+2$
$f'(g)=\cos(g)\ ,\ g'(x)=2x$
$f(g(x))'=\cos(x^2+2)\cdot2x=2x\cdot\cos(x^2+2)$

This can get rather crowded with more than 3 functions:

$\frac{d}{dx}\sec^3\left(\frac{x^3-12}{2x}\right)$

which has an inlaid Quotient rule, which results from taking the derivative of the inner piece.

Make sure that you take note of how many functions there are so that you know how many pieces you should have. Also, remember that the inside of the internal functions remain the same.

## Proof

Let $g:D\to\R$ be differentiable at $x$ , and let $f:g(D)\to\R$ be differentiable at $g(x)$ .

Define a function $F:g(D)\to\R$ such that

$F(z)=\begin{cases}\dfrac{f(z)-f(g(x))}{z-g(x)}&:z\ne g(x)\\f'(z)&:z=g(x)\end{cases}$

Note that $\lim_{z\to g(x)}F(z)=f'(g(x))$ , ie $F$ is continuous at $g(x)$ , and as $g$ is differentiable at $x$ it is also continuous there, so by continuity of composition $F\circ g$ is continuous at $x$ .

$\forall y\ne x\ ,\ \frac{f(g(y))-f(g(x))}{y-x}=\begin{cases}\dfrac{f(g(y))-f(g(x))}{g(y)-g(x)}\cdot\dfrac{g(y)-g(x)}{y-x}&:g(y)\ne g(x)\\0&:g(y)=g(x)\end{cases}$

which is equal to $F(g(y))\cdot\frac{g(y)-g(x)}{y-x}$ .

So

$\lim_{y\to x}\frac{f(g(y))-f(g(x))}{y-x}=\lim_{y\to x}F(g(y))\cdot\frac{g(y)-g(x)}{y-x}=F(g(x))\cdot g'(x)=f'(g(x))\cdot g'(x)$

with the second equality relying on the Algebra of Limits and continuity of $F\circ g$ at $x$ .

Therefore $f\circ g$ is differentiable at $x$ with derivative $f'(g(x))\cdot g'(x)$ .