Site map 

 Contact Graeme 

 Skip Navigation LinksMath Help > Counting > Countable > Counting Ordered Pairs -- Example

After my first explanation to Andrew about the one-to-one correspondence between the counting numbers and the ordered pairs, he asked for clarification, so here it is:

Counting Ordered Pairs, an Example


On 11/15/00 6:01:55 PM, Andrew Critch wrote:

Ok. That was about as far out of my league as anything I've ever seen (I think). I really didn't understand most of your notation, or how you calculated the values of shell, leg, and element. In fact, I wasn't really sure of what they represented. I would never expect you to explain that entire message to me. All I ask is that you clarify those few points to me; I could probably (what I really mean is HOPEFULLY) figure the rest out on my own.
Thanx a bunch,

Let's start with Shell. Thas 16 points in it (points 9 through 24). The third shell has 24 points in it (points 25 through 48), etc. Do you notice that the number of the first point in each shell is a perfect square? That makes sense, after all, because when you have completed a shell, you've gone through all the elements of a perfect square, except the origin, which is not part of the sequence.

That's what a shell is. Do you get that? OK, now, what shell is the nth point in? The answer is the integer portion of (sqrt(n)+1)/2 -- that is, figure out (sqrt(n)+1)/2, and then round down to the next lower integer. So if n is 34, then sqrt(n) is about 5.8, and (sqrt(n)+1)/2 is about 3.4. When I round that down I get 3. So the 34th point is in the 3rd shell.

Each shell is a square. A square has four sides. I call each side a Leg. The Leg number ranges from 0 to 3. The formula that tells you what leg you're on is (n-(2*Shell-1)^2)/(2*Shell), again, rounded down to the nearest smaller integer. So what Leg is the 34th point on? Well, Shell is 3, so

(n-(2*Shell-1)^2)/(2*Shell) is
1 1/2

Which, when I round down to the next integer is 1. So the 34th point of the sequence is on the second leg, which is leg number one (because I count from zero).

On each leg, I number the points on that leg, (I call these points "Elements") from -Shell+1 to Shell. So on the 3rd shell, which is where the 34th point is, the six elements on each leg are numbered from -2 to 3.

When you use the formula for Element, you'll see the 34th point has an element number of 1.

So the 34th point is on Shell 3, Leg 1, Element 1.

The formulas for x and y depend on what the Leg is. There are really four sets of formulas for x and y, one for each leg. On Leg 1, the formulas are


So the 34th point is (-1,3)

If you would like to try other examples yourself, try using this calculator.

Related pages in this website

Look at the Square Spiral and its inverse.


The webmaster and author of this Math Help site is Graeme McRae.