TITLE: how to prove the chain rule?
QUESTION [18 upvotes]: I have just learned about the chain rule but my book doesn't mention the proof. I tried to write a proof myself but can't write it. So can someone please tell me about the proof for the chain rule in elementary terms because I have just started learning calculus.

REPLY [2 votes]: First, let me give a careful statement of the theorem of the chain rule:

THEOREM: If $g$ is differentiable at $a$, and $f$ is differentiable at $g(a)$, then $f \circ g$ is differentiable at $a$, and
$$
(f \circ g)'(a) = f'(g(a)) \cdot g'(a) \, .
$$

Now for the proof. Define the function $\phi$ as follows:
$$
\phi(y)=\begin{cases}
\dfrac{f(y)-f(g(a))}{y-g(a)}&\text{if $y-g(a)\neq0$,} \\[5pt]
f'(g(a))&\text{if $y-g(a)=0$.}
\end{cases}
$$
Since
$$
f'(g(a))=\lim_{y \to g(a)}\frac{f(y)-f(g(a))}{y-g(a)} \, ,
$$
$\phi$ is continuous at $g(a)$. Moreover, $g$ is continuous at $a$ because it is differentiable at $a$. Since the composition of continuous functions is continuous, $\phi \circ g$ is continuous at $a$. This fact is used below on line $\eqref{*}$.
Note that for all $x\neq a$,
$$
\frac{f(g(x))-f(g(a))}{x-a}=\phi(g(x)) \cdot \frac{g(x)-g(a)}{x-a} \, .
$$
(This is true even if $g(x)-g(a)=0$, as in that case both sides are equal to $0$.) Hence,
\begin{align}
(f \circ g)'(a)&=\lim_{x \to a}\frac{f(g(x))-f(g(a))}{x-a} \\[5pt]
&= \lim_{x \to a}\phi(g(x)) \cdot \lim_{x \to a}\frac{g(x)-g(a)}{x-a} \\[5pt]
&= \phi(g(a)) \cdot g'(a) \tag{*}\label{*} \\[5pt]
&= f'(g(a)) \cdot g'(a) \blacksquare
\end{align}
For an explanation of how this proof was motivated, see pages 177 onwards of Michael Spivak's Calculus. Note that my definition of the function $\phi$ is different to Spivak's.