Home > Analysis, Olympiad > There isn’t such a function

## There isn’t such a function

Prove that there is no continuous function $f: \Bbb{R} \to \Bbb{R}$ such that $f(\Bbb{Q}) \subset \Bbb{R}\setminus \Bbb{Q}$ and $f(\Bbb{R}\setminus \Bbb{Q}) \subset \Bbb{Q}$.

Proof: As noted in the first comment, a continuous function has the Darboux property, which means that given two values $a of its image, the function takes all values between them. This means that either the function is constant, either it has an uncountable number of points in its image. It is easy to see that the function has at least two values in the image, one rational, one irrational. Secondly, the image of the function is countable. These two, with the argument above give the contradiction required.

The problem could be modified such that instead of $f$ continuous, we write $f$ has the Darboux property. Note that there are some weird examples of functions with Darboux property, which have the property above, to switch two sets between them. One such example can be found here.