Sobolev space counterexample Is there an example of a smooth function $u:\mathbb{R}\to\mathbb{R}$ with compact support such that $|u|$ fails to lie in the Sobolev space $H^s(\mathbb{R})$ for every $s>1$? Clearly $|u|$ can fail to lie in $W^{s,\infty}$, but it isn't clear to me that the singularities that arise in the $L^{\infty}$ case can't be "integrated" away in the $H^s$ case. Am I missing an obvious example?
 A: No, I claim that for any $u \in C^{2}_c(\Bbb R),$ we have $\lvert u \rvert \in H^s(\Bbb R)$ for all $s < \frac32.$ By considering $u(x)=x$ we see this is optimal; note in this case $(|u|)'(x) = \mathrm{sgn}(x),$ so this can be verified by computing its Fourier transform explicitly.
Indeed for general $u \in C^{\infty}_c(\Bbb R)$ we have
$$ f := \frac{\mathrm{d}}{\mathrm{d}x}(\lvert u \rvert) = u'\,\mathrm{sgn}(u).$$
The idea is that this is never too much worse than $\mathrm{sgn}(x),$ because $u$ does not vanish "too often." This is not entirely accurate as you can have examples like $u(x) = \exp(-1/x^2) \sin(1/x),$ but this can be formalised as follows.
Claim: $f = (|u|)'$ is of bounded variation.
Let $M, R>0$ such that $\mathrm{spt}(u) \subset [-R,R]$ and $\lVert u'' \rVert_{L^{\infty}(\Bbb R)} \leq M,$ and consider the set
$$ S = \left\{ y \in \Bbb R : u(y) = 0, u'(y) \neq 0 \right\} \subset [-R,R]. $$
Note that if $y \in S,$ then observe that $u(x) \neq 0$ for all $0 < |y-x| < \frac{|u'(y)|}{M},$ as $u'$ does not change sign in this region. Then if we let $I_y \subset [-R,R]$ be the maximal interval containing $y$ for which $u' \neq 0$ in $I_y,$ we have $\{I_y\}_{y \in S}$ are pairwise disjoint and each $\lvert I_y \rvert \geq \frac{2 |u'(y)|}M.$ This gives the bound
$$ \frac2M \sum_{y \in S} |u'(y)| \leq \sum_{y \in S} |I_y| \leq 2R. $$
In particular $S$ is countable, and so we claim that as a distribution in $\cal D'(\Bbb R)$ we have
$$ f' = u'' \mathrm{sgn}(u) + 2 \sum_{y \in S} u'(y) \delta_y, $$
where $\delta_y$ is the Dirac delta distribution centred at $y.$ This can be justified by integrating $f$ against a test function, and integrating by parts on suitable subsets of $I_y.$ To break up the integral this way, we will need to use (appealing for instance to the dominated convergence theorem) that the claimed expression of $f'$ is a finite measure on $\Bbb R;$ indeed this holds using the above estimates to bound
$$ \lVert f' \rVert_{\mathcal M(\Bbb R)} = \int_{\Bbb R} |u''| \,\mathrm dx + 2 \sum_{y \in S} |u'(y)| \leq 3MR < \infty.$$
Hence $f \in \mathrm{BV}(\Bbb R)$ as claimed.
From here the result follows by the fractional embedding $\mathrm{BV}(\Bbb R) \cap L^{\infty}(\Bbb R) \hookrightarrow H^s(\Bbb R)$ for all $s < \frac12;$ this follows by an elementary argument using the Gagliardo seminorm, which I'll sketch below (taken from Lemma D.2 of this paper). By density we can consider $f \in C^{\infty}_c(\Bbb R),$ which we can bound as
\begin{align*}
\lVert f \rVert_{H^s(\Bbb R)} &= \int_0^{\infty} \int_{\Bbb R} \frac{\lvert f(x+h) - f(x) \rvert^2}{\lvert h \rvert^{1+2s}} \,\mathrm dx\,\mathrm dh \\
&= \int_0^{1} \int_{\Bbb R} \frac{\lvert f(x+h) - f(x) \rvert^2}{\lvert h \rvert^{1+2s}} \,\mathrm dx\,\mathrm dh + \int_1^{\infty} \int_{\Bbb R} \frac{\lvert f(x+h) - f(x) \rvert^2}{\lvert h \rvert^{1+2s}} \,\mathrm dx\,\mathrm dh \\
&\leq \int_0^1 \int_{\Bbb R} \frac{2\lVert f \rVert_{L^{\infty}(\Bbb R)}\lvert f'(x)\rvert}{\lvert h\rvert^{2s}} \,\mathrm dx\,\mathrm dh + \int_1^{\infty} \int_{\Bbb R} \frac{4\lvert f(x)\rvert^2}{\lvert h \rvert^{1+2s}}\,\mathrm dx\,\mathrm dh \\
&\leq C \lVert f \rVert_{L^{\infty}(\Bbb R)} ( \lVert f' \rVert_{L^1(\Bbb R)} +\lVert f \rVert_{L^{\infty}(\Bbb R)}),
\end{align*}
where the last line follows by noting the respective $h$-integrals are finite for this range of $s.$ Hence the result follows.
