How to show that this function is bijective 
Possible Duplicate:
Proving the Cantor Pairing Function Bijective 

Assume I define
$$ f: \mathbb N \times \mathbb N \to \mathbb N, (a,b) \mapsto a + \frac{(a + b ) ( a + b + 1)}{2} $$
How to show that this function is bijective? For injectivity I tried to show that if $f(a,b) = f(n,m) $ then $(a,b) = (n,m)$ but I end up getting something like $3(n-a) + (n+m)^2 -(a+b)^2 + m - b = 0$ and don't see how to proceed from there. There has to be something cleverer than treating all possible cases of $a \leq n, b \leq m$ etc. 
For surjectivity I'm just stuck. If I do $f(0,n)$ and $f(n,0)$ it doesn't seem to lead anywhere.
Thanks for your help.

Introduce two other functions
$$p(z)=z-\frac{n(n+1)}{2}\textrm{ and }q(z)=n-p(z)$$
where
$$n=\left\lfloor\frac{\sqrt{8z+1}-1}{2}\right\rfloor$$
You can try to prove $p(f(a,b))=a$ and $q(f(a,b))=b$.
In order to prove this, you can use some 2D diagram for integers because $(f,p,q)$ are actually Pairing functions.
Please refer http://en.wikipedia.org/wiki/Pairing_function .
