# 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.

• Yes, keep going. Remember that $f(a) = 0$. Hence your last expression is equal to ... – Simon S Apr 21 '15 at 21:50

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$.

• Is it possible for $g'(a)$ to exist but not $f'(a)$ such that $|f'(a)|$ won't make sense? What if $f(x) = x^2+1$ when x is rational and $x^2 -1$ when x is irrational? – Ilham Apr 21 '15 at 22:45
• @Ilham Of course, I'll add the condition and the example. – egreg Apr 21 '15 at 22:46
• Thank you, just thought that that case was the slightly trickier bit so I was looking for a direct proof that won't have to consider the alternative cases, but I think nayrb has one below!Edit: maybe that's for the other direction though – Ilham Apr 21 '15 at 22:47

$$\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 ???

• Can $g'(a)$ exist and $f'(a)$ not exist at all, i.e. not only is it not zero, it just doesn't exist? – Ilham Apr 21 '15 at 22:17
• Haven't think about this @Ilham. However I guess that $f'(a)$ is supposed to exist, considering the way the question is written. – brick Apr 21 '15 at 22:23

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$$

• Is this the direction that supposes $f'(a) = 0$? – Ilham Apr 21 '15 at 22:53