Like without using if even or odd. Like how you can define a bijection $f\colon\mathbb{N}\to\mathbb{Z}$ by is $f(n)=\lfloor n/2\rfloor\cdot(-1)^n$.
What is an example of a bijective function f: Z to N that isn't piecewise?
1k Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail AtThere are 5 best solutions below
On
If $0\notin \Bbb N$, then $$\left|2x-\frac12\right|+\frac12$$ works. If not, then subtract $1$ to get $\left|2x-\frac12\right|-\frac12$. To be honest, absolute values have an implicit poecewise-ness to it, but it's hidden away.
On
If I can use the absolute value, then, for example, $$2|x|+\frac{1}{2}\frac{x+1/2}{|x+1/2|}+\frac{1}{2}.$$
On
It doesn't exactly answer your question, but I made a function going the opposite direction $f\colon\mathbb{N}\to\mathbb{Z}$ which is bijective and not implicitly defined piecewise like the example you gave. $$ f(n)=\frac{1}{4}-\frac{1+2n}{4}\cos(\pi n) $$
This is the restriction to $\mathbb{N}$ of the spiral $f\colon \mathbb{R}\to\mathbb{C}$ defined in the complex plane by $$ f(x)=\frac{1}{4}-\frac{1+2x}{4}e^{ix}$$ which can be extended to a complex analytic function on all of $\mathbb{C}$.
Let $f(x) = \max(2x+1,-2x) = {1\over 2} + \max(2x+{1\over 2},-{1 \over 2}-2x) = {1 \over 2} + |2x+{1\over 2}|$.
Then $f: \mathbb{Z} \to \mathbb{N}$ is a bijection.