Q:

Where is this function continuous/differentiable?

Let $f: \mathbb R \to \mathbb R$ defined by $$f(x):= \begin{cases} x\sin x & x \in \mathbb Q \\ 0 & x\in \mathbb R \setminus \mathbb Q \end{cases}$$
In which $x\in \mathbb R$ is $f$ continuous (differentiable)?
Looking at the graph the obvious assumption is that $f$ is continuous at $k\pi, k\in \mathbb Z$ and discontinuous elsewhere. Let $x\in \mathbb R \setminus \{k\pi, k\in \mathbb Z \}$. If $x$ is irrational: Let $a_n$ be a sequence of rational numbers converging to $x$. Then $$\lim_{n\to \infty} f(a_n) = a_n\sin(a_n) \neq 0,$$
but $x$ is irrational so $f(x) = 0$. Analogous proof for $x$ rational.
Now if $x = k\pi$ for some $k\in \mathbb Z$, let $a_n$ be a sequence converging to $x$. We have 
$$\left \lvert f(a_n) \right \rvert \leq \rvert a_n \sin a_n \lvert \to 0 = x\sin(x),$$
hence $f$ is continuous in $x$. But how to proof where $f$ is differentiable? I assume it is only in $0$, any solution?

A:

Yes, it's only at $0$.
Note that, if $x\neq0$, then $\left|\frac{f(x)-f(0)}x\right|\leqslant|\sin x|\leqslant|x|$. Therefore$$\lim_{x\to0}\frac{f(x)-f(0)}x=0.$$
Other wise, $f$ can only be differentiable at those points at which it is continuous. At $0$, it is differentiable. If $x=k\pi$ for some $k\in\mathbb{Z}\setminus\{0\}$, then$$\frac{f(x)-f(k\pi)}{x-k\pi}=\frac{f(x)}{x-k\pi}.$$Now, if $(a_n)_{n\in\mathbb N}$ is a sequence of rational numbers that converges to $k\pi$, then$$\lim_{n\to\infty}\frac{f(a_n)}{a_n-k\pi}=\lim_{n\to\infty}\frac{a_n\sin(a_n)}{a_n-k\pi}=k\pi(-1)^k$$and if $(a_n)_{n\in\mathbb N}$ is a sequence of irrational numbers that converges to $k\pi$, then$$\lim_{n\to\infty}\frac{f(a_n)}{a_n-k\pi}=0.$$Therefore, the limit$$\lim_{x\to k\pi}\frac{f(x)}{x-k\pi}$$does not exist, and this proves that $f$ is not differentiable at $k\pi$ then.

