Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
Countable Sets and the Cartesian Product of them

Consider the following question:

Describe a function $ \mathbb{Z}^+ \times \mathbb{Z}^+$ to $\mathbb{Z}^+ $ that is one-to-one and onto (bijection).

This is quite a mind twister. Namely, anything of like $f(x,y) = x + y$, $f(x,y) = xy$, etc. is neither one-to-one or onto.

I'm quite lost on this one. Thoughts?

share|cite|improve this question

marked as duplicate by t.b., Srivatsan, J. M., Zev Chonoles Oct 14 '11 at 1:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Maybe the following equivalent problem is more intuitive: consider the lattice of all points in the first quadrant with integer coordinates. Can you draw a curve which passes through every lattice point? – user7530 Oct 14 '11 at 1:14
up vote 3 down vote accepted

picture $\mathbb{Z}^+$ x $\mathbb{Z}^+$ as an infinite square of dots. It should have 2 sides.

now start counting as follows: Start with the first dot. Then follow the dot to the right of it. Then the dot above the first one. Then the dot above this last dot. Now count diagonally to your down-right. Once you've reached the side of the infinite square, proceed to the dot to the right of the one you stopped. then diagonally up-left-ward until you reach the left side of the square. then go up and diagonally towards down-right. proceed...

It should look like this:

enumerating Z^+ x Z^+


if you rotate this infinite square by $\frac{\pi}{2}$

share|cite|improve this answer
I like how rational your integers are. – mixedmath Oct 14 '11 at 1:19
This is definitely the way I think about. Draw it graphically, imagine trying to lay a number line on top of a grid by spiraling or zig-zagging, then figure out what the actual function or pattern is by writing down the first bunch of relations. – Jon Beardsley Oct 14 '11 at 1:27
Took me a while to wrap my head around this, but I get it now. Thanks. – David Chouinard Oct 14 '11 at 2:35

There are lots of ways to go at this question. The general idea is to not try to explicitly write a function (at first), but to instead realize that this just asks you to count all the pairs of natural numbers. Literally, count them, one at a time, leaving no number out and skipping no counting number.

For example, one might associate $(1,1)$ with $1$, $(1,2) \to 2$, $(2,1) \to 3$, $(1,3) \to 4$, etc. (Draw a picture to see what I'm doing).

To turn that into an explicit function isn't so bad once you see the pattern.

Or you might spiral, or anything. Alternatively, if you just have to show that one exists, you could map $(n_1, n_2) \to 2^{n_1}\cdot 3^{n_2}$ (why is this injective?) and $n \to (1, n)$ (obviously injective. Then we have injections from one into the other, and so we have that they have the same cardinality.

Is that a good start?

share|cite|improve this answer

Assuming ${\mathbb{Z}}^{+}$ are positive integers:

$f(x,y)=2^{x-1} (2y-1)$

For nonnegatives:

$f(x,y)=2^x (2y+1) - 1$

Every natural number can be uniquely decomposed as a power by two times an odd number. This is a bijection.

For another example: pairing function.

share|cite|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.