# Is there a function $f\colon\mathbb{R}\to\mathbb{R}$ such that every non-empty open interval is mapped onto $\mathbb{R}$?

I wonder whether there is a function $f\colon\Bbb R\to\Bbb R$ with the folowing characteristic? for every two real numbers $\alpha,\beta,\alpha\lt\beta$, $$\{f(x):x\in(\alpha,\beta)\}=\Bbb R$$

I can't say such a function does not exist, neither can I construct a example

Thanks a lot!

-
How is this a function from $\mathbb{R} \to \mathbb{R}$? $x$ seems to take on values in $\mathbb{R^2}$. –  Christopher Liu May 11 '14 at 22:24
$x$ takes on values between $\alpha$ and $\beta$ –  user137794 May 11 '14 at 22:25
Oops, thanks. My mistake –  Christopher Liu May 11 '14 at 22:26
See the answer to this question for yet another example. math.stackexchange.com/questions/75589/… –  user4894 Dec 10 '14 at 5:06
This was asked a few times here or on MO: math.stackexchange.com/questions/186427, math.stackexchange.com/questions/454165, mathoverflow.net/questions/32126 Also some answer to this question give also examples of functions like this: math.stackexchange.com/questions/21812 –  Martin Sleziak Dec 10 '14 at 6:36

The Conway base 13 function is one such function. From Wikipedia:

$f$ takes as its value every real number somewhere within every open interval $(a,b)$.

The construction of the function is a little bit complicated. Refer to the wiki page for details.

-
I am really grateful for your prompt help! –  Clin May 11 '14 at 22:41
@Clin Happy to help. –  Ayman Hourieh May 11 '14 at 22:41

I find it easier to define one from $(0,1)$ to $(0,1)$. You can use your favorite bijection to stretch each axis to $\Bbb R$. Express $x \in (0,1)$ in base $3$, choosing the expansion ending in all $2$'s for numbers which would terminate. If $x$ has an infinite number of $2$'s in the expansion, set $f(x)=x$ and ignore it in the rest. If $x$ has a finite number of $2$'s in the expansion, multiply it by $3^k$ so that the last two is just to the left of the ternary point. The expansion is now all $0$'s and $1$'s. Read it as a binary number and return that value. To show it takes all values in an interval, let somebody give you a value $y$ it should take. Express $y$ in binary. Find an interval $(\frac {3m+2}{3^k},\frac {3m+3}{3^k})$ that is within the given interval for some naturals $m,k$. Express $\frac {3m+2}{3^k}$ in ternary and append the binary of $y$ on the right. That will give you an $x$ such that $f(x)=y$ This needs a slight patch because some numbers are mapped to $1$, which is outside the range, so map them to $0.5$ and we are done.

-