The prime numbers form the Ulam Spiral: the diagonal alignment and the link with quadratic formulas

The prime numbers form the Ulam Spiral: the diagonal alignment and the link with quadratic formulas

In the Spiral of Ulam the prime numbers are not arranged randomly, but occupy diagonal lines that have to do with relatively simple formulas.

In 1963, to pass the time during a boring conference, the Polish-American mathematician Stan Ulam began writing down the natural numbers in the shape of a spiral, later deciding to circle only the prime numbers. This simple pastime led to a surprising discovery: inside what is now known as Ulam Spiralthe prime numbers arrange themselves with an unexpected regularity. Instead of appearing randomly, they tend to align along specific diagonal lines, a fascinating phenomenon that can be partly described and explained through the use of quadratic formulas.

We can build this spiral by proceeding like this: we write the number 1 in the center and to its right we write the number 2, then above the 2 we write the number 3, then we write 4 to the left of the 3 and then we continue forming a spiral like the one in the image below. Up to this point it is a simple spiral but, we can get a real Ulam Spiral graphically highlighting the prime numbersfor example we did it by writing the prime numbers in red on a dark gray background.

In the Ulam Spiral the numbers are arranged in a spiral which widens outwards from 1 and the prime numbers are highlighted graphically (here with red color on a dark gray background)

The image obtained, at first glance, does not seem to have anything special but Ulam did not stop at the number 20 and realized that, by extending the spiral, the prime numbers they arrange themselves in manner curiously regular (see image below).

Image
Representation of the Ulam spiral made up of 120,000 numbers: the white dots of the prime numbers are arranged along diagonal lines

The mathematician expected to find a substantially random arrangement, but to his surprise he realized that in his spiral the prime numbers arranged themselves forming a pretty regular plot aligning along diagonal lines. The effect is all the more evident the more numbers the spiral contains and to highlight it we used the help of the computer (as Ulam also did) to create an image of a spiral made up of 120,000 numbers.

The regularity with which the prime numbers seem to arrange themselves surprised Ulam, but the mathematician realized that this regularity was not random, but rather had to do with some formulas that can be used to produce sequences of prime numbers. It’s about quadratic formulasthat is, which require that a number be multiplied by itself, thanks to which it is possible make evident some pieces of diagonals of the spiral of Ulam. Precisely by using 3 of these formulas we were able to highlight some of the diagonal lines formed by the prime numbers in the Ulam spiral: for the numbers in blue we used the Legendre formula (obtained from a Euler’s formula), n × n – n + 41; the numbers highlighted in green were found with the Honaker formula, 4 × n × n + 4 × n + 59; finally the red points were identified with the formula n × n – n – 13 freely obtained by us by modifying the Legendre formula.

Image
Ulam spiral with highlighted prime numbers obtained with 3 different formulas: n×n–n+41 (blue); n×n–n–13 (red); 4×n×n+4×n+59 (green).