The reals as continuous image of the irrationals

For any irrational number $x$, let $f(x)$ be the real number arising from the integer part of $x$, together with every other digit of the rest of the expansion of $x$.

This is surjective, since one may interleave the digits of any real $y$ with any nonrepeating pattern, and thereby find an irrational $x$ with $f(x)=y$. This is continuous, since if $x_n\to x$, then $f(x_n)\to f(x)$.


Let $C$ be a space-filling curve, i.e. a continuous function from $\mathbb R$ onto ${\mathbb R}^2$. Then the first component $C(t)_1$ is a continuous function from $\mathbb R$ onto $\mathbb R$ that hits each real number uncountably many times. Since there are only countably many rationals, the restriction to the irrationals is also surjective.


Here's another simple explicit function that maps the irrationals onto the real numbers. It is defined on the whole real line.

Consider the continuous piece-wise linear function $f:\mathbb{R}\rightarrow\mathbb{R}$, with slope $f'(x)=-1$ or $f'(x)=+1$ according whether $\lfloor x/\sqrt 2\rfloor=0\, \mathrm{ mod} 3 $, or not (like this). So $f(x)=x/3+O(1)$ as $|x|\to\infty$ and it is therefore surjective; precisely, any of its fiber has three points, and the arithmetic mean of some two of these is an odd multiple of $\sqrt{2}$. This means that the equation $f(x)=c$ has always an irrational solution, whatever is $c\in\mathbb{R}$.

rmk. Note that replacing $\sqrt 2$ with $\pi$ produces a map that maps the transcendental numbers onto $\mathbb{R}$.