Practicing the chain rule I'm trying to understand the answer to the problem in this screenshot
The goal is to use the chain rule to find the derivative of
$$e^{\sin(x^2)}$$
As seen in the screenshot, the correct answer is
$$2x e^{\sin(x^2)}\cos(x^2)$$
From my understanding the chain goes:
$$f'(g'(h(x)))  h'(x)  g'(x) $$
but I am not too sure how it gets $\cos(x^2)  $
 A: Your statement of the chain rule is incorrect. The derivative of $f(g(h(x)))$ with respect to $x$ is $f'(g(h(x)))g'(h(x))h'(x)$.
In your case, $f(x) = e^x$, $g(x) = \sin(x)$, and $h(x) = x^2$, so
$$f(g(h(x))) = f(g(x^2)) = f(\sin(x^2)) = e^{\sin(x^2)}$$
To apply the chain rule, we need the derivatives of $f$, $g$, and $h$, which are:
$$\begin{aligned}
f'(x) &= e^x \\
g'(x) &= \cos(x) \\
h'(x) &= 2x \\
\end{aligned}$$
Then the three factors of the chain rule are:
$$\begin{aligned}
f'(g(h(x)) &= f'(\sin(x^2)) = e^{\sin(x^2)} \\
g'(h(x)) &= \cos(x^2) \\
h'(x) &= 2x \\
\end{aligned}
$$
Multiplying these together, we get the final answer:
$$f'(g(h(x)))g'(h(x))h'(x) = 2x e^{\sin(x^2)}\cos(x^2)$$
which matches the correct answer at your link.
A: Let me supplement @Bungo's answer by explaining why the derivative of $f(g(h(x)))$ with respect to $x$ is
$$
f'(g(h(x))) \cdot g'(h(x)) \cdot h'(x) \, .
$$
Recall that the chain rule states that (under certain conditions)
$$
\frac{d}{dx}\left(u(v(x))\right)=u'(v(x)) \cdot v'(x)
$$
Let $u=f$ and $v=g\circ h$.* Then,
$$
\frac{d}{dx}\left(u(v(x))\right)=f'(g(h(x)))\cdot\frac{d}{dx}\left(g(h(x))\right)
$$
But we know that
$$
\frac{d}{dx}\left(g(h(x))\right)=g'(h(x)) \cdot h'(x) \, .
$$
Hence, overall
$$
\frac{d}{dx}\left(u(v(x))\right)=\frac{d}{dx}(f(g(h(x))))=f'(g(h(x))) \cdot g'(h(x)) \cdot h'(x) \, .
$$
In cleaner notation,
$$
(u \circ v)'(x) = (f \circ g \circ h)'(x) = (f' \circ g \circ h)(x) \cdot (g' \circ h)(x) \cdot h'(x) \, .
$$

*The notation $v=g\circ h$ just means that $v(a)=g(h(a))$ for all $a$.
A: I think rather than memorizing rules, a simpler approach is to just use differentials and substitution.  Let's start with the formula:
$$e^{\sin(x^2)}$$
Now, math doesn't care about the variables we use.  So, we can simply say $u = \sin(x^2)$, which makes the formula:
$$e^u$$
If we differentiate this (not the full derivative, just the differential), we get:
$$d(e^u) = e^u\,du$$
This is a 100% true statement!  But what is $du$?  Well, we can find that by just differentiating both sides of $u = \sin(x^2)$.  However, to do that, we need another substitution!  Let's set $w = x^2$, so $u = \sin(w)$.  That means that we can find $du$ by saying:
$$ du = \cos(w)\,dw $$
So what is $dw$?  Well, $w = x^2$, and we can differentiate that directly:
$$ dw = 2x\,dx $$
Now we just build it all back up.
$$ e^u\, du = e^{\sin(x^2)}\,\cos(w)\,dw \\
 = e^{\sin(x^2)}\,\cos(x^2)\,2x\,dx $$
To get the derivative, just divide by $dx$:
$$ e^{\sin(x^2)}\,\cos(x^2)\,2x $$
The rule works just fine, but doing it this way is super-helpful for me for recognizing (a) what the rule is and (b) why the rule is.
A: Let $f: z\mapsto \mathrm e^z\\g:y\mapsto \sin y\\h: x\mapsto x^2$
So $f': z\mapsto \mathrm e^z\\g':y\mapsto \cos y\\h': x\mapsto 2x$
Then we may apply the chain rule, by whatever route you prefer: $$\begin{align}(\mathrm e^{\sin(x^2)})'&=[(f\circ g\circ h)'](x) &&=\dfrac{\mathrm df(g(h(x)))}{\mathrm d x} \\[1ex]&=[(g\circ h)'\cdot(f'\circ g\circ h)](x) &&= \dfrac{\mathrm d g(h(x))}{\mathrm d x}\cdot\dfrac{\mathrm d f(g(h(x))}{\mathrm d g(h(x))} \\[1ex]&=[h'\cdot(g'\circ h)\cdot(f'\circ g\circ h)](x)&& =\dfrac{\mathrm d h(x)}{\mathrm d x}\cdot \dfrac{\mathrm d g(h(x))}{\mathrm d h(x)}\cdot\dfrac{\mathrm d f(g(h(x))}{\mathrm d g(h(x))} \\[1ex]&= 
h'(x)\cdot g'(h(x))\cdot f'(g(h(x))) &&=\dfrac{\mathrm d x^2}{\mathrm d x}\cdot \dfrac{\mathrm d \sin(x^2)}{\mathrm d x^2}\cdot\dfrac{\mathrm d \mathrm e^{\sin(x^2)}}{\mathrm d \sin(x^2)}\\[1ex]&=(x^2)'\cdot\sin'(x^2)\cdot\mathrm e^{\sin(x^2)}&&=2x\cdot\cos(x^2)\cdot\mathrm e^{\sin(x^2)}\end{align}$$
