# $f(x)\in \mathbb Q,$ if $x\not\in \mathbb Q$ and $f(x)\not\in \mathbb Q$, if $x\in \mathbb Q$. [duplicate]

$f(x)\in \mathbb Q,$ if $x\not\in \mathbb Q$ and $f(x)\not\in \mathbb Q$, if $x\in \mathbb Q$. Can $f$ be continuous?

I have tried using the sequential definition of continuity on rational and irrational sequences, but not getting anywhere.

Any suggestions?

• See this. – David Mitra Sep 18 '15 at 7:12

No, it is not possible for $f$ to be continuous.

Suppose that there was a continuous $f$. Then $f(\mathbb{Q})$ has countable image, since $\mathbb{Q}$ is countable. And $f(\mathbb{R}\backslash \mathbb{Q})$ has countable image, since its image is a subset of the rationals. And so $f(\mathbb{R})$ is countable.

On the other hand, since $\mathbb{R}$ is connected and $f$ is continuous, then $f(\mathbb{R})$ is connected. But the only connected countable sets are singletons, $\{x\}$, which is clearly a contradiction. $\diamondsuit$

As an alternate end, which doesn't use connectedness (directly, that is) but instead uses the Intermediate Value Theorem:

Call $f(0) = a$, which is some irrational, and $f(\pi) = b$, which is some rational. Since $f$ is continuous, the image of $f$ must contain every number in the interval $[a,b]$. However there are uncountably many points on$[a,b]$, while the image of $f$ has only countably many points. We have a contradiction. $\diamondsuit$

• I am only aware of the two definitions of continuity and the LUB property of rationals. So, I dont understand what $\mathbb R$ is connected means. Sorry, but I didn't get your solution. – Apurv Sep 18 '15 at 6:46
• @Apurv do you know the Intermediate Value Theorem? – davidlowryduda Sep 18 '15 at 6:48
• Yes, i know the IVT – Apurv Sep 18 '15 at 6:50

Clearly image of the given continuous function is countable. Again it assumes rational and irrationals both values and so by intermediate value theorem for continuous functions image of $f$ assumes uncountable values, which is a contradiction. So no such function exists.