Chain Rule: Version 2
Composition of Functions
Suppose that we have variables $x$, $y$, and $u$, and that
$y = f(u)$ and $u = g(x)$. We say that $y$ is a compound function of $x$,
namely $y= f(g(x))$, because it's a function that depends on a function that depends on $x$.
This is sometimes written as $y=(f \circ g)(x)$.
Visually,
$$
x\longmapsto g(x)\longmapsto f\big( g(x)\big)
$$
For Example:
 $y=\sin(x^2)$ is a compound function with $u=x^2$ and $y=\sin(u)$.

$y=\sin^2(x)$ is a compound function with $u=\sin(x)$ and $y=u^2$.

$y=e^{3x}$ is a compound function with $u=3x$ and $y=e^u$.

$y=(x^2 + 4x + 7)^5$ is a compound function with $u=x^2 + 4x + 7$ and $y=u^5$.

Version 2 of the chain rule says that
$$\frac{dy}{dx} = \frac{dy}{du} \frac{du}{dx}$$

Note that $\displaystyle \frac{dy}{dx}$ is the same
as $\displaystyle{\frac{d}{dx}\Big(f\big(g(x)\big)\Big)}$, that
$\displaystyle{\frac{dy}{du}} = f'(u)=f'(g(x))$, and that
$\displaystyle{\frac{du}{dx}}$
is the same thing as $g'(x)$. So Version 2 says the exact same thing
as Version 1.
Let's see how it applies to our examples above.
Example 1:
If $y=\sin(x^2)$, then $u=x^2$ so that $y=\sin(u)$.
Then $\dfrac{du}{dx} =2x$, and $\dfrac{dy}{du}=\cos(u)$. All together, we have
$$
\frac{dy}{dx} = \frac{dy}{du}\frac{du}{dx}=\cos(u)\cdot2x = \cos(x^2)\cdot 2x.$$

Example 2:
If $y = \sin^2(x)$, then $u=\sin(x)$ so that $y=u^2$.
Then
$\dfrac{du}{dx}=\cos(x)$, and
$\dfrac{dy}{du}=2u$. All together, we have
$$\frac{dy}{dx} = \frac{dy}{du}\frac{du}{dx}=2u\cdot \cos(x) =
2\sin(x)\cos(x).$$

Example 3:
If $y=e^{3x}$, then $u=3x$ so that $y=e^u$.
Then $\dfrac{du}{dx}=3$, and $\dfrac{dy}{du}=e^u$. All together, we have
$$\frac{dy}{dx}= \frac{dy}{du}\frac{du}{dx} =e^u\cdot3 = 3 e^{3x}.$$

Example 4:
If $y=(x^2 + 4x + 7)^5$, then $u=x^2+4x + 7$ so that $y=u^5$.
Then $\dfrac{du}{dx}=2x+4$, and $\dfrac{dy}{du} = 5u^4$. All together we have
$$\frac{dy}{dx} = \frac{dy}{du}\frac{du}{dx} =
5u^4(2x+4)=5(x^2+4x+7)^4(2x+4).$$

Just like with Version 1!
