# Show that derivative is continous at $x = 0$, rigor and correctness of proof?

I want to show the following:

Let $f: \mathbb{R} \to \mathbb{R}$ be continuous.

a) If $f$ is differentiable and for $x \ne 0$ the limit $\lim_{x\to 0} f'(x) = A$ exists, then $f$ is differentiable at $x = 0$ and $f'(0) = A$.

b) Show that the inverse is false, i.e. there exists a function $f$ which is differentiable at $x = 0$, but $\lim_{x\to 0} f'(x)$ does not exists.

For a), I worked out a proof, but I am unsure if the limit manipulations I used are okay and rigorous enough, so please can you comment on my solution and point out possible flaws?

Ok, in a) I have to show, that if the limit exists, then it obeys the continuity condition at $x = 0$, i.e. $$\lim_{x\to 0} f'(x) = f'(0)$$ so I calculate (by using the limit definition of the derivative) \begin{align*} \lim_{x\to 0} f'(x) & = \lim_{x \to 0} \left[ \lim_{h \to 0} \left( \frac{f(x+h)-f(x)}{h} \right) \right] \\ & = \lim_{h \to 0} \left[ \lim_{x \to 0} \left( \frac{f(x+h)-f(x)}{h} \right) \right] \\ & = \lim_{h \to 0} \left[ \frac{1}{h} \lim_{x \to 0} \left( f(x+h)-f(x) \right) \right] \\ & = \lim_{h \to 0} \left[ \frac{1}{h} ( f(h) - f(0) ) \right] \\ & = f'(0) \end{align*} Thats my proof, in the last step I used the continuity of $f$ and the manipulations are possible, I think, because all limits exists. I never saw such manipulations, most proofs in my textbooks use $\epsilon/\delta$-Arguments, so I am unsure as how valid are such limit-exchange operations.

For b) the function $f(x) := |x|$ is differentiable at $x = 0$ but it's derivative is not continuous at $x = 0$.

-
In general, you cannot swap limits like this. To see why, compare $\lim_{n\to\infty}\lim_{m\to\infty}\frac{n}{m+n}$ and $\lim_{m\to\infty}\lim_{n\to\infty}\frac{n}{m+n}$. –  Ayman Hourieh Feb 4 '13 at 21:52
Also, for b), your function isn't differentiable at $x=0$. –  Ayman Hourieh Feb 4 '13 at 21:54
Ok, does this make my proof invalid? Are there circumstences when such limit swaping is valid? For b), what are better examples, to my mind I can just think of functions that have "breaks" at points like the $|\cdot|$ function? –  Stefan Feb 4 '13 at 21:57
See the function in this question. –  Brian M. Scott Feb 4 '13 at 22:08
For part a), you could use the Mean Value Theorem. See this post for details (it handles the one-sided case, but can be suitably modified for your problem). –  David Mitra Feb 4 '13 at 22:08

As I said in the comments, swapping limits doesn't work in general. Let's prove a) using an $\epsilon-\delta$ argument.

Fix $\epsilon > 0$, and pick $\delta > 0$ so that: $$|x| < \delta \implies |f'(x) - A| < \epsilon \tag{1}$$

This is always possible since $\lim_{x \to 0} f'(x) = A$.

Let $h \in (0, \delta)$. Since $f$ is continuous on $[0, h]$ and differentiable on $(0, h)$, by the mean value theorem we can find $\xi \in (0, h)$ so that:

$$\frac{f(h) - f(0)}{h} = f'(\xi)$$

But $\xi$ satisfies (1), thus:

$$\left| \frac{f(h) - f(0)}{h} - A\right| < \epsilon$$

Since our choice of $\epsilon$ is arbitrary, we conclude that $f$ is right differentiable at $x = 0$. A similar argument works for the left derivative, and the desired result follows.

For b), the standard example is $f(x) = \begin{cases} x^2 \cos(1/x) & x \ne 0 \\ 0 & x = 0 \end{cases}$. Try to prove that it's differentiable at $x = 0$ but the derivative isn't continuous there.

-