# Find any 1-1 function from $\mathbb{Z}$ to $\mathbb{N}$.

I was thinking $$f(n)=|n|$$, but realized that would be a surjection. I'm not sure of how to solve this. Thank you.

• Hi Amy! What else have you tried? Could you expand on your problem? Are Z and N any set of numbers, or are integers and naturals? The more informatino the better help you'll get! – Lafinur Apr 24 at 3:07
• It's not the fact that this is a surjection is the problem, it's the fact that it's not injective. – Lord Shark the Unknown Apr 24 at 3:09
• @AngelusSilesius Hi, I apologize, N=natural numbers and Z=integers. I apologize. – Amy Kulp Apr 24 at 3:09
• How about a map taking negative numbers to odd numbers and non-negative numbers to even numbers? – J. W. Tanner Apr 24 at 3:12
• Great. Just for the future, there's special mathjax notation to write $\mathbb{N}$ and $\mathbb{Z}$. Don't worry, there's no need to apologize! – Lafinur Apr 24 at 3:12

Let $$f(n)=2(n+1)$$ if $$n\ge0$$ and $$-2n-1$$ if $$n<0$$.

This maps {$$0,1,2,...$$} to {$$2,4,6,...$$} and {$$-1,-2,-3,...$$} to {$$1, 3, 5, ...$$};

i.e., {$$..., -3, -2, -1, 0, 1, 2, ...$$} to {$$1,2,3,4,5,6,...$$}.

The inverse map is $$f^{-1}(m)=\dfrac m 2 -1$$ if $$m$$ is even and $$-\dfrac{m+1}2$$ if $$m$$ is odd.

How about $$f(x)=\begin{cases} 2x\,,x\gt0\\-2x+1\,,x\le0\end{cases}$$

(As @J W Tanner commented.)

Define $$f$$ as follows:

$$f(n) = \left\{\begin{array}{lr} 2^n , & \text{when } n \ge 0 \\ 3^{|n|} , & \text{when } n \lt 0 \end{array}\right\}$$

If you one a closed formula for the function given by @Chris Custer, this works $$f(x)=2|x|-\frac{x-\epsilon}{2|x-\epsilon|}+\frac{1}{2}$$ Here you can choose any $$0<\epsilon<1$$.

Here's another solution: let $$f(n)=2^n$$ if $$n>0, 2^{-n}-1$$ otherwise.