3

Can a continuous function $f: \mathbb{R} \rightarrow \mathbb{R}$ with the following property exist: if $x \in \mathbb{Q}$, then $f(x) \in \mathbb{R} \setminus \mathbb{Q}$, and if $x \in \mathbb{R} \setminus \mathbb{Q}$, then $f(x) \in \mathbb{Q}$?

My attempt: I don't see any problem with this function. I wanted to check if it is consistent with the intermediate value theorem. Let $x_1, x_2 \in \mathbb{Q}$ and suppose that $x_1 < x_2$. Then $f(x_1) = y_1 \in \mathbb{R} \setminus \mathbb{Q}$ and $f(x_2) = y_2 \in \mathbb{R} \setminus \mathbb{Q}$. Intermediate value theorem says that for every $y$ satisfying $y_1 < y < y_2$ there exists an $x$ satisfying $x_1 < x < x_2$ such that $f(x) = y$. So I took a $y \in \mathbb{Q}$ satisfying $y_1 < y < y_2$ (I can do this since $\mathbb{Q}$ is dense in $\mathbb{R}$). Then, since $\mathbb{R} \setminus \mathbb{Q}$ is also dense in $\mathbb{R}$, there certainly exists an $x$ with the property that $x_1 < x < x_2$ and $f(x) = y$.

Or is there maybe something else wrong with this function that I don't see?

Kamil
  • 5,309

1 Answers1

4

I will base my answer on Mr. David's Mitra's comment, for it might be the case that someone may not understand his comment fully.

Suppose that $f:\Bbb R\to \Bbb R$ be a function such that $$\begin{align} f(x)\in\Bbb Q &\quad\text{for all}\quad x\in\Bbb Q^c \\ f(x)\in\Bbb Q^c &\quad\text{for all}\quad x\in\Bbb Q. \end{align}$$

It can be shown that $\mathcal R(f)$, the range of $f$, is a countable set. Indeed, $$ \mathcal R(f)=\mathcal R(f|_{\Bbb Q})\cup\mathcal R(f|_{\Bbb Q^c})\ . $$ Since $\mathcal R(f|_{\Bbb Q})$ is the image of countable set, it is countable. $\mathcal R(f|_{\Bbb Q^c})$ is countable by the assumption that $\mathcal R(f|_{\Bbb Q^c})\subseteq\Bbb Q$. Thus $\mathcal R(f)$ is the union of countable sets so it is countable.

However, every continuous function $f:\Bbb R\to\Bbb R$ is either a constant or its image, i.e. $\mathcal R(f)$, is uncountable!

To see this, we suppose that $f$ is not a constant function (it is obvious from the conditions on $f$ that $f$ cannot be a constant function) i.e. there exist $x,y\in\Bbb R$ such that $f(x)\ne f(y)$. Denote $$ a=\min\{ f(x),f(y)\}, \\ b=\max\{ f(x),f(y)\}. $$

By the Intermediate Value Theorem, for any $c\in(a,b)$ there is a $\xi$ between $x$ and $y$ such that $f(\xi)=c$. This shows that $$ [a,b]\subset \mathcal R(f), $$ contradicting the fact that $\mathcal R(f)$ is countable.

Conclusion: Such a function $f$ does not exist.

BigbearZzz
  • 15,530
  • 1
    I followed your argument, but I don't understand your last step. How does $[a, b] \subset R(f)$ contradict the fact that $R(f)$ is countable? Because $[a,b]$ is uncountable and so it cannot be a subset of a countable set? – Kamil Jul 07 '16 at 13:19
  • @Kamil Exactly! Every subset of a countable set must be countable (possibly finite). – BigbearZzz Jul 07 '16 at 13:21
  • @Kamil If there's anything else you want to ask, please feel free! – BigbearZzz Jul 07 '16 at 13:24