Question: When showing that $\mathbb{N}\times\mathbb{N}$ is in bijection with $\mathbb{N}$, it seems standard to give a proof by picture that shows a way to systematically weave through all the points in $\mathbb{N}\times\mathbb{N}$ and label each one as you go.

![enter image description here](https://i.stack.imgur.com/okCcv.png)

I know there is a polynomial expression for this method, given by $$
J(m,n)=[1+2+\cdots+(m+n)]+m=\frac{1}{2}[(m+n)^2+3m+n]
$$
where $m$ is the usual $x$-coordinate and $n$ the usual $y$-coordinate.

But how does one "see" how this formula is arrived at? I know how to manipulate the middle expression to arrive at the rightmost expression, but how does the middle expression relate to the weaving pattern through $\mathbb{N}\times\mathbb{N}$? Thank you.

Answer: 
Looking at the diagram, the order is lexicographic, first in $m+n$, then in $m$. The motivation is that it is easy to see you get all the points of $\mathbb{N} \times \mathbb{N}$, so now you just need to figure out what $J(m,n)$ is.
The formula will manifest itself if you begin by thinking about linear expessions of the form

$\tag 1 z = c + ax + by \quad \text{where } a - b = 1$

observing how they behave on the 45 degree down-slanting lines.

Next you calculate on the $y\text{-axis}$ (view as top/left start of down slash segment),

$\quad J(0,k) = \displaystyle{\frac{1}{2}[k^2 +k]}$

Now the point $J(0,k)$ defines the start of one of our 'down slash' lines; we can write $k = x + y$ and $x = 0$. This allows us to write

$\tag 2 J(0,k) = \displaystyle{\frac{1}{2}[((x+y)^2 +y]}$

Now along the diagonal $x + y = k$ and using $\text{(1)}$ to get the functional coefficient for $a$ when $b =.5$ we know $a = 1.5$. But then by seamless splicing we've found the formula

$\tag 3 J(x,y) = \displaystyle{\frac{1}{2}[((x+y)^2 +3x+ y]}$