# Showing that a function is not continuous

$$f(x)= \left\{ \begin{array}{} x, &x\in \mathbb{Q} \\ 0, &x\in \mathbb{R} \setminus\mathbb{Q} \end{array} \right.$$ Show that f is not continuous for $x\neq0$.

I'd like to know if my attempted solution is ok:

Let $x_0\neq0$ and $\delta\gt0$. Since rational and irrational numbers are dense in $\mathbb{R}$, there exist $x_1\in\mathbb{Q}$ and $x_2\in\mathbb{R}\setminus\mathbb{Q}$ so that $x_1,x_2\in U'(x_0,\delta)$. Let $\epsilon=\frac{|x_1|}{2}$. Then $|f(x_1)-f(x_2)|=|x_1|>\epsilon$ and f is not continuous.

• Do you mean $f(x)=x$ if $x\in\mathbb Q$? Otherwise this is not well defined. – Gregory Grant May 13 '15 at 17:55
• That was a mistake, sorry. Corrected now. – user240297 May 13 '15 at 17:58
• The flow could be improved. You should define $\epsilon$ before ever mentioning $\delta$. That's because non-continuity means there exists an $\epsilon$ such that $\forall$ $\delta>0$ etc... – Gregory Grant May 13 '15 at 18:02

Suggested edits: Fix $x_0\neq 0$. Let $\epsilon=\frac{x_0}{2}$. For every $0<\delta$, there exists a rational number $x_1$ and an irrational number $x_2$ in $U(x_0,\delta)$, and $|x_1|>\frac{x_0}{2}$.
Then $|f(x_1)-f(x_2)|=|x_1|>\frac{x_0}{2}=\epsilon$, which means $f$ is not continuous.
The preimage of, say, $]1,2[$ definitely not open.