What is an example of a bijective function f: Z to N that isn't piecewise?

1k Views Asked by At

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$.

5

There are 5 best solutions below

0
On

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.

3
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.

0
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}.$$

0
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}$.

1
On

IBWiglin's example, written another way: $$ A(n) := \frac{(-1)^n(-2n-1)+1}{4} $$ Then $$ A(0)=0, \\ A(1)=1, \\ A(2)=-1, \\ A(3)=2, \\ A(4 )=-2 $$ The inverse of this function can presumably be written in terms of the Lambert W function...