0

I wonder if it is possible to construct a continuous $f : \mathbb R \to \mathbb R$ such that for each $x \in \mathbb R$, $f(x)$ is irrational if and only if $x$ is rational?

my attempt

Sadly, I pretty much don't know where to start with this one. Intuitively I feel this is impossible. But I just can't see what could go wrong. Any help would be appreciated. Thanks!

msd15213
  • 643

1 Answers1

3

As lulu has suggested in the comment, the answer is no.

proof

Evidently, if $f$ is constant, it cannot satisfy the requirement.

Suppose $f$ is nonconstant. Then $f$ must be nonconstant on some compact subset $[a, b]$, $a, b\in \mathbb R$.

Since $f$ is continuous, it achieves its minimum and maximum on $[a, b]$. Denote the minimum as $m$ and the maximum as $n$, then $f$ achieves every value in $[m, n]$ at least once, again by continuity of $f$.

Since there are uncountably many irrational numbers in $[m, n]$ and the set of all rational numbers is countable, it cannot be the case that $f(x)$ is irrational if and only if $x$ is rational. $\square$

Many thanks to lulu for the hint!

msd15213
  • 643