# Does this type of functions exist [duplicate]

Does there exist a cont function $f$ : $\mathbb{R}$ $\rightarrow$$\mathbb{R}$ which takes irrational values at rational points and rational values at irrational points?

• I get the feeling, no. And I suspect this is because of their density – Squirtle Dec 26 '13 at 8:36

No. Such a function is clearly not constant. Let $a$ and $b$ be numbers with $f(a)\ne f(b)$. Then $f(x)$ must take all values between $f(a)$ and $f(b)$ for $x$ between $a$ and $b$. But there are an uncountable number of irrational numbers between $f(a)$ and $f(b)$, and only a countable number of rational $x$ between $a$ and $b$.

• cont here means continuous not constant. – Squirtle Dec 26 '13 at 8:47
• @Squirtle: Such a function is clearly not constant in any case, even if "cont" means continuous. – Mårten W Dec 26 '13 at 8:49
• I didn't say it was.... I agree with the response; however, this simply wasn't the question. – Squirtle Dec 26 '13 at 9:15
• @Squirtle It was the first step to observe that the function $f$ not constant. Then we show that such continuous function impossible because we can not map countable set of rational numbers from $(a,b)$ on to uncountable set of irrational numbers from $(f(a), f(b))$. – Nikita Evseev Dec 26 '13 at 11:15