We see it in nature (the Golden Ratio), and constructs by humans (the movement of share prices). But what about in pure numbers? Especially the most mysterious kind: prime numbers. |

"I would teach the world how the Greeks proved, more than 2,000 years ago, that there are infinitely many prime numbers. In my mind, this discovery is the beginning of mathematics – when humankind realised that, by pure thought alone, it could prove eternal truths of the universe."

Marcus du Sautoy, "Life lessons" The Guardian (April 7, 2005)

As the story goes, Ulam was bored during a seminar in 1963 and began to doodle in his notebook. In this doodle, Ulam drew the positive integers on a square spiral of the number line, with 0 (or 1, it doesn't much matter) at the center. Then he marked the primes on this folded up number line and immediately noticed that under this unusual transformation many primes tend to fall on diagonal line fragments as well as some horizontal and vertical fragments. |

Ulam's paper associated the diagonal dust with the known fact that many simple quadratic functions produce primes for some range of inputs. The right sidebar explains this in more detail. The quadratic prime generators are fragmentary in their output and in no way represent a general nth prime algorithm. The pattern in Ulam's spiral can be seen as a visualization of these quadratic fragments. But why would quadratics have a tendency to generate prime numbers? |

The primes being a kind of mathematical honey pot, the diagonal dust in his spiral has led to much discussion of the reason for the clearly visible pattern despite the lack of predictability in the primes. Some even assert this figure shows a hidden structure in the primes. Although such assertions are naive, it is nevertheless enlightening to explore why all those diagonal fragments appear by using an even more strongly visual tack than Ulam could manage in the days of Maniac II.

You can begin by asking what simple sets of numbers look like when square spiraled. Here are images of all the multiples of 3, all the multiples of 7, and all odd numbers - meaning the removal of all multiples of 2 - on the square spiral.

You can begin by asking what simple sets of numbers look like when square spiraled. Here are images of all the multiples of 3, all the multiples of 7, and all odd numbers - meaning the removal of all multiples of 2 - on the square spiral.

It turns out that every spiraling of the integer multiples of a single number creates a unique pattern. This usually but not always consists of a repetition of a sort of stamp made up of n values that is repeated but which rotates at diagonal quadrant changes, a clear example of which is seen in the multiples of 7 above. The image on the right is especially worth noting despite it looking like a boring checkerboard. It is a subtractive image of what is left after removing all the multiples of two, that is: it is all the odd numbers on the square spiral. Since all prime numbers except 2 are odd, all the prime numbers except 2 are in the blue squares of that checkerboard.

The diagonal dust in Ulam's prime spiral can be seen as being a result of the sheer density of the primes within the positive integers. One can produce quite similar figures by random selection of points from the remainder structure of the integers at the density of the primes once the multiples of only the first few primes have been removed. The line fragments are the result of the rising density of the primes on the eroding remainder structure rather than any result of their particular values. With each removal cycle of another prime's multiples, the prime density on the remainder structure goes up and this happens fast enough that the diagonal quality of the earliest remainder structure is never completely eroded.

But none of that has anything to do with particular primes, just their density. It is almost thermodynamic in nature and playing out on the odd "crystal" of the square spiraled number line.

There's more beauty than mystery in the diagonal dust in Ulam's spiral. It was a clever doodle indeed that Ulam drew. It's an unusual and scalable visual compression of the number line in a way that can allow patterns, meaningful or not, that would not normally be visible to become so.

###### Ponder this

Does the Ulam Spiral prove that the appearance of prime numbers are not random?

Can we tell whether the spiral is merely a coincidence or an actual pattern? What are the implications if they are indeed discernible patterns?

###### Discuss

Stanislaw Ulam originally drew the spiral using a four-point spiral, what if we were to build one based on five- or six-point spirals? Will we get a pattern as well? Does it actually prove a pattern exists or our ability to see patterns everywhere (even when there is none)?

###### Further readings

Ulam spiral, for a more detailed description on the phenomenon.

"

*A Visual Display of Some Properties of the Distribution of Primes*", the paper co-authored by Ulam as a result of his 'doodle'.

Ulam spiral at Alperton, an interactive Javascript application that displays the prime numbers up to 10^18.

Pareidolia, a psychological phenomenon in which the mind perceives a familiar pattern where none exists. This is a possible explanation.