0

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

D Wiggles
  • 2,918
srujzs
  • 11

5 Answers5

2

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.

Arthur
  • 206,103
1

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.

copper.hat
  • 179,003
1

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

GEdgar
  • 117,915
  • 1
    I tried that Lambert thing, but you need to use a different branch of W for each value ... sort of the ultimate in piecewise writing. – GEdgar Nov 19 '14 at 21:38
0

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

Peter Franek
  • 12,010
0

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

D Wiggles
  • 2,918