# Continuity and differentiability problem and checking is the function elelment of $C^0$ and $C^1$

Find value of a for which function $f(x) \in C^0(R)$ and $f(x) \in C^1(R)$
f(x) = \begin{cases} |x|^a sin(\frac{1}{x}) & \text{if }x \neq0,\\ 0 & \text{if } x=0 \end{cases}

I try this: I rewrite function $f(x)$ to look like this: f(x) = \begin{cases} (-x)^a sin(\frac{1}{x}) & \text{if }x <0,\\ 0 & \text{if } x=0,\\ (x)^a sin(\frac{1}{x}) & \text{if }x>0, \end{cases} To check continuity I have to find limit of:$\lim_{x \to 0^+}((x)^a sin(\frac{1}{x}))$ must be equal to 0 and must be equal to this limit too $\lim_{x \to 0^-}((-x)^a sin(\frac{1}{x}))$ But that is true $\forall$ $a$.
Ok I need to check differentiability of function $f(x)$. I need to check right and left differention at point 0. If left and right are equal function is defferentiable on $R$. $$\lim_{x \to 0^+}\frac{(x)^a sin(\frac{1}{x})}{x}=\lim_{x \to 0^+}x^{a-1}sin(\frac{1}{x})=0$$
$$\lim_{x \to 0^-}\frac{(-x)^a sin(\frac{1}{x})}{x}=\lim_{x \to 0^-}(-x^{a-1}sin(\frac{1}{x})=0$$ We see that function if defferentiable on $R$ $\forall a$.

And to complete the task we need to check continuity of $f'(x)$. But we check that when we was checking differentiability (L'H rule). So that function is an element of $C^0$ and $C^1$ for every real value of a.

Here is how I would think about it. Note $f$ is continuous everywhere except perhaps $0$, since it is a composition/product of continuous functions. Notice that $\sin(1/x)$ is a bounded function, and to ensure continuity we simply need that $f(x) \to 0$ as $x \to 0$. Equivalently, then, we must have $|x|^{a} \to 0$ as $x \to 0$. Well, that will be the case for pretty much any $a>0$. $a=1$ is an easy choice.
Differentiability is a bit more complex. Again notice that $f$ is differentiable everywhere except perhaps $0$. At $0$, the condition for differentiability is that $$\frac{f(h)-f(0)}{h}=|h|^{a-1}\sin(1/h)$$ tends to a finite limit as $h \to 0$. You can see that the limit must be $0$ by considering $h<0$ and $h>0$, or alternatively think of it as "$\sin(1/h)$ is absolutely horrible near $0$. How can I make it disappear?", and the considerations from the first part allow you to take any $a>1$.
Finally, to make $f \in C^{1}(\mathbb{R})$, we need the derivative to be continuous. Computing $f'(x)$ away from $0$, we have $$x^{a-1}\sin(1/x)-x^{a-2}\cos(1/x)$$ for $x>0$, and similarly for $x<0$.
Again, by boundedness considerations this can only tend to $0$ if $a>2$. $a=3$ is an easy choice.