Can someone show me how to define a function $g: (0, 1) \cup \mathbb{Q} \mapsto (0, 1)$ such that $g$ is one-to-one and onto? What comes to mind is some sort of diagonalization argument function or a piecewise function of the form $g(x)=x$ if $x \in (0, 1)$ and $g(x)=1/x$ if $x \in \mathbb{Q}$ and $x > 1$. Would any of those work? If not, please define one for me. Intuitively, it seems such a correspondence is possible.
5 Answers
The set $\mathbb Q\setminus(0,1)$ is countable, which means that there is a bijection $b\colon\mathbb N\longrightarrow\mathbb Q\setminus(0,1)$. Now consider the map$$\begin{array}{rccc}\beta\colon&\mathbb Q\cup(0,1)&\longrightarrow&(0,1)\\&x&\mapsto&\begin{cases}x&\text{ if $x\neq\frac1n$ for any $n\in\mathbb N$ and $x\in(0,1)$}\\\frac1{2b^{-1}(n)}&\text{ if }x\in\mathbb Q\setminus(0,1)\\\frac1{2n-1}&\text{ if $x=\frac1n$ for some $n\in\mathbb N$.}\end{cases}\end{array}$$Now, prove that $\beta$ is a bijection.

- 427,504
-
You need to adjust this a little bit for rationals that are in $(0,1)$ but not of the form $\frac{1}{n}$. – quarague Mar 27 '19 at 10:37
-
I fail to see the need to adjust something. Is my $\beta$ function not well-defined? Or is it not a bijection? – José Carlos Santos Mar 27 '19 at 10:40
-
You are right, I think it is good as is. – quarague Mar 27 '19 at 10:45
-
So you are not the one who downvoted it? – José Carlos Santos Mar 27 '19 at 10:48
-
I am, but it seems I can't undo the down vote because the answer was not edited (which it doesn't need to be here). I'm confused and posting a meta question about this situation. – quarague Mar 27 '19 at 10:50
-
I've edited my answer. – José Carlos Santos Mar 27 '19 at 11:03
An explicit one, taken from this answer.
$$ f(x)=\begin{cases} 1+\frac{1}{x-2} & x<0 \\ \frac{1}{x+2} & x\ge 0 \end{cases} $$
is a bijection $\mathbb Q \to (0,1) \cap \mathbb Q$. So now we do what @quarague wrote in their answer:
$$ g(x) = \begin{cases} x & x\in(0,1)\setminus\mathbb Q \\ f(x) & x\in \mathbb Q \end{cases} $$
is a bijection $ (0,1) \cup \mathbb Q \to (0,1)$.

- 7,031
Let $b : \mathbb{Q} \rightarrow \mathbb{Q} \cap (0,1)$ be a bijection. This has to exist because both sets are countably infinite. If needed I could construct one explicitly. Then you can simply define $g(x) = x$ for $x \in (0,1) \setminus \mathbb{Q}$ and $g(x) = b(x)$ for $x \in \mathbb{Q}$.

- 5,921
Making use of two following facts,
- $\mathbb{Q} \approx \mathbb{N}=\{1,2,\cdots\}$
- $(0,1]\approx(0,1)$
we can construct one such a bijection in the question.
First, the second fact above tells us $(0,\frac{1}{2}]\approx(0,\frac{1}{2}) , (\frac{1}{2},\frac{3}{4}]\approx(\frac{1}{2},\frac{3}{4}),\cdots$.
Consequently, $(0,1)=\cup_{k\in\mathbb{N}}\left(1-({\frac{1}{2}})^{k-1},1-({\frac{1}{2}})^k\right] \approx (0,1)-\{\frac{1}{2},{(\frac{1}{2})}^2,\cdots\} =\cup_{k\in\mathbb{N}}\left(1-({\frac{1}{2}})^{k-1},1-({\frac{1}{2}})^k\right)$.
Then, with the clear bijection $\mathbb{N}\approx\{\frac{1}{2},{(\frac{1}{2})}^2,\cdots\}$, it gives us $(0,1)\cup\mathbb{N}\approx(0,1)$. And then the first fact above!
(Now I see, the first fact should be $\mathbb{Q}-(0,1)\approx \mathbb{N}$. I just cared it as disjoint union...,or if it were disjoint, this kind of answer could be helpful !?)
(Any comments! if needed, or whatever!)

- 11
What about$$\begin{array}{rccc}g\colon&\mathbb Q\cup(0,1)&\longrightarrow&(0,1)\\&g(x)&\mapsto&\begin{cases}x&\text{ if $x\in(0,1) \setminus \mathbb{Q}$}\\\frac1{x}&\text{ if } x>1 \text{and} x\in\mathbb Q\setminus(0,1)\\\end{cases}\end{array}$$ Why is this not a bijection?

- 723