TITLE: If $h$ is twice differentiable, then $|h|$ is twice differentiable except on a countable set
QUESTION [9 upvotes]: Let $h:\mathbb R\to\mathbb R$ be differentiable. It can be shown that $$N:=\left\{a\in\mathbb R:h(a)=0\text{ and }h'(a)\ne0\right\}$$ is countable and $|h|$ is differentiable on $\mathbb R\setminus N$ with $$|h|'(a)=\begin{cases}\displaystyle\frac{h(a)}{\left|h(a)\right|}h'(a)&\text{, if }h(a)\ne0\\0&\text{, if }h'(a)=0\end{cases}\tag1$$ for all $a\in\mathbb R$.

Assuming $h$ is twice differentiable, can we show a similar statement for the second derivative of $|h|$, i.e. that there is a countable $N'\subseteq\mathbb R$ such that $|h|$ is twice differentiable on $\mathbb R\setminus N'$?

EDIT: It would be enough for me, if $N'$ can be shown to have Lebesgue measure $0$ (as opposed to being even countable). Moreover, if necessary, feel free to assume that $h''$ is continuous.
EDIT 2: We already know that $|h|$ is differentiable at $a$ with $$|h|'(a)=\operatorname{sgn}(h(a))h'(a)\tag5$$ for all $a\in\left\{h\ne0\right\}\cup\left\{h'=0\right\}$. Now, since $h$ is continuous, $\operatorname{sgn}h$ is differentiable at $a$ with $$(\operatorname{sgn}h)'(a)=0\tag6$$ for all $a\in\left\{h\ne0\right\}\cup\left\{h=0\right\}^\circ$ (see: Can we show differentiability of $\operatorname{sgn}h$ on a larger set than $\left\{h\ne0\right\}$?). Thus, by the chain rule, $|h|$ is twice differentiable at $a$ with $$|h|''(a)=\operatorname{sgn}(h(a))h''(a)\tag7$$ for all $a\in\left\{h\ne0\right\}\cup\left\{h=0\right\}^\circ\cap\left\{h'=0\right\}$. The complement of the latter set is $$N_0:=\left\{h=0\right\}\cap\left(\mathbb R\setminus\left\{h=0\right\}^\circ\cup\left\{h'\ne0\right\}\right)=\partial\left\{h=0\right\}\cup N.$$ However, since $\partial\left\{h=0\right\}$ doesn't need to have Lebesgue measure $0$ (please correct me if I'm wrong), we cannot conclude.
(Please take note of my related question: if $h$ is twice differentiable, what is the largest set on which $|h|$ is twice differentiable?.)

REPLY [4 votes]: Let us assume $h$ twice differentiable.
Let $N$ be the set of isolated zeros of $h$. $|h|$ is differentiable on $\mathbb{R}\backslash N$, and $|h|'(x) = sgn(h(x)) h'(x)$ where the sgn function is $0$ on $0$, $1$ on the positive reals and $-1$ and the negative ones.
Let $x_0 \in \mathbb{R}\backslash N$. For $x \in \mathbb{R} \backslash N$,
$|h|'(x) - |h|'(x_0) = sgn(h(x)) h'(x) - sgn(h(x_0)) h'(x_0)$
Let us show that Newton's difference quotient has always a limit when $x\rightarrow x_0$, $x\in \mathbb{R}\backslash N$ (this is not rigorously equivalent to say that $|h|'$ is differentiable at $x_0$ since $\mathbb{R} \backslash N$ does not necessarily contain an open interval centered at $x_0$)
I will distinguish several cases.

$h(x_0) \neq 0$. Then $h(x)$ has the same sign as $h(x_0)$ when $x$ close enough to $x_0$ and it is clear that the Newton's difference quotient converges to $sgn(h(x_0)) h''(x_0)$. Here, $|h|'$ is even rigorously differentiable at $x_0$.
$h(x_0) = 0$ (so $h'(x_0) = 0$) and $h$ is of constant sign (in a large sense) near $x_0$, it is essentially the same situation.
$h(x_0)=0$ (so $h'(x_0) = 0$) and $h$ has strict changes of sign in each interval centered at $x_0$. Then $h''(x_0) = 0$ (else, $h$ would have a local extrema at $x_0$, which contradicts the changes of sign). So we have a LD at order $1$ for $h'$ at $x_0$ : $h'(x) = o( x-x_0)$ So $|h|'(x) - |h|'(x_0) = sgn(h(x))h'(x) = o(x-x_0)$. So the Newton's difference quotient admits a limit, which is $0$ (but $|h|'$ is not rigorously differentiable as soon as $x$ in not the interior of $\mathbb{R} \backslash N$, i.e exactly when infinitely many sign changes of $h$ are made with non zeros first derivatives).

Note that $|h|''(x) = sgn(h(x)) h''(x)$.
Conlusion : Let $N' = (\overline{N} \cap \{h'(x_0) = 0, h \text{ has infinite strict changes of sign near } x_0 \text{ with non zeros first derivatives}\}) \cup N$. Let  $|h|'$ is rigorously differentiable exactly on $\mathbb{R} \backslash N'$, but the Newton's difference quotients converges for all $x_0 \in \mathbb{R} \backslash N$. But there might be some real philosophical problem : the fact that the Newton's difference converges does not corresponds intuitively to the idea of differentiability (it ignores the "jumps" that can exists in the holes of the domain of definition, and is not compatible with LD of order $\geq 2$, see the counter example I give in About a $C^\infty$ extension of a function defined on a closed set (or a $C^\infty$- version of Tietze's extension theorem) ).
To understand better the situation, the following question should be raised : where is the singular loci of $|h|''$, interpreted as a distribution ? And what are the nature of the different singularities ? 
Remark : it is possible to check that $\overline{N}$ can contain an arbitrary Cantor set contained in $\mathbb{R}$ (it's a bit technical, because of the intricated structure of the cantor set : the difficult part is to ensure that $h$ is two times differentiable). So it might be of positive measure... It is quite easy to ensure that $N' = \overline{N}$ in this case : just put non zero derivatives on all isolated zeros of $h$. The demonstration is a bit technical, so please tell me if it is necessary to make it. 
EDIT : I've made several edits for the notations of this response ; don't pay attention too much attention of the notations in the commentaries.