# The relationship between the derivative of $f(x)$ and $|f(x)|$

I have seen it in an exercise book. I don't know how to do it.

If $f(x)$ is continuous at $x=a,$ and $|f(x)|$ can be differentiated at $x=a,$ then $f(x)$ is differentiable at $x=a.$

-
Start by thinking about the cases when f(a) is nonzero. Can you handle that? Then we can discuss cases when f(a) = 0. – hardmath Apr 12 '12 at 0:35
.. where $$\frac{d}{dx} |f(a)| = f'(a) \frac{f(a)}{|f(a)|}.$$ – user2468 Apr 12 '12 at 0:38
@Gingerjin: I have posted a detailed analysis. If some details remain obscure, please ping. (I think leaving an unaddressed message beneath my answer will work, or an addressed message anywhere.) – André Nicolas Apr 12 '12 at 5:10

Let $g(x)=|f(x)|$. If $f(a)\ne 0$, then by the continuity of $f$, there is an interval $I_\epsilon=(a-\epsilon, a+\epsilon)$ such that if $x$ is in $I_\epsilon$, then $f(x)$ has the same sign as $f(a)$. If $f(a)$ is positive, then for all $x$ in $I_\epsilon$, we have $g(x)=f(x)$. So for $x$ in the interval $I_\epsilon$, $$\frac{g(x)-g(a)}{x-a}=\frac{f(x)-f(a)}{x-a}.$$ It follows that if $\lim_{x\to a}\frac{g(x)-g(a)}{x-a}$ exists, then so does $\lim_{x\to a}\frac{f(x)-f(a)}{x-a}$ (and the limits are the same). We conclude that $f'(a)$ exists and is equal to $g'(a)$.
If $f(a)$ is negative, then for all $x$ in $I_\epsilon$, we have $g(x)=-f(x)$. It follows that $$\frac{g(x)-g(a)}{x-a}=\frac{-f(x)+f(a)}{x-a}=-\frac{f(x)-f(a)}{x-a}.$$ Thus if $\lim_{x\to a}\frac{g(x)-g(a)}{x-a}$ exists, then so does $\lim_{x\to a}\frac{f(x)-f(a)}{x-a}$. In this case, $f'(a)=-g'(a)$.
Now we come to the interesting case, where $f(a)=0$. We are told that $\lim_{x\to 0}\frac{g(x)-g(a)}{x-a}$ exists. Since $g(a)=0$, this says that $\lim_{x\to a}\frac{g(x)}{x-a}$ exists.
But $g(x)\ge 0$ for all $x$. So for all $x>a$, we have $\frac{g(x)}{x-a}\ge 0$. It follows that $$\lim_{x\to a+}\frac{g(x)}{x-a} \ge 0.\tag{1}$$ Also, if $x<a$, then $x-a<0$, and therefore $\frac{g(x)}{x-a}\le 0$. It follows that $$\lim_{x\to a-}\frac{g(x)}{x-a} \le 0.\tag{2}$$ Since by assumption $\lim_{x\to a}\frac{g(x)}{x-a}$ exists, we conclude from inequalities $(1)$ and $(2)$ that $$\lim_{x\to a}\frac{g(x)}{x-a} = 0.\tag{3}$$ It follows immediately that $$\lim_{x\to a}\frac{f(x)}{x-a} = 0.$$ This says that $f'(a)$ exists and is equal to $0$.