Discuss about the differentiability of $g(x)=|f(x)|$, where $f$ is a differentiable function

general-topologyreal-analysis

I want to discuss about the differentiability of $g(x)=|f(x)|$, where $f$ is a differentiable function

Example 1

Take $f(x)=|x|$, function is clearly not differentiable at $x=0$.
enter image description here

Example 2

Take $f(x)=|\sin(x)|$, function is clearly not differentiable at the point $x=n\pi$

enter image description here

After taking few more examples like $|x-1|, |\cos(x)|$, it always seems to be the case that $|f(x)|$ is not differentiable at the points where $f(x)=0$

Observation: One thing is common in all the examples that some portion of $f(x)$ lies below $x$ axis.
So I took another example

$f(x)=x^2$ but $|f(x)|$ is differentiable at the point where $f(x)=0$

Question 1:

Am I right in concluding that we can not just say in general setting that $|f(x)|$ is not differentiable at the points where $f(x)=0$?

When can we(I mean under what conditions can we )conclude that $|f(x)|$ is differentiable at points where $f(x)=0$. My hypothesis is that graph of $f$ should lie below $x$ axis.

Question 2:

Let $f(x)$ and $g(x)$ be two differentiable function, when can we conclude that $|f(x)|+|g(x)|$ is not differentiable at the points where $f(x)=0$ and $g(x)=0$

Example $|sin(2-x)|+ |cos(x)| $ are not differentiable at $x=2+2\pi, x=(2n+1)\frac{k}{2}$

Edits
As mentioned by @Torsten Schoeneberg in comments, my hypothesis fails!!
enter image description here


Grand Edit:

$f(x)=|x|$ then $f'(x)=\text{sign}{(x)}$

So let $f(x)$ be a differentiable function, and let $g(x)=|f(x)|$, then $$g'(x) =\text{sign}(f(x))f'(x)$$
Note that $\text{sign}{(f(x))}=\begin{cases}{ -1 \quad \text{if } f(x)<0\\+1 \quad \text{if } f(x)>0 } \\{ 0 \quad \text{if } f(x)=0} \end{cases}$

Am I going in right direction?

Best Answer

Hint: Try to show that if $f(x_0)\ne 0,$ then $f'(x_0)$ exists iff $|f|'(x_0)$ exists. And if $f(x_0)= 0$ and $f'(x_0)$ exists, then $|f|'(x_0)$ exists iff $f'(x_0)=0.$