# Does there exist continous function $f(x)$ defined on $(-\infty ; +\infty)$?

Does there exist continous function $f(x)$ such that $$f(x)=\begin{cases} \frac{m}{n} & \text{if } x \text{ is irrational,} \\ \text{irrational} & \text{if } x \text{ is rational} \end{cases}$$ I think it's impossible, as definition of that function is similar to Dirichlet Function or Thomae's function. And these functions are always discontinous somewhere. Please help, I don't know what to start with. I'm first year undergraduate

• So you want a continuous function which sends rationals to irrationals and vice versa? – Hanul Jeon Jan 30 '17 at 14:55
• What do you denote with $m/n$ ? – Yves Daoust Jan 30 '17 at 14:57
• yes, I do. Sorry for my formulas. I started to learn LaTEX recently – ioleg19029700 Jan 30 '17 at 15:00
• $\frac{m}{n}$ is rational number – ioleg19029700 Jan 30 '17 at 15:01
• Note the proper use of \text{} in MathJax, as seen in my edit. – Michael Hardy Jan 30 '17 at 16:34

FIrst, $f$ cannot be constant, so by the intermediate value theorem, there exists an interval $[a,b]$ such that $[a,b] \subset f(\Bbb R)$ ($a < b$)
So we have $[a,b] \cap (\Bbb{R}-\Bbb{Q}) \subset f( \Bbb{Q} )$
But $\Bbb{Q}$ is countable, so $f( \Bbb{Q} )$ is countable (or finite) too. In the other hand, $[a,b] \cap (\Bbb{R}-\Bbb{Q})$ is uncountable : contradiction
Let $a$ be a rational number and take a sequence $x_n\rightarrow a$ with each $x_n$ irrational. By definition $\lim_{n\rightarrow \infty}f(x_n)=f(a)$. But then $\lim_{n\rightarrow \infty}f(x_n)=\frac{m}{n}=f(a)$, which is impossible.