# How to show that $f$ is continuous only at $x=0$

Can any one help me to answer this question:

Assuming $$f(x)=\begin{cases} x &\text{if }x\in \mathbb{Q} \\ 0 &\text{if }x\in \mathbb{R}\setminus\mathbb{Q} \end{cases}$$

show that $$f$$ is continuous only at $$x=0$$?

Notice: use this theorem

Let $$f:D\rightarrow \mathbb{R}$$ and let $$c\in D$$. Then $$f$$ is continous at $$c$$ if and only if, whenever $$X_n$$ is a sequence in $$D$$ that converges to $$c$$, then $$f(X_n)$$ converges to $$f(c)$$

I hope someone can answer this question

Thanks

• Which is it that you have problems with - to show that $f$ is continuous at $0$ or to show that is it discontinuous everywhere else? – Karolis Juodelė Apr 8 '13 at 7:34

Hints: To show that $f$ is continuous at $0$, use the easy result that $\lim_{x\to x_0} f(x)=0 \iff \lim_{x\to x_0}|f(x)|=0$ (the proof of this result is almost a tautology, and involves only unpacking the definitions.
To show that $f$ is discontinuous at any point $p\ne 0$, choose two sequence that converge to $p$, one consisting of rationals only and one consisting of irrationals only (you will need to justify the existence of such sequences). Then use the second result you quote.
Notice that $|f(x)| \le |x|$, hence if $x_n \to 0$, then we have $f(x_n) \to 0$. Hence $f$ is continuous at $x=0$.
If $x \ne 0$, then let $q_n$ be a sequence of rationals converging to $x$, and let $\alpha_n$ be a sequence of irrationals converging to $x$. Then we have $f(q_n) = q_n \to x$ and $f(\alpha_n) = 0 \to 0$. Since $x \ne 0$, $f$ cannot be continuous at $x$ (since for any sequence $x_n \to x$ we would have $f(x_n) \to f(x)$).