TITLE: Regularity of the function $|x|^ax$
QUESTION [10 upvotes]: Assuming $x \in \mathbb{R}$, what can we say about the regularity class ($C, C^1, C^2, ..., \text{or}\ C^\infty$) of the following function (also with respect to $a \in \mathbb{R}$)? $$f(x)=|x|^ax$$

REPLY [4 votes]: First of all note that if $g(x)=|x|^{\alpha+2}$, then $g'(x)=(\alpha+2)|x|^{\alpha}x$ and thus it is enough (and more convient) to study the differentiability of $f(x)=|x|^\alpha$ to answer your question. Juste note that for every $D\subset \Bbb R$ and $k\geq 1$ we have $g \in C^k(D) \iff g'\in C^{k-1}(D)$. My conclusions are summarized in the following list and are direct consequences of the Theorem below.
For $\alpha >0$, we write $[\alpha]$ the integer part of $\alpha$ (i.e. $[\cdot]$ is the floor function).

Let $\alpha \in \Bbb R$ and $f\colon \Bbb R\to \Bbb R, \ x \mapsto |x|^{\alpha}$, then

$f \in C^{\infty}(\Bbb R\setminus\{0\})$,
If $\alpha <0$, then $f\notin C^{0}(\Bbb R)$,
If $\alpha \geq 0$ and $\alpha = 2n$ for some $n\in \Bbb N$, then $f\in C^{\infty}(\Bbb R)$
If $\alpha>0$ and $\alpha \neq 2n$ for every $n\in \Bbb N$, then $f\in C^{[\alpha]}(\Bbb R)$ but $f\notin C^{[\alpha]+1}(\Bbb R)$


Remember that for every $A \subset B \subset \Bbb R$ and $k\in \Bbb N$, we have $C^{k}(B)\subset C^{k}(A)\subset C^{k+1}(A)$.
For any function $f\colon \Bbb R \to \Bbb R$ and $n\in \Bbb N$, we write $f^{(n)}$ the $n$-th derivative of $f$.
Theorem.
Let $\alpha \in \Bbb R, \alpha \neq 1$ and $f\colon \Bbb R\to \Bbb R, \ x \mapsto |x|^{\alpha}$, then for every $n\in \Bbb N$ and every $x\neq 0$, we have
$$f^{(2n)}(x)=\frac{\alpha !}{(\alpha-2n)!}|x|^{\alpha-2n},$$
and
$$f^{(2n+1)}(x)=\frac{\alpha !}{(\alpha-2n-1)!}|x|^{\alpha-2(n+1)}x,$$
Moreover, $f^{(2n)}$ and $f^{(2n+1)}$ are continuous on $\Bbb R\setminus\{0\}$ and 

$f^{(2n)}(0)=0 \quad \text{ if } \alpha >2n,$ 
$f^{(2n)}(0)=0 \quad \text{ if } \alpha=2n,$
$f^{(2n+1)}(0)=0 \quad \text{ if } \alpha >2n+1,$
$\lim_{x\to 0}f^{(2n+1)}(x)$ does not exists if $\alpha=2n+1, $
$\lim_{x\to 0}f^{(2n)}(x)$ does not exists if $2n< \alpha$,
$\lim_{x\to 0}f^{(2n+1)}(x)$ does not exist if $2n+1<\alpha$.

Proof: See appendix.


Appendix:
Proposition 1. Let $f\colon \Bbb R\to \Bbb R,\ x\mapsto|x|$, then $f'(x)$ exists for every $x\neq 0$ and $f'$ is continuous on $(0,\infty)$ and $(-\infty,0)$. Moreover,
$$f'(x)=\operatorname{sign}(x)=\frac{x}{|x|}=\frac{|x|}{x} \qquad \forall x \neq 0,$$
where $\operatorname{sign}$ is the sign function.
Proof:

Let $x>0$, then for every $|h|<x$ we have
$$\frac{|x+h|-|x|}{h}=\frac{x+h-x}{h}=1 \implies f'(x)=\lim_{h\to 0}\frac{|x+h|-|x|}{h}=1=\operatorname{sign}(x).$$
If $x<0$, for every $|h|<x$ we have
$$\frac{|x+h|-|x|}{h}=\frac{-x-h-x}{h}=-1 \implies f'(x)=\lim_{h\to 0}\frac{|x+h|-|x|}{h}=-1=\operatorname{sign}(x).$$
If $x=0$, then for every $h_1<0<h_2$ we have 
$$\frac{|x+h_1|-|x|}{h_1}=\frac{-h_1}{h_1}=-1 \quad \text{ and } \quad \frac{|x+h_2|-|x|}{h_2}=\frac{h_2}{h_2}=1,$$
thus
$$\lim_{h_1\to 0^-}\frac{|x+h_1|-|x|}{h_1}=-1 \neq 1 = \lim_{h_2\to 0^-}\frac{|x+h_2|-|x|}{h_2},$$
i.e. $f'(0)$ does not exists.

Finally, clearly for every $x\neq 0$, we have $\operatorname{sign}(x)=\frac{x}{|x|}=\frac{|x|}{x}$ and since this function is constant on $(0,\infty)$ (resp. $(-\infty,0)$) it is continuous on $(0,\infty)$ (resp. $(-\infty,0)$).$\qquad \square$
The next Proposition, Theorem as well as Corollary are classical results of real-analysis and a proof can be found in any analysis introductory book.
Proposition 2. Let $f:D\subset \Bbb R\to \Bbb R,g:E \subset f(D)\to \Bbb R$ and $x_0\in D$ such that $f(x_0)\in E$. If $f'(x_0)$ and $g'(f(x_0))$ exist, then 
$$\frac{d}{dx}g\big(f(x_0)\big)=g'\big(f(x_0)\big)f'(x_0).$$
Theorem 3. Let $a<b$ and $f[a,b]\to \Bbb R$ such that $f'$ exists and is continuous on $]a,b[$. If $\lim_{x\to a^+}f'(x)$ exists, then 
$$\lim_{x\to a^+}f'(x)=\lim_{h\to 0^+}\frac{f(a+h)-f(a)}{h}=:f'(a).$$
Corollary 4. Let $I\subset \Bbb R$ open, $x_0\in I$ and $f\colon I \to \Bbb R$ continuous. Suppose that $f'(x)$ exists for every $x\in I\setminus\{0\}$. If $\lim_{x\to x_0^-}f'(x)=\lim_{x\to x_0^+}f'(x)=l$, then $f'(x_0)$ exists and $f'(x_0)=l$.
Proposition 5. Let $\alpha \in \Bbb R$ and $f\colon [0,\infty)\to \Bbb R,\ x\mapsto x^\alpha$, then $f'(x)$ exists for every $x\neq 0$ and is continuous on $(0,\infty)$. Moreover, if $\alpha\geq 1$, then $f'(0)$ exists and $f'$ is continuous on $[0,\infty)$. Moreover,
$$f'(x)=\alpha x^{\alpha-1} \quad \forall x>0, \qquad f'(0)=0 \quad \text{ if }\alpha> 1 \qquad\text{ and } \qquad f'(0)=1 \quad \text{ if }\alpha = 1.$$
Proof: Since $\alpha\in \Bbb R$, we have $f(x)=x^\alpha=e^{\alpha \ln(x)}$ by definition. Now, by proposition 2 we have $$f'(x)=\frac{\alpha}{x}\ e^{\alpha \ln(x)} = \alpha x^{\alpha-1} \qquad \forall x >0.$$
It follows that $f'$ is continuous on $(0,\infty)$. Now, suppose that $\alpha > 1$, then, from Theorem 3, we get
$$f'(a)=\lim_{x\to a^+}f'(x)=\alpha \ 0^{\alpha-1}=0.$$
Finally, if $\alpha = 1$, then, from Theorem 3, we get
$$f'(a)=\lim_{x\to a^+}f'(x)=1.$$
Continuity on $[0,\infty)$ when $\alpha \geq 1$ should now be clear. $\qquad \square$
Proof of the main Theorem:
We proceed by induction over $n \in \Bbb N$, so let $x\neq 0$, then (by Proposition 1 and 4)
$$f^{(0)}(x)=\frac{\alpha !}{\alpha !}|x|^{\alpha}=f(x) \quad \text{and} \quad f^{(1)}= \alpha |x|^{\alpha-1}\frac{x}{|x|}=\alpha |x|^{\alpha-2}x.$$
Now suppose that the formula is true for $2n$, then (by Propositions 1 and 5)
$$f^{(2n+1)}(x)=\frac{d}{dx}\left(\frac{\alpha !}{(\alpha-2n)!}|x|^{\alpha-2n}\right)=\frac{\alpha !(\alpha-2n)}{(\alpha-2n)!}|x|^{\alpha-2n-1}\frac{x}{|x|}=\frac{\alpha !}{(\alpha-(2n+1))!}|x|^{\alpha-2n-2}x.$$
If the formula is true for $2n+1$, then (by Propositions 1 and 5)
$$f^{(2n+2)}(x)=\frac{d}{dx}\left(\frac{\alpha !}{(\alpha-2n-1)!}|x|^{\alpha-2(n+1)}x\right)\\ =\frac{\alpha !}{(\alpha-2n-1)!}\Big(\big(\alpha-2(n+1)\big)|x|^{\alpha-2(n+1)-1}x\frac{x}{|x|}+|x|^{\alpha-2(n+1)}\Big)=\frac{\alpha !}{(\alpha-2n-1)!}\Big((\alpha-2n-1)|x|^{\alpha-2(n+1)}\Big)=\frac{\alpha !}{(\alpha-2n-2)!}|x|^{\alpha-2(n+1)}.$$
Now, if $\alpha>2n$, then, by Corollary 4, clearly $f^{(2n)}(0)=\lim_{x\to 0}f^{(2n)}(x)=0$ and if $\alpha >2n+1$, then, by Corollary 4, $\lim_{x\to 0}f^{(2n+1)}(x)=0$. Now, if $\alpha =2n$, then $f(x)=|x|^{2n}=(x^2)^n=x^{2n}$ and thus $f^{(k)}(0)=0$ for every $k\in \Bbb N$. If $\alpha = 2n+1$, then 
$$f^{(2n+1)}(x)=\alpha!\frac{x}{|x|}=\alpha!\operatorname{sign}(x)$$
and thus $f^{(2n+1)}(0)$ does not exists.
Finally, if $\alpha < 2n$, then $\lim_{x\to 0^+}f^{(2n)}(x)=\infty\neq-\infty=\lim_{x\to 0^-}f^{(2n)}(x)$, i.e. $\lim_{x\to 0}f^{(2n)}(x)$ does not exists. The same argument shows that if $\alpha < 2n+1$, then $\lim_{x\to 0}f^{(2n)}(x)$ does not exists. $\qquad \square$
PS Thank you for this interesting question.