# The Derivative Chain Rule
> In calculus, **the chain rule is a formula that expresses the derivative of the composition of two differentiable functions f and g in terms of the derivatives of f and g**.
> [Wikipedia](https://en.wikipedia.org/wiki/Chain%20rule)
For functions $f$ and $g$ of $x$, the derivative of their composition is:
$\frac d {dx}\bigg[f \circ g\bigg] = \frac {df} {dg} \cdot \frac {dg} {dx}$
The $\circ$ operator indicates function composition, so $f \circ g$ means $f(g(x))$.
^qnzl9i
First you evaluate the $f$ derivative at the 'stuff' (inside brackets, in this case $g(x)$), and then you multiply by the derivative of the 'stuff'.
## Reasoning 1
Let's look at $f(x) = \sin(2x)$. We can start by labeling the inside as $h(x) = 2x$.
$f$ then becomes $f(x) = \sin(h)$. And $df = \cos h \, dh$. However we're interested in the change of $f$ for a change of $x$, so we need to substitute $dh$ back into the last expression
$dh = 2dx$ so
$df = \cos (2x) 2 \, dx$
This reasoning comes from 3Blue1Brown: https://www.youtube.com/watch?v=YG15m2VwSjA&list=PLZHQObOWTQDMsr9K-rj53DwVRMYO3t5Yr
## Reasoning 2
When trying to reason about the chain look at $f(x) = \sin(x)$ and $h(x) = \sin(2x)$ as an example, and look at the derivative of the two functions close to the second hump:
<img src="https://d18l82el6cdm1i.cloudfront.net/uploads/Bc0r19TS7B-c3q4p2.svg" style="background: white; padding: 10px; width: 400px" />
The slope of $\sin(2x)$ evaluated at $a$ twice as big as the derivative of $\sin(x)$ evaluated at $b$. The factor 2 corresponds to the derivative of the inner function $g(x) = 2x$. This tells us that the derivatives multiply, when evaluated at corresponding points.
Here's another illustration of the same point:
<img src="https://d18l82el6cdm1i.cloudfront.net/uploads/N2Lq5cTRRl-c3q4p4.svg" style="background: white; padding: 10px; width: 400px" />
Lets look at the function $g$ and assume that $g'(a)=2$. If we increase $g$ input by $\Delta x$, $g$ output will increase by $2\Delta x$.
Also assume that $f'(b) = 3$. This means that if we increase $b$ by a small amount, $f$ output will increase by a factor of 3. So in total, if we increase the input of $f \circ g$ by a small amount, its output will increase by a factor of 6.
Now remember that $b = g(a)$, so we can say that the derivative of $f \circ g$ is $f'(b) \cdot g'(a) = f'(g(a)) \cdot g'(a)$.
> When doing $g$ and then $f$, the magnifying factors multiply, and hence the derivatives just multiply.
>
> But remember we have to multiply the derivatives at the corresponding points — that is, the derivative of $g$ at $a$ times the derivative of $f$ at $b$.[^1]
[^1]: Brilliant. Calculus Fundamentals. The Chain Rule.
## Reciprocal Derivatives
Reciprocal derivatives can be determined using the chain rule
$\frac d {dx}\left[ \frac 1 f \right] = - f^{-2} \cdot \frac {df} {dx}$ ^1vw3jd