Let $f$ be a continuous nonconstant function on the reals. Could it map almost all irrationals to rationals?


This is impossible if $f$ maps *all* irrationals to rationals, by a well known result.


This is impossible if $f$ preserves measure 0 sets, because then $\{f(x)| f(x)\textrm{ is irrational}\}$ has measure $0$.



Does there exist a continuous nonconstant function $f$ that maps almost all irrationals to rationals?
Take the [Cantor function](https://en.wikipedia.org/wiki/Cantor_function) $c:[0,1] \to [0,1]$. It is rational almost everywhere. To create a function $f: \mathbb R \to \mathbb R$, apply a transform like $x \mapsto \frac {\sin x + 1} 2$, i.e., $f(x)=c(\frac {\sin x + 1} 2)$.


