Is there a bijective function $f: \Bbb Z \to \Bbb N$ that involves only elementary arithmetic and no piecewise functions?

103 Views Asked by At

As the title suggests, I'm looking for a function $f : \Bbb Z \to \Bbb N$ that satisfies the following:

$$ \forall y \in \Bbb N, \exists! x \in \Bbb Z : y = f(x) \\ \therefore\quad \Bbb N = \left\{ f(x) \mid x \in \Bbb Z \right\} \quad\land\quad \Bbb Z = \left\{ f^{-1}(y) \mid y \in \Bbb N \right\} $$

The most common bijective function I've found is something similar to this:

$$ f(x) = \begin{cases} 2x+1 & x \geq 0 \\ -2x & x \lt 0 \end{cases} \\ \therefore\quad f^{-1}(y) = \begin{cases} \frac{y-1} 2 & \text{$y$ is odd} \\ -\frac y 2 & \text{$y$ is even} \end{cases} $$

However, this definition is obviously a piecewise function. Is there any way to write a bijective function that:

  • Doesn't use a piecewise function (is the same formula for all of the domain $\Bbb Z$)
  • Doesn't use any non-elementary functions like $\sin(x)$, $\lvert x \rvert$, etc.
  • Only uses addition/subtraction, multiplication/division, and exponentiation/roots/logs

?

1

There are 1 best solutions below

1
On

The OP ruled out the function $|x|$. But another answer uses $\sqrt{x^2}$. So, assuming that $|x|$ is OK, we can use this $$ f(x) := 2\left|x-\frac{1}{4}\right|-\frac{1}{2} $$ Then $f$ maps $0$ to $0$, maps the negative integers to the positive even integers, and maps the positive integers to the positive odd integers.