# Proving the piecewise function is bijective

Prove that the function $f: \mathbb{Z} \rightarrow \mathbb{N} \cup \{{0}\}$ defined by

$$f(x)= \left\{ \begin{array}{lcc} 2x & x \geq 0 \\ \\ -2x-1& x<0 \\ \\ \end{array} \right.$$ is bijective.

I don't have any familiarity with piecewise functions when dealing with bijective proofs yet. I'm assuming I have to show the bijection for two separate cases? Like for injective assume $f(x)=f(y)$ for some and arrive at $x=y$ with both cases? Would it be possible to find an inverse which would imply its bijective also?

• Both are valid proof methods, assuming that 'two separates cases' would mean proving both injectivity and surjectivity. And yes, it's possible to explicity write a bijection for $f$. – Fimpellizieri Dec 5 '16 at 7:18

Inverse: $g:\mathbb{N}\cup\{0\}\to\mathbb{Z}$
$$g(x)= \left\{ \begin{array}{lcc} \frac{x}{2} & x \text{ is even} \\ \\ -\frac{x+1}{2}& x\text{ is odd} \\ \end{array} \right.$$