I'm working on an exercise asking me to construct an explicit formula for a bijection between $(0,1]$ and $(0,1)$. I come up with:
$f(x)= \frac{x}{2}$ if $x = \frac{1}{2^n}$ , and $f(x) = \frac{1}{2^n}+\frac{1}{2^{n+1}}-x$ , if $x \in (\frac{1}{2^{n+1}} \, ,\frac{1}{2^n})$ , where $n \in \{0,1,2,...\}.$
It seems to me it's 1-1 and onto from the graph, but I can't be sure whether it's right or not. Could anyone tell me whether it's correct? Thanks.
I elaborate on Jorge's comment. The only thing different between the two sets is the extra element $1=2^0$. Consider mapping $2^0$ to $2^{-1}$, $2^{-1}$ to $2^{-2}$, and so on. Then, you get a bijection.
Formally, let $A=\{2^{-n} \vert n=0,1,2,\dots\}$, $B = A -\{1\}$, $g$ be the identity function on $(0,1)-B$, and $h:A\mapsto B, x\mapsto x/2$. Clearly $g$ and $h$ are bijections. Then, $f:(0,1]\mapsto (0,1), x\mapsto \begin{cases}g(x) &, x \notin A \\ h(x) &, x\in A\end{cases}$ is a bjiection.