Prove that $g(x):=|f(x)|$ is differentiable iff $f'(a)=0$ Suppose that $f(a)=0$. Prove that $g(x):=|f(x)|$ is differentiable iff $f'(a)=0$

Not sure how to go about this at all. The limit definition that I am working with is
$$
g'(a)=\lim_{x \rightarrow a} \frac{g(x)-g(a)}{x-a}=
\lim_{x \rightarrow a} \frac{|f(x)|-|f(a)|}{x-a}=
\lim_{x \rightarrow a} \frac{|f(x)|}{x-a}=\text{something}
$$
On the other hands, if $f'(a)=0$
$$
f'(a)=\lim_{x \rightarrow a} \frac{f(x)-f(a)}{x-a}=
\lim_{x \rightarrow a} \frac{f(x)}{x-a}=0
\quad\text{iff}\quad
\lim_{x\rightarrow a} f(x)=0
$$
Then, $g'(a)=\lim\limits_{x \rightarrow a} \dfrac{|f(x)|}{x-a}=0$.
My only question is how to do the other direction.
 A: In what follows I'll assume that $f$ is differentiable at $a$.
Suppose $f'(a)\ne0$. Then
$$
\lim_{x\to a^+}\frac{|f(x)|-|f(a)|}{x-a}=
\lim_{x\to a^+}\left|\frac{f(x)}{x-a}\right|=|f'(a)|
$$
while
$$
\lim_{x\to a^-}\frac{|f(x)|-|f(a)|}{x-a}=
\lim_{x\to a^-}-\left|\frac{f(x)}{x-a}\right|=-|f'(a)|
$$
so the derivative of $g$ at $a$ doesn't exist.
So, if $g$ is differentiable at $a$, then $f'(a)=0$.
For the converse, recall that, if $f$ is differentiable at $a$, then 
$$
f(x)=f(a)+(x-a)f'(a)+(x-a)\varphi(x)
$$
where $\lim_{x\to a}\varphi(x)=0$. If $f'(a)=0$, then $f(x)=(x-a)\varphi(x)$, so $g(x)=|x-a|\,|\varphi(x)|$ and
$$
\lim_{x\to a}\frac{g(x)-g(a)}{x-a}=
\lim_{x\to a}\frac{|x-a|}{x-a}|\varphi(x)|=0
$$
because $|x-a|/(x-a)$ is bounded in a punctured neighborhood of $a$.

If we don't assume $f$ is differentiable at $a$, then the result is false, in the sense that from the differentiability of $g$ at $a$ we can't conclude $f$ is differentiable at $a$.
A counterexample: the function $g(x)=|f(x)|$ can be differentiable without $f$ being even continuous; indeed, consider
$$
f(x)=\begin{cases}
-1 & \text{if $x$ is rational}\\
1 & \text{if $x$ is irrational}
\end{cases}
$$
Then $f$ is nowhere continuous, but of course $g$ is everywhere differentiable, being constant.
Things could be arranged so that $f$ is continuous at $a$, but not differentiable:
$$
f(x)=\begin{cases}
-x^2 & \text{if $x$ is rational}\\
x^2 & \text{if $x$ is irrational}
\end{cases}
$$
The function $f$ is continuous at $0$, but not differentiable. However $g(x)=|f(x)|=x^2$ is differentiable at $0$.
A: $$\lim_{x \rightarrow a} \frac{g(x)- g(a)}{x - a} = \lim_{x \rightarrow a} \frac{|f(x)|- |f(a)|}{x - a} = \lim_{x \rightarrow a} \frac{|f(x)|}{x - a} = \lim_{x \rightarrow a} \frac{|f(x) - f(a)|}{x - a}$$
Suppose that $\lim_{x \rightarrow a} \frac{|f(x) - f(a)|}{x - a} = g'(a) \in \mathbb R$ and $|f'(a)| > 0$ (equavalently $f'(a) \neq 0$), then
$$0 < |\lim_{x \rightarrow a} \frac{f(x) - f(a)}{x - a}| = \lim_{x \rightarrow a} |\frac{f(x) - f(a)}{x - a}| = \lim_{x \rightarrow a} \frac{|f(x) - f(a)|}{|x - a|} = \lim_{x \rightarrow a} \frac{|f(x) - f(a)|}{|x - a|} \frac{x-a}{x-a} = g'(a) \lim_{x \rightarrow a} \frac{x-a}{|x-a|}$$
Hence $g'(a) \neq 0$ and $\lim_{x \rightarrow a} \frac{x-a}{|x-a|} = \frac{|f'(a)|}{g'(a)} \in \mathbb{R}$, but does this limit exists ??? 
A: By the reverse triangle inequality:
$$0 \leq |g'(a)| =  
\lim_{x \to a} \left| \frac{|f(x)|-|f(a)|}{x-a} \right| \leq \lim_{x \to a} \frac{|f(x)-f(a)|}{|x-a|} = \left| \lim_{x \to a} \frac{f(x)-f(a)}{x-a} \right| = |f'(a)| = 0$$
