# Calculus: Derivatives II

## Chain Rule

The previous two sections have shown how to take the derivative of the product and quotient of two differentiable functions. But what about a function whose argument is another function? That is to say, what about a function of the form $f(g(x))$, such as $\cos(x^2)$? There are many proofs of the Chain Rule, the origin of whose name will become apparent with the completion of the derivation. Like in the previous two sections, the trick here is to multiply by $1$:

$\dfrac{d}{dx}f(g(x)) = \lim\limits_{x \rightarrow a} \dfrac{f(g(x)) - f(g(a))}{x - a} \\ \dfrac{d}{dx}f(g(x)) = \lim\limits_{x \rightarrow a} \dfrac{f(g(x)) - f(g(a))}{x - a} \cdot \dfrac{g(x)-g(a)}{g(x) - g(a)} \\ \dfrac{d}{dx}f(g(x)) = \lim\limits_{x \rightarrow a} \dfrac{f(g(x)) - f(g(a))}{g(x) - g(a)} \cdot \dfrac{g(x)-g(a)}{x - a} \\ \dfrac{d}{dx}f(g(x)) = \left(\lim\limits_{x \rightarrow a} \dfrac{f(g(x)) - f(g(a))}{g(x) - g(a)}\right)\left( \lim\limits_{x \rightarrow a}\dfrac{g(x)-g(a)}{x - a} \right)\\ \dfrac{d}{dx}f(g(x)) = f'(g(x))g'(x) \\$

The name "Chain Rule" comes from the fact that the outside function is differentiated, then multiplied by the derivative of the inside function. If the inside function is itself a compound function, the inner-inner function gets differentiated and added the the product, and so on.

## Problems

1. Differentiate with respect to $x$: $y=\sin(2x)$

$\dfrac{d}{dx}y = \dfrac{d}{dx}\sin(2x) \\ \dfrac{dy}{dx} = \cos(2x)\left(\dfrac{d}{dx}2x\right) \\ \dfrac{dy}{dx} = \cos(2x)\left(2\right) \\ \dfrac{dy}{dx} = 2\cos(2x) \\$
2. Differentiate with respect to $x$: $y=\tan(2x+2) - \sin\left(4x^3-2x^2\right)$

$\dfrac{d}{dx}y = \dfrac{d}{dx}\left(\tan(2x+2) - \sin\left(4x^3-2x^2\right)\right) \\ \dfrac{dy}{dx} = \dfrac{d}{dx}\tan(2x+2) - \dfrac{d}{dx}\sin\left(4x^3-2x^2\right) \\ \dfrac{dy}{dx} = \sec^2(2x+2)\left(\dfrac{d}{dx}(2x+2)\right) - \cos\left(4x^3-2x^2\right)\left(\dfrac{d}{dx}\left(4x^3-2x^2\right)\right) \\ \dfrac{dy}{dx} = \sec^2(2x+2)(2) - \cos\left(4x^3-2x^2\right)\left(12x^2-4x\right) \\ \dfrac{dy}{dx} = 2\sec^2(2x+2) - \left(12x^2-4x\right)\cos\left(4x^3-2x^2\right) \\$
3. Differentiate with respect to $x$: $y=e^{x^2}$

$\dfrac{d}{dx}y = \dfrac{d}{dx}e^{x^2} \\ \dfrac{dy}{dx} = e^{x^2}\left(\dfrac{d}{dx}x^2\right) \\ \dfrac{dy}{dx} = e^{x^2}\left(2x\right) \\ \dfrac{dy}{dx} = 2xe^{x^2} \\$
4. Differentiate with respect to $x$: $y=e^{e^x}$

$\dfrac{d}{dx}y = \dfrac{d}{dx}e^{e^x} \\ \dfrac{dy}{dx} = e^{e^x}\left(\dfrac{d}{dx}e^x\right) \\ \dfrac{dy}{dx} = e^{e^x}\left(e^x\right) \\ \dfrac{dy}{dx} = e^{x+e^x} \\$
5. Differentiate with respect to $x$: $y=\sec(e^x)$

$\dfrac{d}{dx}y = \dfrac{d}{dx}\sec(e^x) \\ \dfrac{dy}{dx} = \tan(e^x)\sec(e^x)\left(\dfrac{d}{dx}e^x\right) \\ \dfrac{dy}{dx} = \tan(e^x)\sec(e^x)e^x \\$
6. Differentiate with respect to $x$: $y=\csc^2(e^x)$

$\dfrac{d}{dx}y = \dfrac{d}{dx}\csc^2(e^x) \\ \dfrac{dy}{dx} = 2\csc(e^x)\left(\dfrac{d}{dx}\csc(e^x)\right) \\ \dfrac{dy}{dx} = 2\csc(e^x)\left(-\csc(e^x)\cot(e^x)\left(\dfrac{d}{dx}e^x\right)\right) \\ \dfrac{dy}{dx} = 2\csc(e^x)\left(-\csc(e^x)\cot(e^x)\left(e^x\right)\right) \\ \dfrac{dy}{dx} = -2e^x\csc^2(e^x)\cot(e^x) \\$
7. Differentiate with respect to $x$: $y=2^{x}$

$\dfrac{d}{dx}y = \dfrac{d}{dx} 2^{x} \\ \dfrac{dy}{dx} = \dfrac{d}{dx} e^{\ln(2) x}\\ \dfrac{dy}{dx} = \ln(2) e^{\ln(2) x}\\ \dfrac{dy}{dx} = \ln(2) 2^{x}\\$
8. Differentiate with respect to $x$: $y=\sin(\sin(\sin(x)))$

$\dfrac{d}{dx}y = \dfrac{d}{dx}\sin(\sin(\sin(x))) \\ \dfrac{dy}{dx} = \cos(\sin(\sin(x))) \cdot \left(\dfrac{d}{dx}\sin(\sin(x))\right) \\ \dfrac{dy}{dx} = \cos(\sin(\sin(x))) \cdot \left(\cos(\sin(x)) \cdot \left(\dfrac{d}{dx}\sin(x)\right)\right) \\ \dfrac{dy}{dx} = \cos(\sin(\sin(x))) \cdot \left(\cos(\sin(x)) \cdot (\cos(x))\right) \\ \dfrac{dy}{dx} = \cos(\sin(\sin(x)))\cdot\cos(\sin(x))\cdot\cos(x) \\$
9. Differentiate with respect to $x$: $y=f(g(x))$

$$\dfrac{d}{dx}y = \dfrac{d}{dx}f(g(x)) \\ \dfrac{dy}{dx} = f'(g(x))g'(x) \\$$ Note: This is the general form of the Chain Rule.
10. Differentiate with respect to $x$: $y=x^x$
$\dfrac{d}{dx}y = \dfrac{d}{dx}x^x \\ \dfrac{dy}{dx} = \dfrac{d}{dx}e^{\ln(x)x} \\ \dfrac{dy}{dx} = e^{\ln(x)x}\left(\dfrac{d}{dx}\ln(x)x \right) \\ \dfrac{dy}{dx} = e^{\ln(x)x}\left(\left(\dfrac{d}{dx}\ln(x)\right)x +\ln(x)\left(\dfrac{d}{dx}x\right)\right) \\ \dfrac{dy}{dx} = e^{\ln(x)x}\left(\left(\dfrac{1}{x}\right)x +\ln(x)\left(1\right)\right) \\ \dfrac{dy}{dx} = e^{\ln(x)x}\left(1 +\ln(x)\right) \\ \dfrac{dy}{dx} = x^{x}\left(1 +\ln(x)\right) \\$