Bijection between an open and a closed interval Recently, I answered to this problem:

Given $a<b\in \mathbb{R}$, find explicitly a bijection $f(x)$ from
  $]a,b[$ to $[a,b]$.

using an "iterative construction" (see below the rule).
My question is: is it possible to solve the problem finding a less exotic function?
I mean: I know such a bijection cannot be monotone, nor globally continuous; but my $f(x)$ has a lot of jumps... Hence, can one do without so many discontinuities?

W.l.o.g. assume $a=-1$ and $b=1$ (the general case can be handled by translation and rescaling).
Let:
(1) $X_0:=]-1,-\frac{1}{2}] \cup [\frac{1}{2} ,1[$, and
(2) $f_0(x):=\begin{cases}
    -x-\frac{3}{2} &\text{, if } -1<x\leq -\frac{1}{2} \\ -x+\frac{3}{2} &\text{,
    if } \frac{1}{2}\leq
    x<1\\ 0 &\text{, otherwise} \end{cases}$,
so that the graph of $f_0(x)$ is made of two segments (parallel to the line $y=x$) and one segment laying on the $x$ axis; then define by induction:
(3) $X_{n+1}:=\frac{1}{2} X_n$, and
(4) $f_{n+1}(x):= \frac{1}{2} f_n(2 x)$
for $n\in \mathbb{N}$ (hence $X_n=\frac{1}{2^n} X_0$ and $f_n=\frac{1}{2^n} f_0(2^n x)$).
Then the function $f:]-1,1[\to \mathbb{R}$:
(5) $f(x):=\sum_{n=0}^{+\infty} f_n(x)$
is a bijection from $]-1,1[$ to $[-1,1]$.
Proof: i. First of all, note that $\{ X_n\}_{n\in \mathbb{N}}$ is a pairwise disjoint covering of $]-1,1[\setminus \{ 0\}$. Moreover the range of each $f_n(x)$ is $f_n(]-1,1[)=[-\frac{1}{2^n}, -\frac{1}{2^{n+1}}[\cup \{ 0\} \cup ]\frac{1}{2^{n+1}}, \frac{1}{2^n}]$.
ii. Let $x\in ]-1,1[$. If $x=0$, then $f(x)=0$ by (5). If $x\neq 0$, then there exists only one $\nu\in \mathbb{N}$ s.t. $x\in X_\nu$, hence $f(x)=f_\nu (x)$. Therefore $f(x)$ is well defined.
iii. By i and ii, $f(x)\lesseqgtr 0$ for $x\lesseqgtr 0$ and the range of $f(x)$ is:
$f(]-1,1[)=\bigcup_{n\in \mathbb{N}} f(]-1,1[) =[-1,1]$,
therefore $f(x)$ is surjective.
iv. On the other hand, if $x\neq y \in ]-1,1[$, then: if there exists $\nu \in \mathbb{N}$ s.t. $x,y\in X_\nu$, then $f(x)=f_\nu (x)\neq f_\nu (y)=f(y)$ (for $f_\nu (x)$ restrited to $X_\nu$ is injective); if $x\in X_\nu$ and $y\in X_\mu$, then $f(x)=f_\nu (x)\neq f_\mu(y)=f(y)$ (for the restriction of $f_\nu (x)$ to $X_\nu$ and of $f_\mu(x)$ to $X_\mu$ have disjoint ranges); finally if $x=0\neq y$, then $f(x)=0\neq f(y)$ (because of ii).
Therefore $f(x)$ is injective, hence a bijection between $]-1,1[$ and $[-1,1]$. $\square$

Define a bijection $f:(-1,1)\rightarrow[-1,1]$ as follows: $f(x)=2x$ if $|x|=2^{-k}$ for some $k\in\mathbb{N}$; otherwise $f(x)=x$.
