Piecewise bijection $f: \Bbb R \to (\Bbb R$ \ $ \{1\})$ I want to define a piecewise-defined bijection $f: \Bbb R \to (\Bbb R$ \ $ \{1\})$ but I'm stuck.
This means that I must define $f(x)$ by cases: $f(x) = g_1(x)$ if $x \in J_1$,   $f(x) = g_2(x)$ if $x \in J_2$,... where $J_1,J_2,...$ are intervals.
I don't know if this one works: 
$f(x) = \frac{1}{x}$ if $x \in (-\infty, 0) \cup (0,1) \cup (1, 2)  \cup (2, \infty)$,   $f(x)=0$ if $x=0$, $f(x)= 2$ if $x=1$.
Edit
$f(x) = \frac{1}{1-x}$ if $x \in (-\infty, 1) \cup (1,\infty), \ f(x)=0$ if $x=1$.
 A: Hint: I'm assuming that most of the functions you were planning on applying to your intervals were going to be continuous — or at worst have a couple of discontinuous points. In this case, you will need to use infinitely (thus countably) many intervals. This can be proven using the following argument:

Claim: Every bijection $f:\mathbb R\to\mathbb R\smallsetminus\{1\}$ has infinitely many points of discontinuity.

We argue by contrapositive: Assume that there are finitely many points of discontinuity $x_1<x_2<x_3<\cdots<x_n$. Define $x_0=-\infty$ and $x_n=\infty$. Then by definition, the restriction of $f$ to
$$f^*: \left(\mathbb R\smallsetminus \{x_i\}_{i=1}^n\right) \to \left(\mathbb R\smallsetminus\left[\{1\}\cup\{x_i\}_{i=1}^n\right]\right)$$
 is a continuous. By continuity, we know that the intervals $(x_k,x_{k+1})$ (with $0\leq k\leq n$) are mapped into intervals $I_k$. However, the domain is the union of $n+1$ intervals, but the codomain is a union of $n+2$ intervals, and so there is some interval in the codomain which is not in Im$(f^*)$ and hence not in Im$(f)$. Therefore, $f$ cannot be a bijection, which proves (by contrapositive) the claim.
