How to define an injective and surjective function from $\mathbb{Z}$ to $\mathbb{N}$? I want to show that $|\mathbb{Z}|=|\mathbb{N}|$. FWIW, I think again that I must define a injective and surjective function from $\mathbb{Z}$ to $\mathbb{N}$. But how? Is there any proof as to how could one define such functions and based on what information?
 A: Since you are to show that $\mathbb{N}$ and $\mathbb{Z}$ have the same cardinality, you're correct: you need to find a bijection (hence both injective and surjective) between $\mathbb Z $ and $\mathbb N$
One bijection between $\mathbb{Z}$ and $\mathbb{N}$ is the function $f: \mathbb{Z} \to \mathbb{N}$, defined by:

$$f(k) = 
\begin{cases}  \\ \\ 
2k & \quad k \in \mathbb Z,\; k>0 \\ \\
-2k + 1 & \quad k\in \mathbb Z, \; k \leq 0 \\ \\
\end{cases}
$$
In words, you are simply mapping positive integers to positive even integers, and non-positive integers to positive odd integers. 
A: You can do something like this, $f\colon\mathbb{Z} \to \mathbb{N}$. By $f(0) = 0,\; f(1) = 1, \;f(-1) = 2,\; f(2) = 3,\; f(-2) = 4,\;$ etc. This gives a bijection from $\mathbb{Z}$ to $\mathbb{N}$. 
I leave it as an exercise for the reader to give an explicit formula for the function $f$. 
A: You can use this approach by cases as well:
$\mathbb{N}:0,\ \ \ \ \ 1, \ \ 2,\ \  \ \ \ 3,\ \ 4,\  \ \ \ \  5,\ \ 6,  \ \ \ \ \ 7, \ \ 8,...$
$\mathbb{Z}:0,\  -1, \ 1,\  -2, \ 2, \ -3,\  3,\  -4,\  4,... $
Here you can clearly observe two cases with each with two equations:
Case 1:


*

*$2x$

*$-2x -1$
Case 2:


*

*$\frac{x}{2}$

*$-\frac{x+1}{2}$
Solve one case for one-to-one  and the other one for onto function.
