Bijection between open and partially closed interval

elementary-set-theory

i need some help finding an explicit bijection between $(0,1)$ and $[0,2]\cup[3,5]$. I know it exists because of Cantor's theorem but im struggling to find it.

I've tried with dividing the problem to use an already known bijection from $[0,2]$ to $(0,\frac{1}{2})$ ,then finding a bijection from $(3,5]$ to $(\frac{1}{2},1)$ while sending 3 into $\frac{1}{2}$.

My last try was the following but it ended up not being onto:

\begin{equation}
S={x|x=\frac{1}{n+2}+\frac{1}{2},n\in N^{+}}\\
f(x)=
\begin{cases}
5(\frac{1}{n+1}+\frac{1}{2}), & x\in S \\
4x+1, & x\notin S
\end{cases}
\end{equation}

I'd appreciate some help on this please.

Best Answer

I'll describe the map $[0,2]\cup [3,5]\to (0,1)$ because it may look simpler: $$ f(x)=\begin{cases}1-\frac1{n+1}=\frac1{2-x}&x=1-\frac1n\\ 1+\frac1{n+1}=2-\frac{1}{x}&x=1+\frac1n\\x&\text{otherwise}\end{cases}$$ would biject $[0,2]\to (0,2)$. $$ f(x)=\begin{cases}4+\frac1{n+1}=5-\frac1{x-3}&x=4+\frac1n \\x&\text{otherwise}\end{cases}$$ would biject $[3,5]\to [3,5)$. Combine and scale a bit to arrive at $$ f(x)=\begin{cases}\frac1{2-x}&x<1, \frac 1{1-x}\in \Bbb N\\ 2-\frac{1}{x}&1<x\le 2, \frac 1{x-1}\in\Bbb N\\ 5-\frac1{x-3}&x>4,\frac 1{x-4}\in\Bbb N\\ \frac{x-1}4&x\ge 3,(x=4\text{ or }\frac 1{x-4}\notin\Bbb N \\ \frac x4&\text{otherwise}\end{cases}$$