Continuity of a function in the rational and irrational numbers Let $f:\mathbb{R}\rightarrow\mathbb{R}$ defined by $$f(x)=\left\{
   \begin{array}{ll}
     x, & \hbox{if}\,\,\, x\in \mathbb{I} \\
     p\,{{\sin}} \frac{1}{q}, & \hbox{if}\,\,\, x=\frac{p}{q}\in\mathbb{Q},\,\,\, \gcd(p, q)=1 
   \end{array}
 \right.$$
To what point is continuous and discontinuous $ f $ and why?
 A: We first show that $\lim_{x\to a} f(x)=a$ for all $a$. So we need to examine the behaviour of our function at points near $a$ but not equal to $a$. The irrationals near $a$ cause no problem. . We will see that neither do the rationals. 
For note that $p\sin(1/q)=\frac{p}{q}\frac{\sin(1/q)}{1/q}$.  Fix $\epsilon\gt 0$. By taking $x=\frac{p}{q}$ rational and close enough to $a$, we can ensure that the denominator $q$ of $x$ is large enough to make $\left|\frac{\sin(1/q)}{1/q}-1\right|\lt \frac{\epsilon |q|}{2|p|}$. If we also make $\left|\frac{p}{q}-a\right|\lt \frac{\epsilon}{2}$, then our function value will be within $\epsilon$ of $f(a)$.  
If $a$ is irrational, then $f(a)=a$, and the limit result above shows that $f$ is continuous at $a$.  Since $f(0)=0$, we also have continuity at $0$. 
However, we do not have continuity at any rational point other than $0$. For if $a$ is rational and different from $0$, then $f(a)\ne a$, but $\lim_{x\to a}f(x)=a$.
A: Consider a slightly different expression of the function:
$$f(x)=\left\{
   \begin{array}{ll}
     x, & \hbox{if}\,\,\, x\in \mathbb{I} \\
     xq\,{{\sin}} \frac{1}{q}, & \hbox{if}\,\,\, x=\frac{p}{q}\in\mathbb{Q},\,\,\, \gcd(p, q)=1 
   \end{array}
 \right.$$
As such, continuity occurs where $q\sin\frac1q=1$ and when $x=0$. However, $\sin \frac1q\not\in\mathbb{Q}$, and so it cannot be continuous at any point $x\in\mathbb{Q}$. That said, $\lim_{q\to\infty} q\sin\frac1q=1$, and so the function is continuous at all points $x\not\in\mathbb{Q}$.
