Home > Uncategorized > The 17-armed spiral within a spiral

The 17-armed spiral within a spiral

July 22, 2015

Last Friday I visited my high school math camp, HCSSiM, where I became a nerd. I also taught there multiple times over the years, and in 2012 I blogged my lectures.

Why the visit? You see, we loyal alums of HCSSiM have a tradition of going back every July 17th to celebrate “Yellow Pig day,” which consists of a talk where founder and director (David) Kelly talks extensively about fun facts regarding the number 17, which happens before dinner, and then after dinner we sing “yellow pig carols” and eat an enormous amount of cake in the shape of a yellow pig. You can learn more about this ridiculous and hilarious tradition here.

Anyhoo, this year we (I went with other nerds) missed the 17 talk because of traffic in Connecticut but we made it for the dinner and carols. Luckily at dinner I had the chance to talk to Kelly, and I asked him if there were any new 17 facts this year. He told me there was one, and it was slightly mysterious. This post is an attempt to explain it a bit.

The mathematical set-up is explained here. Namely, we start with something called the Ulam Spiral, which is simply a way to label the boxes of an infinite two-dimensional grid with the natural numbers. You start at some place and then spiral outwards from there. Here’s a picture:

The center of the Ulam Spiral

The center of the Ulam Spiral

OK, so the first thing to say is that, when you label the plane like this, primes tend to cluster along lines. I think this is what Ulam thought was cool about his spiral:

Primes are black. This is the spiral with 200 layers.

Primes are black. This is the spiral with 200 layers.

Now comes the observation. You need to know what a triangular number is first, though. Namely, it’s a number that corresponds to counting up how many dots you need to form a triangle. We say the nth triangular number corresponds to a triangle with n rows. Here are the first few:

Screen Shot 2015-07-22 at 4.50.32 AM

You can also draw these triangles so that consecutive ones fit together to form squares.

When you highlight the triangular numbers in the Ulam Spiral, instead of the primes, then you get something that looks weird:

Green dots are triangular.

Green dots are triangular numbers within the Ulam Spiral.

OK so if you count those spiral arms, you’ll see there are 17 of them. But does that last forever? And if so, why?

Well, the answer is going to be yes. And here’s a rough proof. Rough because it uses asymptotic limits, so technically I will not show that the above picture extends perfectly, but rather that it eventually does look like a spiral with 17 arms.

A famous story about Gauss tells us that the formula for the nth triangular number is

T_k = k \cdot (k+1) /2.

Also, by construction of the Ulam Spiral, the bottom right corner of each “spiral layer” is an odd square, and that if we call that number n^2, there will be 4 \cdot n + 4 boxes on the very next layer, corresponding to the 4 sides of the next layer plus the 4 corners of the next layer.

Now imagine that there’s a triangular number right on that bottom right corner. That would mean that for some k,

k \cdot (k+1) /2 = n^2, or in other words that

k^2 + k = 2 \cdot n^2.

This is when things get asymptotic. Imagine that n is very very large. That would mean that k is too (everything here is a positive integer), and in particular that the k^2 term would dwarf the k term above. In other words, we could approximate:

k = \sqrt{2} \cdot n.

My next question is, how many triangular numbers would lie on the next layer of the spiral? Well, as we said above there are 4 \cdot n + 4 spots in the next layer, which we will approximate by 4 \cdot n, and the triangular number coming after T_k is T_{k+1}, which is k+1 bigger than T_k, corresponding to adding one layer to a triangle with k rows. We will approximate k+1 by \sqrt{2} \cdot n, again ignoring small terms.

For that matter, the next few triangular numbers after T_k come regularly, about k spots after the first. Therefore there are about 4 \cdot n / (\sqrt{2} \cdot n) triangular numbers in the next row of the Ulam spiral. That comes out to 2 \sqrt{2}, which is about 2.83.

So far we’ve figured out that, when n is huge, then after meeting the kth triangular number on the nth row, we will see two more, and get most of the way to a third, by going one more row.

Now let’s do that 6 more times. After traveling 6 rows past a triangular number, we will meet about 12 \sqrt{2} more triangular numbers. But

12 \sqrt{2} = 16.9705627485...,

which is very close to 17. So after traveling the Ulam Spiral for 6 rows, we will just about hit 17 triangular numbers, which will be more or less evenly spaced from each other.

What this means is that we should expect to see a spiral with 17 arms, but that when the picture is enlarged to include a very large number of rows, we will see the spiral shifting very slightly to the other direction.

By the way, I didn’t figure this out immediately. First I had a most delightful time understanding when, exactly, square numbers and triangular numbers coincide. In other words, I wanted to understand when there is a X and an X so that:

X \cdot (X+1) /2= Y^2, or

X^2 + X= 2 \cdot Y^2.

I might write this up in another post, but play around with it for a while if you get bored on the subway.

Categories: Uncategorized
  1. July 22, 2015 at 6:37 am

    coool! …too bad Martin Gardner isn’t around to appreciate this!

    Like

  2. Clark
    July 22, 2015 at 3:19 pm

    I don’t understand the triangular number formula, k (k + 1)/2. That looks like the sum of any first n integers, whether the sum to a triangular number or not. Help?

    Like

    • July 22, 2015 at 3:41 pm

      You’re exactly right! Now just turn those numbers into dots and you’ve got a triangle.

      Like

  3. Marcos Carreira
    July 22, 2015 at 8:52 pm

    A very long time ago I worked out some recurrence formulas for square triangular, square pentagonal and square hexagonal numbers: https://oeis.org/search?q=Marcos%20Carreira&fmt=short

    Like

  4. S. Carnahan
    July 23, 2015 at 4:43 am

    If you zoom out far enough, I think the difference between 16.97 and 17 dots per 6 cycles will cause the spiral to look increasingly “sloped”. Perhaps at some far out point we will perceive a more diffuse collection of spirals reflecting a different approximation to 2\sqrt2.

    Like

  5. YGLENA
    July 23, 2015 at 1:24 pm

    I thought this is nice, so i tried with more larger numbers. First I calculated some numbers which are ‘more closer’ to 2sqrt2 then before, and this is the result:

    (There are three numbers in a row: the third one is the number close to 2sqrt2. There are 14, 17, 82, 99, etc etc.)
    Now I drew triangular numbers within Ulam spiral below 600*600=360000:

    And I counted the number of spirals.

    There are 99 spirals, which is in calculation. Wonderful!

    Like

  6. Matthew Taylor
    July 29, 2015 at 2:34 pm

    Thanks for writing this post; this is a really cool piece of maths! If you’ll permit me, I have a question. Why base your argument on the supposition that there is a triangular number in the bottom right corner, e.g. a square triangular number? I understand the argument that follows, but the square triangular numbers make up a vanishingly small proportion of the triangular numbers, and accordingly for most triangular numbers there isn’t a value of n s.t. k^2 + k = n^2.

    As such surely this assumption only works in the vicinity of a square triangular number & hence so too the result? Perhaps this is why the switch is made from a 3-armed spiral, to a 17-armed spiral, to a 99-armed spiral, and presumably on again?

    Also, I think interestingly, just before each new spiral becomes apparent it seems that the previous spiral ‘turns square’. In the above picture it seems that the 17-armed spiral ‘turns square’ as the 99-armed spiral becomes apparent, and in the picture in your post the original 3-armed spiral ‘turns square’ as the 17-armed spiral becomes apparent. Any ideas why?

    Like

    • July 29, 2015 at 2:40 pm

      Yes, there doesn’t have to be. I just said that to fix ideas, but of course it only actually happens exactly that way every now and then, for solutions of k^2 + k = 2 n^2. But the great thing is, everything on the nth row is of order n^2, and the argument works anyway.

      You’re also right that there are lots of different spirals; 17 is by no means the only one. However, because of the “every 6 rows” phenomenon with 17 points, it is the most obvious one when you see it from high up.

      Like

  1. No trackbacks yet.
Comments are closed.
<span>%d</span> bloggers like this: