How to comment the differentiability of this rapidly changing function at $x=0$. Define $f,g:\Bbb{R}\to \Bbb{R}$ by $$ f(x)=\begin{cases}   x, & \text{if} \,\,\,  x\in\Bbb{Q},\\ \sin(x), &\text{if}\,\,\, x\in\Bbb{R-Q}\end{cases}$$ and $$g(x)=\begin{cases} x \sin(x)\sin(1/x), & \text{if}\,\,\, x\ne0,\\
0, & \text{if}\,\,\, x=0\end{cases}$$ at $x=0.$ 
how do I know if they are differentiable or not at $x=0$ as of $f$ it looks like related to Dirichlet's function and it is continuous everywhere so should $f$? 
And I find out 
\begin{align*}g'(0)&=\lim_{h\to 0}\frac{g(h)-g(0)}{h}\\
&=\lim_{h\to 0}\sin(h)\sin(1/h).
\end{align*}
Does this limit exist or not? I was thinking of $\sin(1/h)\le1$ so the limit is finite equal to $0$? thanks for any help.
 A: Let's find out the derivative! At its heart, the derivative its defined as a limit. If we find out that both pieces of the function $f$ have the same derivative at $0$, then we can conclude that $f$ is derivable at $0$.
$$
f'(0)=\lim_{t\to 0} \frac{f(t)-f(0)}{t}=
\begin{cases}
\lim_{t\to 0} \frac{t}{t}=1,  & \text{if $t$ is rational} \\
\lim_{t\to 0} \frac{sin(t)}{t}=\lim_{t\to 0} cos(t)=1, & \text{if $t$ is irrrational}
\end{cases}
$$
Thus, no matter whether we approximate ourselves to $0$ through the rational or irrational numbers, or a mix or both, the derivative of $f$ at $0$ is 1. This also implies that f is continuous at 0, as you suggested.
Now for $g$:
$$
g'(0)=\lim_{t\to 0} \frac{g(t)-g(0)}{t}=\lim_{t\to 0} \frac{tsin(t)sin(1/t)}{t}=\lim_{t\to 0}sin(t)sin(1/t)
$$
Which goes to 0 using your argument, which is indeed correct.
To see why it is correct, we have to use the sandwich rule. You can easily see that:
$$
-sin(t)\le sin(t)sin(1/t)\le sin(t),\ \forall t\in \mathbb{R}
$$
Which in the limit goes to:
$$
0\le\lim_{t\to 0}sin(t)sin(1/t)\le 0
$$
Thus, the limit is 0.
