If $h$ is twice differentiable, then $|h|$ is twice differentiable except on a countable set

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.


Suppose that $h$ is twice differentiable. Note that you already know that $\bigl||h|'(x)\bigr|=|h'(x)|$ for $x\notin N:=\{\,x\in \Bbb R\mid h(x)=0,h'(x)\ne 0\,\}$ (and that $N$ is countable).

Suppose $h(a)=h'(a)=0$, $h''(a)=c>0$. Then we have a local minimum at $a$, hence $h(x)\ge0$ on some interval $(a-\epsilon,a+\epsilon)$ and hence $|h|=h$ and $|h|''=h''$ there. Similarly, $|h|''(a)=-h''(a)=|h''(a)|$ if $c<0$. If $c=0$ and additionally $a\notin \overline N$, then we already know $|h|'(a)=0$ and have that $$\tag1\lim_{t\to0}\left|\frac{|h|'(a+t)-|h|'(a)|}{t}\right|=\lim_{t\to 0}\left|\frac{|h|'(a+t)}{t}\right|= \lim_{t\to 0}\left|\frac{h'(a+t)}{t}\right|=0$$ because $\lim_{t\to 0}\frac{h'(a+t)}{t}=h''(a)=0$ and we conclude that also $|h|''(a)=0$.

We conclude that $|h|''(a)$ can only fail to exist under some limited conditions, namely for $a\in N$ and for those $a\in\overline N$ where $h''(a)=0$ (and additionally $h(a)=h'(a)=0$). Specifically, let $$N_2=(\overline N\cap \{\,x\in\Bbb R\mid h(x)=h'(x)=h''(x)=0\,\})\cup N.$$ Let $x\in\Bbb R\setminus N_2$. Then one of the following cases treated above applies:

  • $h(x)\ne 0$ $\quad\implies\quad|h|''(x)=\operatorname{sgn}(h(x))h''(x)$,
  • or $h(x)=h'(x)=0$ and $h''(x)\ne 0$ $\quad\implies\quad|h|''(x)=|h''(x)|$,
  • or $h(x)=h'(x)=h''(x)=0$, but $x\notin \overline N$ $\quad\implies\quad|h|''(x)=0$.

Note that we cannot say that $N_2$ is countable (or can we?), but at least it is nowhere dense ...


Can $|h|''$ exist for any point $a\in N_2$? Certainly not for $a\in N$ as then not even $h'(a)$ exists: From $h(a)=0$ it follows that $\frac{|h|(x)-|h|(a)}{x-a}=\pm\frac{h(x)-h(a)}{x-a}$, so at most $|h|'(a)=\pm h'(a)$ is possible, but on the other hand $|h|$ has a local minimum at $a$. So what about $a$ with $h(a)=h'(a)=h''(a)=0$ and there is a sequence $a_n\to a$ with $h(a_n)=0$, $h'(a_n)\ne 0$? Then as just said, $|h|'(a_n)$ does not exist. Hence there is no open neighbourhood of $a$ where $|h|'$ is defined. Hence the ordinariy definition of derivative is not applicable.

At best, a one-sided derivative of $|h|'$ can exist. In that case, we can just write $t\to 0^+$ or $t\to 0^-$ in $(1)$ and still obtain the (one-sided) derivative $|h|''(a)=0$. But keep in mind that even this is valid only if $a$ is only a one-sided limit of points in $N$, that is, we must have that one of $[a,a+\epsilon)$, $(a-\epsilon,a]$ is disjoint from $N$.