How to prove that this function is bijective from $\mathbb{N}\times\mathbb{N}$ to $\mathbb{N}$ I constructed a function $f$ from $\mathbb{N}\times\mathbb{N}$ to $\mathbb{N},$ that is,
$$f(i,j)=\frac{1}{2}(i+j)\cdot(i+j+1)+\frac{1}{2}(1-(-1)^{i+j})\cdot(i+j)+(-1)^{i+j}\cdot i,$$
with which I want to prove the claim that a countable union of countable sets is countable.  Here $\mathbb{N}$ denotes the set of all the nonnegative integers. And I have checked that 
\begin{align*}
&f(0,0)=0,&& f(1,0)=1, &&f(0,1)=2,&&f(0,2)=3,&&f(1,1)=4,&&f(2,0)=5,\\
&f(3,0)=6,&& f(2,1)=7,&&f(1,2)=8,&&f(0,3)=9,&&f(0,4)=10,&&f(1,3)=11...
\end{align*}
Then I have tried to prove that $f$ is bijective. But I have not succeeded. Can anyone help me?
@TheGreatSeo, I constructed such a function $f(i,j)$ by the order indicated in the diagram below:

whose LaTeX codes are:
\begin{center}
\begin{tikzpicture}
\matrix (m) [matrix of math nodes,row sep=3em,column sep=2em,minimum width=2em]
{
(0,0) & (0,1) & (0,2) & (0,3) &(0,4)&\cdots \\
(1,0)&  (1,1)  & (1,2) &(1,3) & \cdots\\
(2,0)&(2,1)&(2,2) &\cdots\\
(3,0)&(3,1) & \cdots&\\
(4,0) & \cdots& &\\
};
  \path[-stealth]
   (m-1-1) edge node [left] {$$} (m-2-1)
   (m-2-1) edge node[above] {$$}(m-1-2)
   (m-1-2) edge node [left] {$$} (m-1-3)
   (m-1-3)edge node{$$}(m-2-2)
   (m-2-2) edge node{$$}(m-3-1)
   (m-3-1) edge node{$$}(m-4-1)
   (m-4-1) edge node{$$}(m-3-2)
   (m-3-2) edge node{$$}(m-2-3)
   (m-2-3) edge node{$$}(m-1-4)
   (m-1-4) edge node{$$}(m-1-5)
   (m-1-5) edge node{$$}(m-2-4)
   (m-2-4) edge node{$$}(m-3-3)
   (m-3-3) edge node{$$}(m-4-2)
   (m-4-2) edge node{$$}(m-5-1);
\end{tikzpicture}
\end{center}
 A: If $i+j$ is odd, $$f(i,j)=\frac12(i+j)(i+j+1)+\frac12(1-(-1))(i+j)+(-1)i=\frac12(i+j)(i+j+1)+j.$$ So for fixed $i+j=n$, as $j$ varys from $0$ to $n$, $f(i,j)$ varys from $\frac12n(n+1)$ to $\frac12n(n+1)+n$.
If $i+j$ is even, $$f(i,j)=\frac{1}{2}(i+j)(i+j+1)+\frac{1}{2}(1-1)(i+j)+1\cdot i=\frac12(i+j)(i+j+1)+i.$$ So for fixed $i+j=n$, as $j$ varys from $n$ to $0$, $f(i,j)$ varys from $\frac12n(n+1)$ to $\frac12n(n+1)+n$.
Thus, for any fixed $i+j=n$, $f(i,j)$ varys from $\frac12n(n+1)$ to $\frac12n(n+1)+n$, where each values comes out exactly one time. What we have to notice is that $\frac12\cdot0\cdot(0+1)=0$ and $(\frac12n(n+1)+n)+1=\frac12(n+1)(n+2)$. From these, we can conclude that $$\bigcup_{n=0}^\infty \left[\frac12n(n+1),~\frac12n(n+1)+n\right]$$ is a disjoint union, and is same as $\Bbb N_0$(in your notation, it is same as $\Bbb N$). Therefore, the proof is completed.

p.s. Can I ask you about how you constructed $f$? It seems a little bit hard for me to construct such a nice function at once.
A: If you want a bijection from $\mathbb N\times\mathbb N$ to $\mathbb N$, then I suggest you construct an easier function, because the one you have is really hard to understand.
Instead, it is easier to find a bijection from $\mathbb N$ to $\mathbb N\times\mathbb N$. The most intuitively understandable function is the function
$$0\mapsto (0,0)\\
1\mapsto (0,1)\\
2\mapsto (1,0)\\
3\mapsto (0,2)\\
4\mapsto (1,1)\\
5\mapsto (2,0)\\
6\mapsto (3,0)\\
7\mapsto (2,1)\\
8\mapsto (1,2)\\
9\mapsto (0,3)\\
\vdots
$$
Which, if drawn on a piece of paper, can quickly be seen to be bijective (and the proof of bijectivity is not hard to put down in stricter terms). For an illustrative proof, look at this picture:

I have drawn the red line from $f(0)$ to $f(1)$ to $f(2)$ and so on. It is easy to understand why I will surely hit every dot exactly once, so the function is bijective.
