Does differentiablity of mod of a continuous function implies differentiablity of the function? Let $f$ be a real valued continuous function on an open interval, and $|f|$ is differentiable. Is $f$ differentiable?
If answer is yes, please give me a proof of it. 
If answer is no please give me a counterexample.
What is the role of open interval here? Is the result unchanged for a closed interval?
Thank you for your help.
 A: Yes, for a continuous real-valued $f$, the differentiability of $\lvert f\rvert$ implies the differentiability of $f$ (but not vice versa).
If $f(x_0) \neq 0$, we have a neighbourhood $(x_0-\varepsilon, x_0+\varepsilon)$ of $x_0$ on which $f$ has no zeros, by the continuity. Hence on $(x_0-\varepsilon, x_0+\varepsilon)$, we have either $f \equiv \lvert f\rvert$ (if $f(x_0) > 0$) or $f \equiv -\lvert f\rvert$. In either case, $f$ is differentiable on $(x_0-\varepsilon, x_0+\varepsilon)$.
If $f(x_0) = 0$, then $\lvert f\rvert$ has a minimum in $x_0$, hence $\lvert f\rvert'(x_0) = 0$, which means
$$\lim_{h\to 0} \frac{\lvert f(x_0+h)\rvert}{h} = 0,$$
but that implies
$$\lim_{h\to 0} \frac{f(x_0+h)}{h} = 0,$$
which is the differentiability of $f$ in $x_0$ with $f'(x_0) = 0$.
So $f$ is differentiable in all points.
If $f$ is defined on a closed (or semi-closed) interval instead of an open interval, the only thing that changes is that in the endpoints of the interval it may be necessary to speak of the one-sided derivative, if the derivative is only defined for interior points.
