**Prime Spirals – Patterns in Primes**

One of the fundamental goals of pure mathematicians is gaining a deeper understanding of the distribution of prime numbers – hence why the Riemann Hypothesis is one of the great unsolved problems in number theory and has a $1 million prize for anyone who can solve it. Prime numbers are the the building blocks of our number system and are essential to our current encryption methods such as RSA encryption. Hence finding patterns in the primes is one of the great mathematical pursuits.

**Polar coordinates**

The beautiful prime spiral was generated above on Desmos using polar coordinates. We can see a clear spiral pattern – so let’s see how to create this. Polar coordinates (r, θ) need a length (r) from the origin and an angle of anti-clockwise rotation from the origin (θ). So for example in polar coordinates (2,2) means a length of 2 from the origin and a rotation of 2 radians. By considering trigonometry and the unit circle we can say that the polar coordinates (r, θ) are equivalent to the Cartesian coordinate (r.cosθ, r.sinθ).

**Plotting prime pairs**

So we plot the first few prime pairs:

Polar: (2,2). Cartesian: (2cos2, 2sin2).

Polar: (3,3). Cartesian: (3cos3, 3sin3).

Polar: (5,5). Cartesian: (5cos5, 5sin5).

In Desmos (making sure we are in radians) we input:

We can then change the Desmos graph view to polar (first click on the spanner on the right of the screen). This gives the first 3 points of our spirals. Note I have labeled the points as polar coordinates.

I then downloaded the first 1000 prime numbers from here. I then copied this list of comma separated values and pasted it into an empty part of square brackets M = [ ] in Desmos to create a list.

I can then plot every point in the list as a prime pair by doing the following:

We can then generate our prime spiral for the first 1000 prime pairs:

Just to see how powerful Desmos really is, I then downloaded all the prime numbers less than or equal to 100,000 from here. This time we see the following graph:

We can see that we lose the clear definition of the spiral – though there are still circular spirals with higher densities of primes than others. Also we can see that there are higher densities of the primes on some of the radial lines out from the origin – and other radial lines where no primes appear.

**Prime Number Theorem**

We can also use our Desmos result to investigate another (more fundamental) result about the distribution of prime numbers. The prime number theorem states:

Here pi(N) is the number of prime numbers less than or equal to N. The little squiggle means that as N gets large pi(N) becomes better and better approximated by the function on the RHS.

For our purple “spiral” above we downloaded all the primes less than or equal to 100,000 – and Desmos tells us that there were 9,592 of them. So let’s see how close the prime number theorem gets us:

We can see that we are off by an error of around 9.46% – not too bad, though still a bit out. As we make N larger we will find that we get a better and better approximation.

Let’s look at what would happen if we took N as 1,000,000,000. From Wikipedia we can see that there are 50,847,534 primes less than or equal to 1,000,000,000. Therefore:

This time we are off by an error of only 5.10%. Have a look at the table of values in Wikipedia to find how large N has to be to be within 1% accuracy.

So this is a nice introduction to looking for patterns in the primes – and a good chance to explore some of the nice graphical capabilities of Desmos. See if you can find any more patterns of your own!

## 1 comment

Comments feed for this article

July 18, 2021 at 11:37 am

Yogeeta BhambhaniInteresting exploration.