TITLE: Bijective function excluding 0
QUESTION [5 upvotes]: Construct a bijective function $f:\mathbb R\to\mathbb R\setminus\{0\}$. Prove that the function is bijective.

Im having trouble with this... A few concepts that I get so far
is that function essentially should be representing $\mathbb R$, which in turn maps to the same set of real numbers excluding 0. Im thinking about proving its bijective by proving the function is both injective and surjective. Im thinking about doing $x^2+1$ but am uncertain if this is the right sort of track to take. Would really appreciate guidance

REPLY [8 votes]: The classic natural number shifting argument works:
$$f(x)=\begin{cases}x+1&x\in\mathbb N\\x&\text{else}\end{cases}$$
(Here $0\in\mathbb N$.)
Suppose $f(a)=f(b)$. Then either this value is not a positive integer, in which case $a=b$ (since the first case only produces positive integers), or it is a positive integer, whence $a=b=f(a)-1=f(b)-1$ again. Hence $f$ is injective.
Real numbers that are not positive integers are the images of themselves, while the positive integers are the images of their respective predecessors. Thus $f$ is also surjective, hence bijective.
The inverse function is
$$f^{-1}=\begin{cases}x-1&x\in\mathbb N,x\ne0\\x&\text{else}\end{cases}$$