Proving the chain rule in Calculus 1 I want to prove that if $g$ is differentiable at $x$ and $f$ is differentiable at $g(x)$, then $f \circ g$ is differentiable at $x$ and $\:\left[f(g(x))\right]'=f'(g(x))\cdot g'(x)$.
I know there are a few ways to prove this, however, I want to do so with a piece wise defined function.
Define $\;\phi(h) = \begin{cases} \dfrac{f(g(x+h))-f(g(x))}{g(x+h)-g(x)},& g(x+h) \neq g(x) \\ f'(g(x)) ,& g(x+h)=g(x)
\end{cases}$

First, I will show that $\;\phi(h) \cdot \displaystyle\frac{g(x+h)-g(x)}{h} = \frac{f(g(x+h))-f(g(x))}{h}$
Case $1$: $\,g(x+h) \neq g(x)$
Then we have $\displaystyle\frac{f(g(x+h))-f(g(x))}{g(x+h)-g(x)} \cdot \frac{g(x+h)-g(x)}{h} = \frac{f(g(x+h))-f(g(x))}{h}$.
Case $2$: $\,g(x+h)=g(x)$
Then we have $\;f'(g(x)) \cdot \dfrac{g(x+h)-g(x)}{h} = 0$ since $g(x+h) = g(x)$. Note that even though the product is zero, we are done because $g(x+h)=g(x)$ means $f(g(x+h))-f(g(x)) = 0$ too, so
$$\frac{f(g(x+h))-f(g(x))}{h} = 0.$$
Therefore, $\;\phi(h) \cdot \displaystyle\frac{g(x+h)-g(x)}{h} = \frac{f(g(x+h))-f(g(x))}{h}$.
Now I just need to show that $\;\displaystyle\lim_{h \to 0}\left[\phi(h)\cdot \frac{g(x+h)-g(x)}{h}\right] = f'(g(x))\cdot g'(x)$.
The limit of a product is the product of the limits, and the second limit is easy. It is just the definition of the derivative, i.e. $g'(x)$.
So we just need to show $\;\displaystyle\lim_{h \to 0}\phi(h) = f'(g(x))$. There are two cases to check. First,
By the definition of the limit we have that $\;\forall\, \varepsilon > 0, \ \exists \,\delta > 0\,$ s.t. if $\,0 < \left\lvert h - 0\right\rvert < \delta$, then $$\left\lvert \dfrac{f(g(x+h))-f(g(x))}{g(x+h)-g(x)} - f'(g(x))\right\rvert  < \varepsilon$$
I have no idea how to compute this limit. Does anyone know how?
 A: By definition, $f$ is differentiable at $t_0=g(x)$ if for all $\epsilon>0$ there exists $\mu>0$ such that
$$
\left|\frac{f(t)-f(g(x))}{t-g(x)}-f'(g(x))\right|<\epsilon,\quad\forall 0<|t-g(x)|<\mu.\tag{1}
$$
Now, $g$ is continuous at $x$, which means that for any $\mu>0$ there exists $\delta>0$ such that 
$$
|g(x+h)-g(x)|<\mu,\quad\forall 0<|h-0|<\delta.\tag{2}
$$
Those $\epsilon$ and $\delta$ are exactly what you are looking for. Indeed, if $g(x+h)=g(x)$ then it is trivial that
$$
|\phi(h)-f'(g(x))|=|f'(g(x))-f'(g(x))|=0<\epsilon.
$$
If $g(x+h)\ne g(x)$ then $0<|g(x+h)-g(x)|<\mu$ from (2) and, hence, taking $t=g(x+h)$ will lead us to (1), that is, again
$$
|\phi(h)-f'(g(x))|<\epsilon.
$$

P.S. I would personally prefer using Taylor expansions (or the alternative definition of differentiability if you wish):
\begin{eqnarray}
g(x+h)&=&g(x)+g'(x)h+o(h),\\
f(g(x+h))&=&f(g(x))+f'(g(x))[g(x+h)-g(x)]+\underbrace{o(g(x+h)-g(x))}_{=o(h)}=\\
&=&f(g(x))+f'(g(x))g'(x)h+o(h)
\end{eqnarray}
and the result follows.
A: I'll use slightly different notation, with $x_0$ for the fixed point and $x$ as a variable. Let $y_0= g(x_0).$ Define
$$\psi (y) = \begin{cases}\frac{f(y) - f(y_0)}{y-y_0},& y\ne y_0\\ f'(y_0) & y = y_0\end{cases}$$
Since $f$ is differentiable at $y_0,$ $\psi$ is continuous at $y_0.$ We are using nothing more than the definition of the derivative here.
Now $g$ is differentiable at $x_0,$ hence $g$ is continuous at $x_0.$ So we are set up to use a basic fact: compositions of continuous functions are continuous. We have $g$ continuous at $x_0$ with $g(x_0) = y_0,$ and $\psi$ continuous at $y_0.$ Therefore $\psi\circ g$ is continuous at $x_0.$ I.e.,
$$\lim_{x\to x_0}(\psi\circ g)(x) = (\psi\circ g)(x_0).$$
That answers your question, because this is exactly the limit you asked about.
A: When $g'(x)\neq 0$ there is a neighborhood on which $g(x+h)\neq g(x)$ for all $h\neq 0$ in that interval. Why? Because if we had a sequence of points approaching $x$ on which values of $f$ was equal to $f(x)$, then this would force $f'(x)=0.$
Then by simple algebra:
$$\displaystyle  \frac{f(g(x+h))-f(g(x))}{h} =\frac{f(g(x+h))-f(g(x))}{g(x+h)-g(x)} \cdot \frac{g(x+h)-g(x)}{h}  \\ =\frac{f(u_h)-f(u_0)}{u_h-u_o} \cdot \frac{f(g(x+h))-f(g(x))}{h}$$
(I renamed for clarity.)
Now, letting $h$ approach zero, we get $$(fog)'(x)=f'(u_0)g'(x)=f'(g(x).g'(x).$$
When $g'(x)=0$, 
$$\displaystyle  \frac{f(g(x+h))-f(g(x))}{h} = 0,$$
if $g(x+h)=g(x)$, or
$$\displaystyle  \frac{f(g(x+h))-f(g(x))}{h} = \frac{f(g(x+h))-f(g(x))}{g(x+h)-g(x)} \cdot \frac{g(x+h)-g(x)}{h}  $$
In either case, no matter what sequence of $h_n$ we pick and approch zero, the result will be zero in the limit, as in the latter case, the first quotient approaches $f'(g(x)$, thus does not blow up, while the second approaches $g'(x)=0.$
This wraps us the case of $g'(x)=0.$
