# How can we construct a $1-1$ correspondence between $(0,1$) and $\mathbb{R}$ that transform irrationals into irrationals and rationals into rationals?

This is an exercise in "Elements of set theory by Enderton". I can construct a function from the rational unit interval into rationals easily. So, If I can find a $1-1$ correspondence from real unit interval into reals that transform irrationals into irrationals, I can construct the required function easily.

Now I assume that I can find a function $g$ mapping rationals into rationals.

Now For irrationals: I can transform irrationals of $\mathbb{R}-(0,1)$ into $(0.1,1)$ as follows, suppose $a_ma_{m-1}..a_1.b_1b_2...$ is an irrational real number whose integer part is $a_ma_{m-1}..a_1$. Now consider $0.a_ma_{m-1}a_{m-2}...a_2a_1b_1b_2......$ as its image under the transformation. It seems that this is another irrational which lies between $0.1$and $1$, notice that $a_m\ne 0$, So we still have $(0.0.1)$ to be used. Now for $x\in (0,1)$, we can embed them into $(0,0.1)$. Suppose $0.c_1c_2c_3...$ is an irrational between zero and $1$. its image is $0.0c_1c_2c_3...$. So we can transform all irrationals of reals into irrationals of the open unit interval. we call this transformation $h$.

Now consider $f:(0,1)\rightarrow \mathbb{R}$ where $f(x)=h(x)$ if $x$ is irrational, $f(x)=g(x)$ otherwise.

My main question: Is my construction valid? If not, why?

Also, If my construction works well, Is there any better constructions?

• @PedroTamaroff, If $t$ is irrational, $\frac{t}{1-t^2}$ could be rational as the division of irrational by irrational is not necessarily irrational. How can we make sure? – Fawzy Hegab Jan 25 '15 at 23:08
• There are two problems with your mapping function: First, it's not one-to-one, e.g. $2$ and $20$ are both mapped to $0.2$. Second it's not well defined since you map $1\in\mathbb R\setminus(0,1)$ to $0.1\not\in(0.1,1)$ and it's unclear what $0$ is mapped to. – kremerd Jan 25 '15 at 23:25

Your construction is not injective. It satisfies $$f(x)=f(10x)$$ since doing so, bumps $b_1$ to the left of the decimal point, but since we move the decimal point all the way back over, this doesn't matter in the end. For instance, we'd get $f(\sqrt{2})=f(10\sqrt{2})$.
I think the simplest construction of such an $g:(0,1)\rightarrow \mathbb R$ is probably $$g(x)=\begin{cases}\frac{1}{x-1}+2&&\text{if }x>\frac{1}2\\0&&\text{if }x=\frac{1}2\\ \frac{1}x-2&&\text{if }x<\frac{1}2\end{cases}$$
A strategy which yields a lot of such functions would be to choose some increasing, bijective function $f:\mathbb Q \cap (0,1)\rightarrow \mathbb Q$ and simply consider its extension to a continuous function on $\mathbb R$, which will be bijective. It turns out you have a lot of degrees of freedom when you construct such an $f$, and it even yields something continuous.
• @Math The relation $f(x)=f(10x)$ still holds and is still a problem. I added an explicit example of why that's a problem. There may be a way to salvage your attempt - maybe something along the lines of writing your number in scientific notation (in base $2$), encoding the exponent with a Fibonacci coding, and follow that with the binary expansion of the significand, which forms an injective function but not surjective on the desired domain. It would be hard to figure out how to make something which always works. – Milo Brandt Jan 25 '15 at 23:43
• @mijucik My best guess would be that I figured that taking $x$ to $1/x$ preserves rationality as does adding a rational number to $x$ and that, this property of rationality-preserving being quite special, I'd better stick to only using them - but would clearly need piecewise definition. From there, one just needs to imitate the usual examples of (continuous) bijections $(0,1)\rightarrow\mathbb R$ by putting an asymptote at $0$ and an asymptote at $1$ and then just to figure out how to connect those two functions into a piecewise definition. – Milo Brandt Jun 9 at 4:47