If you are a teacher then please also visit my new site: intermathematics.com for over 2000+ pdf pages of resources for teaching IB maths!

**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!

**Essential Resources for IB Teachers**

If you are a **teacher** then please also visit my new site. This has been designed specifically for teachers of mathematics at international schools. The content now includes over **2000 pages of pdf content** for the entire SL and HL Analysis syllabus and also the SL Applications syllabus. Some of the content includes:

**Original pdf worksheets**(with full worked solutions) designed to cover all the syllabus topics. These make great homework sheets or in class worksheets – and are each designed to last between 40 minutes and 1 hour.**Original Paper 3 investigations**(with full worked solutions) to develop investigative techniques and support both the exploration and the Paper 3 examination.- Over 150 pages of
**Coursework Guides**to introduce students to the essentials behind getting an excellent mark on their exploration coursework. - A large number of
**enrichment activities**such as treasure hunts, quizzes, investigations, Desmos explorations, Python coding and more – to engage IB learners in the course.

There is also a lot more. I think this could save teachers 200+ hours of preparation time in delivering an IB maths course – so it should be well worth exploring!

**Essential Resources for both IB teachers and IB students**

1) Exploration Guides and Paper 3 Resources

I’ve put together a **168 page** Super Exploration Guide to talk students and teachers through all aspects of producing an excellent coursework submission. Students always make the same mistakes when doing their coursework – get the inside track from an IB moderator! I have also made **Paper 3 packs** for HL Analysis and also Applications students to help prepare for their Paper 3 exams. The Exploration Guides can be downloaded here and the Paper 3 Questions can be downloaded here.