# Pi and the primes: a pattern related to the Ulam spiral

I have recently been considering the spiral packing pattern (illustrated here) which often appears in plants, and arises by placing the nth point at distance n from the origin and angle 2nπ/φ where φ is the golden ratio. I wondered: what happens if we rotate by 1 radian each time instead of the golden angle? Evidently a less dense packing is obtained; but also, by numbering the points, we have a situation analogous to the Ulam spiral - perhaps more accurately the Sacks spiral - in which the primes may be highlighted.

The Sacks spiral plots the natural number n at an angle proportional to √n and thus is roughly equivalent to considering the square root of primes modulo some value k: for the Sacks spiral itself k = 1, while for the Ulam spiral k = 2. By instead plotting n at an angle proportional to n, we are effectively considering the primes themselves modulo some k: in this case, k = 2π. The result is striking (all graphs are plotted for the first 10000 primes; apologies for the shoddy Excel graphs). My guess is that the 2*10 equidistant parallel lines, plus 2 gaps, correspond to 22 being the numerator in a best rational approximation to π, but honestly this is just a rather shaky intuition based on the appearance of the Fibonacci sequence in the aforementioned golden angle spiral.

In fact the two sets of lines coincide mod π; Shown here are the primes mod π. Just in case π turned out not to be so special after all (though I suspected it was), I returned to the original golden spiral packing by taking the primes and mod φ-1 I also tried taking them mod e and mod √2 (obviously if I took them mod some rational k I'd just get a bunch of horizontal lines). In case anyone has difficulty accessing those images, here's a quick summary: φ and φ-1 give nice sets of lines on a large scale, though the pattern is less clear for smaller numbers of primes (in contrast with π) and I suspect spacings will be related to φ; for e the picture is less clear but there appear to be narrow, regularly-spaced "empty bands"; and for √2 there are again empty bands, but not evenly-spaced. In all cases, the bands form parallel lines. No other irrational k seems to give the nice, clear pattern that π does.

To summarize: there is the general pattern of bands for irrational k; the particularly nice behaviour in the case of π; and the question of when the bands are spaced periodically and, when they are, with what period. Is there some spectacularly simple explanation that I'm missing? If not, have any of these ever been noticed or studied before? What about the more general case of studying pα mod k for primes p and other powers α? Any relevant literature / ideas?

Edit: in fact, for k = π the lines coincide mod π/11 so a prime p is p(1-7π/22) + nπ/22 (mod π) where n is an odd number between -9 and 9.

• The plot (mod e) seems to be just as striking as the (mod pi) plot :-)
– M.G.
Jul 7, 2010 at 11:56
• For the sake of experiment, coud you try something like $(\mod e^{\pi})$
– M.G.
Jul 7, 2010 at 11:59
• Don't let the numerologists get their hands on this, or we will have an epidemic. Jul 7, 2010 at 22:17

Pi has some large partial quotients (that's why 22/7 is such a good approximation), your other irrationals don't. Try some other irrational with a real good rational approximation, and let us know what happens.

I've disappointingly come to the same conclusion as Gerry, that it's got more to do with continued fractions than a special relationship between π and the primes. (Edit: in fact, it doesn't have a great deal to do with the primes at all; rather, the "empty" bands appear due to almost all primes being coprime to any given numerator, as explained below. The only special thing about the primes is that they are coprime to all such numerators, so the pattern of empty bands will appear at all scales.) Returning to the case k = π:

For p ∉ {2,11} we have:

7p ≡ an odd number n ≠ 11 (mod 22)

so p(7π/22) ≡ nπ/22 (mod π),

so p ≡ p(1-7π/22) + nπ/22 (mod π)

The key property is that 22/7 ≅ π, so that the slope (1-7π/22) is small enough to be visible over a large range. Given γ irrational and a/b ≅ γ, only finitely many p divide a, so in general we have bp ≡ n coprime to a (mod a). Then p(bγ/a) ≡ nγ/a (mod γ), so p ≡ p(1-bγ/a) + nγ/a a(mod γ).

What made π seem special was that a was small, so the number of possible choices for n was also small. By contrast, φ is difficult to approximate so in order for (1-bγ/a) to be small a must be large.

Finally, my guess is that the less evenly-spaced bands when k = √2 are a result of the numerators of the convergents being particularly composite.

• I realize this conversation is 4 years old, but I'd be really curious to see your images - the links don't seem to work anymore. Oct 2, 2014 at 20:23
• Ok, I've reuploaded them - hopefully they should all work now. Oct 3, 2014 at 13:59