top of page

Prime spirals

Prime numbers are a big mystery. Whenever we look at them we don't see any pattern, they seem like randomly popping up as we move on a number line, sometimes there are large gaps between them while other times we get two primes very close example: the gap between 5 and 13 is 8 while the gap between 29 and and 31 is only 2, so they feel completely random but today I am going to show you some strange patterns about them, one way to see a pattern is to construct an Ulam spiral.

An Ulam spiral or prime spiral (in other languages also called the Ulam cloth) is a simple method of visualizing the prime numbers that reveals the apparent tendency of certain quadratic polynomials to generate unusually large numbers of primes. It was discovered by the mathematician Stanislaw Ulam in 1963, while he was doodling during the presentation of a "long and very boring paper"at a scientific meeting.

Ulam constructed the spiral by writing down a regular rectangular grid of numbers, starting with 1 at the center, and spiraling out:

He then circled all of the prime numbers:

We can see that prime numbers are lining up along the diagonal, removing all other number we see it clearly :

When we plot the large number of values, we get to see more and more primes lining up on the diagonals.

Hundred's of values :

Thousand's of values :

Note that these diagonals are not always continuous there are gaps in between but definitely they doesn't seem to be random, the random picture of dots will look like this :

All prime numbers, except for the number 2, are odd numbers. Since in the Ulam spiral either all numbers in a diagonal are odd, or all numbers are even, and adjacent diagonals alternate between odd and even, it is no surprise that all prime numbers lie in alternate diagonals of the Ulam spiral.

What's amazing about these patterns is the tendency of prime numbers to align themselves on some diagonals more than the others.

Moreover, we can write an equation for the diagonal and put the values like 1,2,3... and get a prime number, i.e we can have a prime number generator function but there will be gaps i.e it will not be a continuous one.

Example :

There is one more such equation f(x) = x^2 - x + 41;

for x = 0; f(0) = 41, which is a prime

for x = 1; f(1) = 41, which is a prime

for x = 2; f(2) = 43, which is a prime

for x = 3; f(3) = 47, which is a prime

.

.

.

for x = 40; f(40) = 1601, which is a prime

So, for every 1<=x<=40, we get a prime number, hence this equation contains lots of prime numbers.

There are two more lines that have been found to contain much more primes than average these are:

f(x) = x^2 + x + 3399714628553118047

f(x) = x^2 + x - 33251810980696878103150085257129508857312847751498190349983874538507313

So we can see that some lines contain more prime numbers than others, but that's the conjecture actually i.e it hasn't been proved yet.

Now, there are many different kinds of such pattern, there is one more which is pretty interesting and make patterns more clear, this is called a square spiral.

To construct such spiral we write squares of natural numbers each separated by some distance and then connect them with a spiral line and on that spiral line we write the remaining numbers in between the consecutive squares, it will look something like this :

Now again if we trace the path of all the prime numbers we get a pattern which will look like this :

Notice that white line passing in the middle of the pattern, this line as we know consists of squares of numbers which can never be prime.

There are many more variations of Ulam's curves like :

From all these patterns one thing is clear that occurrence of a prime in a series is not completely random, in fact we have some formula to calculate the number of occurences of primes and that is called the prime counting function denoted by π(x).

but this formula is accurate only for large values, even it gets better at predicting prime count for larger and larger values of x, x being the no. of primes in the range (1,x).

So can we say we have an approximate formula and that's why we have an approxiamte pattern, i.e the pattern is also not fully accurate, it has breaks and so the formula, whatever the case is prime numbers are surely a great mystery of mathematics and will continue to baffle the mathematicians time and again.

Thank you folks for reading. Hope you enjoyed the article, have a nice day!


bottom of page