Peter Chamberlin

web person

The Ulam spiral

A visualization of prime numbers,

Discovered in 1963 by Polish-American mathematician Stanislaw Ulam, the Ulam spiral is a visualization of the prime numbers in a spiral of squares. In a world-changing lifetime Ulam worked on such things as the Manhattan Project, where he came up with the standard detonator for thermonuclear bombs (the Teller-Ulam design), and developed the Monte Carlo method of probabilistic simulation, all of which must have kept him rather busy.

The primes are mysterious. As number theorist Don Zagier puts it in The First 50 Million Prime Numbers, they "sprout like weeds", seemingly at random among the integers, while at the same time possessing "stunning regularity" and strictly obeying laws governing their behaviour.

Finding a way to predict the occurrence of primes has been an obsession of mathematicians for centuries, with such visionaries as Gauss, Euler and Riemann devoting great chunks of their lives to investigations of their properties. Today primes are a key component of many of the world's strongest security systems, such as in public key cryptography, precisely because they are so difficult to compute.

Any insight into the nature of primes then is valuable to mathematicians, and Ulam's spiral gives us a tantalising glimpse. In the spiral the primes can be seen to group along certain diagonals, and to a lesser extent horizontals and verticals, but unpredictably so, hinting at an elusive underlying order.

The spiral itself is created from the inside out, anti-clockwise, with one step for each integer. As the spiral progresses the prime numbers are marked where they appear. There are a number of interesting variations on this concept which can be seen on Wikipedia, or by doing an image search.

The colours used in the animation above are generated pseudo-randomly and are just for fun, they don't have any foundation in the mathematics. Check out the javascript that runs the animation on GitHub.