TITLE: Spivak's Chain Rule Proof (Image of proof provided)
QUESTION [8 upvotes]: 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)^{\prime}(a)=f^{\prime}(g(a)) \cdot g^{\prime}(a).
$$
Define a function $\phi$ as follows:
$$
\phi(h)= \begin{cases}\frac{f(g(a+h))-f(g(a))}{g(a+h)-g(a)}, & \text { if } g(a+h)-g(a) \neq 0 \\ f^{\prime}(g(a)), & \text { if } g(a+h)-g(a)=0 .\end{cases}
$$
It should be intuitively clear that $\phi$ is continuous at $0:$ When $h$ is small, $g(a+h)-g(a)$ is also small, so if $g(a+h)-g(a)$ is not zero, then $\phi(h)$ will be close to $f^{\prime}(g(a)) ;$ and if it is zero, then $\phi(h)$ actually equals $f^{\prime}(g(a))$, which is even better. Since the continuity of $\phi$ is the crux of the whole proof we will provide a careful translation of this intuitive argument.
We know that $f$ is differentiable at $g(a) .$ This means that
$$
\lim _{k \rightarrow 0} \frac{f(g(a)+k)-f(g(a))}{k}=f^{\prime}(g(a)).
$$
Thus, if $\varepsilon>0$ there is some number $\delta^{\prime}>0$ such that, for all $k$,
$$ \text{if $0<|k|<\delta^{\prime}$, then $\left|\frac{f(g(a)+k)-f(g(a))}{k}-f^{\prime}(g(a))\right|<\varepsilon$}. \tag{1} $$
Now $g$ is differentiable at $a$, hence continuous at $a$, so there is a $\delta>0$ such that, for all $h$,
$$\text{ if $|h|<\delta$, then $|g(a+h)-g(a)|<\delta^{\prime} .$}\tag{2}$$
Consider now any $h$ with $|h|<\delta .$ If $k=g(a+h)-g(a) \neq 0$, then
$$
\phi(h)=\frac{f(g(a+h))-f(g(a))}{g(a+h)-g(a)}=\frac{f(g(a)+k)-f(g(a))}{k} ;
$$
it follows from $(2)$ that $|k|<\delta^{\prime}$, and hence from (1) that
$$
\left|\phi(h)-f^{\prime}(g(a))\right|<\varepsilon.
$$

(transcribed from this screenshot)
Here is a proof of the chain rule in Spivak's Calculus. Note there is a second page, but I understand it, and this is the meat of the proof. I have a few questions.
$\textbf{1.}$ "It should be intuitively clear that $\phi$ is continuous at $0$." Do we care that it is continuous at zero so we will not have a division by zero since $g(a+h)-g(a)$ is in the denominator and could equal zero? I am not sure I understand why it is continuous at zero. I understand what he was saying but I was always under the impression continuity was when there were no breaks in the graph visually. Here, I am imagining $\phi(h)$ being continuous up to zero, then it jumping to another point when it is zero.
$\textbf{2.}$ At (2),I do not understand what we are trying to do here. We randomly switched to $h$ and are defining continuity I think. The switch back and forth from $k$ to $h$ is confusing me.

REPLY [2 votes]: Just to provide an additional point, one can understand Spivak's $\phi$ function as actually being a composite function. In fact, in Chapter 6 Exercise 12a, we proved a useful lemma that reads as follows:

If $f$ is continuous at $l$ and $\displaystyle \lim_{x \to a} g(x) = l$, then $\displaystyle \lim_{x\to a}f(g(x))=f(l)$

Although Spivak's $\phi$ function looks a little exotic, consider the slightly more digestible function $\psi$ which we define as follows:
$$\psi(k)=
\begin{cases} 
      \frac{f\left(g(a)+k\right)-f\left(g(a)\right)}{k} & k \neq 0 \\
      f'\left(g(a)\right)& k = 0 
   \end{cases}$$
For the $k \neq 0$ condition, we recognize this as the expression that we would to the right of the $\displaystyle \lim_{k \to 0}$ in the definition of the derivative of $f$ at $g(a)$. By assumption, we know that the derivative of $f$ at $g(a)$ exists. With this information, we can actually prove that $\psi$ is continuous at $0$, which means that $\displaystyle \lim_{k \to 0}\psi(k)=\psi(0)=f'\left(g(a)\right). \quad \dagger$
Next, consider the function $\omega$ which we will define as follows:
$$\omega(h)=g(h+a)-g(a) \text{ for any }h\in \mathbb R$$
By assumption, $g$ is differentiable at $a$...which means $g$ is also continuous at $a$. With this information, we can prove that $\displaystyle \lim_{h \to 0} \omega(h)=0. \quad \dagger \dagger$
Notice how using $\dagger$ and $\dagger \dagger$, we can invoke our lemma which states:
$$\displaystyle \lim_{h \to 0}\psi\left( \omega(h) \right)=\psi(0)=f'\left(g(a)\right)$$
We can unpack $\psi\left ( \omega(h)\right)$ in the following way:
$$\psi\left ( \omega(h)\right)=\psi \left( g(h+a)-g(a)\right)$$
By definition of $\psi$, if $g(h+a) - g(a) = 0$, then $\psi \left (g(h+a) - g(a) \right)=f'\left(g(a)\right) $
If $g(h+a) - g(a) \neq 0$, then $\psi \left (g(h+a) - g(a) \right)=\frac{f\left(g(a)+g(h+a) - g(a)\right)-f\left(g(a)\right)}{g(h+a) - g(a)} = \frac{f\left(g(h+a)\right)-f\left(g(a)\right)}{g(h+a) - g(a)}$.
This is precisely how Spivak defined his $\phi$ function.