I first saw this pattern that I'm about to show
you in a question on the Math Stack Exchange.
It was asked by a user under the name Dwymark, and answered by Greg Martin,
and it relates to the distribution of prime numbers,
together with rational approximations for pi.
You see, what the user had been doing was playing around with data in polar coordinates.
As a quick reminder so we're all on the same page,
this means labeling points in 2D space not with the usual xy coordinates,
but instead with a distance from the origin, commonly called r for radius,
together with the angle that radial line makes with the horizontal, commonly called theta.
For our purposes, this angle will be measured in radians,
which basically means that an angle of pi is halfway around, and 2 pi is a full circle.
Notice, polar coordinates are not unique, in the sense that adding 2 pi to that second
coordinate doesn't change the location that this pair of numbers is referring to.
The pattern that we'll look at centers around plotting points
where both of these coordinates are a given prime number.
There is no practical reason to do this, it's purely fun,
we're just frolicking around in the playground of data visualization.
To get a sense for what it means, look at all the whole numbers,
rather than just the primes.
The point 1,1 sets a distance 1 away from the origin, with an angle of 1 radian,
which actually means this arc is the same length as that radial line.
And then 2,2 has twice that angle, and twice the distance.
And to get to 3,3, you rotate one more radian,
with a total angle that's now slightly less than a half turn,
since 3 is slightly less than pi, and you step one unit farther away from the origin.
I really want you to make sure that it's clear what's being plotted,
because everything that follows depends on understanding it.
Each step forward is like the tip of a clock hand,
which rotates one radian with each tick a little less than a sixth of a turn,
and it grows by one unit at each step.
As you continue, these points spiral outwards,
forming what's known in the business as an archimedean spiral.
Now if you make the admittedly arbitrary move to knock out everything
except the prime numbers, it initially looks quite random, after all,
primes are famous for their chaotic and difficult to predict behavior.
But when you zoom out, what you start to see are these very clear
galactic-seeming spirals, and what's weird is some of the arms seem to be missing.
And zooming out even further, those spirals give way to a different pattern,
these many different outward-pointing rays.
And those rays seem to mostly come in clumps of four,
but there's the occasional gap, like a comb missing its teeth.
The question for you and me, naturally, is what on earth is going on here?
Where do these spirals come from, and why do we
instead get straight lines at this larger scale?
If you wanted, you could ask a more quantitative question,
and count that there are 20 total spirals, and then up at that larger scale,
if you patiently went through each ray, you'd count up a total of 280.
And so this adds a further mystery of where these numbers are coming from,
and why they would arise from primes.
Now this is shocking, and beautiful, and you might think that
it suggests some divine hidden symmetry within the primes.
but to study your expectations, I should say that the fact
that the person asking this question on math exchange jumped
right into prime numbers makes the puzzle a little misleading.
If you look at all the whole numbers, not just the primes,
as you zoom out, you see very similar spirals.
They're much cleaner, and now there's 44 of them instead of 20,
but it means that the question of where the spirals come from is,
perhaps disappointingly, completely separate from the question of what happens
when we limit our view to primes.
But don't be too disappointed, because both these questions are still phenomenal puzzles.
There's a very satisfying answer for the spirals,
and even if the primes don't cause the spirals,
asking what goes on when you filter for those primes does lead you to
one of the most important theorems about the distribution of prime numbers,
known in number theory as Dirichlet's theorem.
To kick things off, let's zoom back in a little bit smaller.
Did you notice that as we were zooming out, there were these six little spirals?
This offers a good starting point to explain what's happening in the two larger patterns.
Notice how all the multiples of 6 form one arm of this spiral.
then the next one is every integer that's one above a multiple of 6,
and then includes all the numbers 2 above a multiple of 6,
Then after that it includes all the numbers 2 above a multiple of 6, and so on.
Why is that?
Well, remember that each step forward in this sequence involves a turn of one radian,
so when you count up by 6, you've turned a total of 6 radians,
which is a little less than 2 pi, a full turn.
So every time you count up by 6, you've almost made a full turn, it's just a little less.
Another six steps, a slightly smaller angle.
Six more steps, smaller still, and so on, with this angle changing
gently enough that it gives the illusion of a single curving line.
When you limit the view to prime numbers, all but two of these spiral arms will go away.
And think about it, a prime number can't be a multiple of 6,
and it also can't be 2 above a multiple of 6 unless it's 2,
or 4 above a multiple of 6, since all of those are even numbers.
It also can't be 3 above a multiple of 6, unless it's the number 3 itself,
since all of those are divisible by 3.
So, at least at this smaller scale, nothing magical is going on.
And while we're in this simpler context, let me
introduce some terminology that mathematicians use.
Each one of these sequences, where you're counting up by 6,
is fancifully called a residue class mod 6.
The word residue here is sort of an overdramatic way of saying remainder,
and mod means something like where the thing you divide by is.
So, for example, 6 goes into 20 three times, and it leaves a remainder of 2.
So 20 has a residue of 2 mod 6.
Together with all the other numbers leaving a remainder of 2 when
the thing you divide by is 6, you have a full residue class mod 6.
I know that sounds like the world's most pretentious way of saying
everything 2 above a multiple of 6, but this is the standard jargon,
and it is actually handy to have some words for the idea.
So looking at our diagram, in the lingo, each of these spiral arms
corresponds to a residue class mod 6, and the reason we see them
is that 6 is close to 2 pi, turning 6 radians is almost a full turn.
And the reason we see only 2 of them when filtering for primes is that all prime
numbers are either 1 or 5 above a multiple of 6, with the exceptions of 2 and 3.
With all that as a warmup, let's think about the larger scale.
In the same way that 6 steps is close to a full turn,
taking 44 steps is very close to a whole number of turns.
Here, let's compute it.
There are 2 pi radians per rotation, right?
So taking 44 steps, turning 44 radians, gives a total of 44 divided by 2 pi rotations,
which comes out to be just barely above 7 full turns.
You could also write this by saying that 44 sevenths is a close approximation for 2 pi,
which some of you may better recognize as the famous 22 sevenths approximation for pi.
What this means is when you count up by multiples of 44 in the diagram,
each point has almost the same angle as the last one, just a little bit bigger.
So as you continue on with more and more, we get this
very gentle spiral as the angle increases very slowly.
Similarly, all the numbers 1 above a multiple of 44 make another spiral,
but rotated one radian counterclockwise.
Same for everything 2 above a multiple of 44, and so on,
eventually filling out the full diagram.
To phrase it with our fancier language, each of
these spiral arms shows a residue class mod 44.
And maybe now you can tell me what happens when we limit our view to prime numbers.
Primes cannot be a multiple of 44, so that arm won't be visible.
Nor can a prime be 2 above a multiple of 44, or 4 above, and so on,
since all those residue classes have nothing but even numbers.
Likewise, any multiples of 11 can't be prime, except for 11 itself,
so the spiral of numbers 11 above a multiple of 44 won't be visible,
and neither will the spiral of numbers 33 above a multiple of 44.
This is what gives the picture those Milky Way-seeming gaps.
Each spiral we're left with is a residue class
that doesn't share any prime factors with 44.
And within each one of those arms that we can't reject out of hand,
the prime numbers seem to be randomly distributed.
That's a fact I'd like you to tuck away, we'll return to it later.
This is another good chance to inject some of the jargon mathematicians use.
What we care about right here are all the numbers between
0 and 43 that don't share a prime factor with 44, right?
The ones that aren't even and aren't divisible by 11.
When two numbers don't share any factors like this,
we call them relatively prime, or also co-prime.
In this example you could count that there are 20 different numbers between 1
and 44 that are co-prime to 44, and this is a fact that a number theorist would
compactly write by saying phi of 44 equals 20,
where the Greek letter phi here refers to Euler's totient function,
yet another needlessly fancy word, which is defined to be the number of integers
from 1 up to n which are co-prime to n.
It comes up enough that it's handy to have compact notation.
More obscurely, and I had never heard this before but I find it too
delightful not to tell, these numbers are sometimes called the totitives of n.
Back to the main thread, in short, what the user on math exchange was seeing
are two unrelated pieces of number theory but illustrated in one drawing.
The first is that 44 sevenths is a very close rational approximation for 2 pi,
which results in the residue classes mod 44 being cleanly separated out.
The second is that many of these residue classes contain zero prime numbers,
or sometimes just one, so they won't show up, but on the other hand primes do show
up enough in all 20 of the other residue classes that it makes these spiral arms visible.
And at this point maybe you can predict what's going on at the larger scale.
Just as 6 radians is vaguely close to a full turn,
and 44 radians is quite close to 7 full turns,
it just so happens that 710 radians is extremely close to a whole number of full turns.
Visually, you can see this by the fact that the point ends up
almost exactly on the x-axis, but it's more compelling analytically.
710 radians is 710 divided by 2 pi rotations, which works out to be 113.000095.
Some of you may have seen this in another form.
It's saying that 710 one hundred thirteenths is a close approximation for 2 pi,
which is more commonly seen in saying that 355 over 113 is a very good approximation
for pi.
If you want to understand where these rational approximations are coming from,
and what it means for one like this to be unusually good,
like way better than you would get for phi or e or square root of 2 or
other famous irrationals, I highly recommend taking a look at this great Mathologer video.
For our storyline though, it means that when you move forward by steps of 710,
the angle of each new point is almost exactly the same as the last one,
just microscopically bigger.
Even very far out, one of these sequences looks like a straight line.
And of course, the other residue classes, mod 710, also form these nearly straight lines.
710 is a big number though, so when all of them are on screen,
and there's only so many pixels on the screen, it's a little hard to make them out.
So in this case, it's actually easier to see when we limit the view to primes,
where you don't see many of those residue classes.
In reality, with a little further zooming, you can see
that there actually is a very gentle spiral to these.
But the fact that it takes so long to become prominent is a wonderful illustration,
maybe the best illustration I've ever seen, for just how good an approximation this is
for 2 pi.
Tying up the remaining loose thread here, if you want to understand what
happens when you filter for primes, it's entirely analogous to what we did before.
The factors of 710 are 71, 5, and 2, so if the remainder,
or residue, is divisible by any of those, then so is the number.
When you pull up all of the residue classes with odd numbers,
it looks like every other ray in the otherwise quite crowded picture.
And then of those that remain, these are the ones that are divisible by 5,
which are nice and evenly spaced at every 5th line.
Notice the fact that prime numbers never show up in any of these is what
explains the pattern of the lines we saw at the beginning coming in clumps of 4.
And moreover, of those remaining, these four residue classes are the ones that are
divisible by 71, so the primes aren't going to show up there,
and that's what explains why the clumps of 4 that we saw occasionally have a missing
tooth in your cone.
And if you were wondering where that number 280 came from,
it comes from counting how many of the numbers from 1 up to 710 don't share any
prime factors with 710.
These are the ones that we can't rule out for including
primes based on some obvious divisibility consideration.
This of course doesn't guarantee that any particular one will contain prime numbers,
but at least empirically when you look at this picture,
it actually seems like the primes are pretty evenly distributed among the remaining
classes, wouldn't you agree?
This last point is actually the most interesting observation of the whole deal.
It relates to a pretty deep fact in number theory, known as Dirichlet's theorem.
To take a simpler example than residue classes mod 710, think of those mod 10.
Because we write numbers in base 10, this is the same thing
as grouping numbers together by what their last digit is.
Everything whose last digit is 0 is a residue class,
everything whose last digit is 1 is another residue class, and so on.
Other than 2, prime numbers can't have an even number as their last digit,
since that means they're even.
And likewise, any prime bigger than 5 can't end in a 5.
There's nothing surprising there, that's one of the
first facts you observe when you learn about prime numbers.
Anything bigger than 5 has to end in either a 1, a 3, a 7, or a 9.
A much more nuanced question, though, is how exactly these
primes are divvied up among those remaining four groups.
Here, let's make a quick histogram, counting through each prime number,
where the bars are going to show what proportion of the primes we've seen so far have a
given last digit.
So in particular, the 2 and the 5 slots should go down to 0 over time.
What would you predict is going to happen as we move through more and more primes?
Well, as we get a lot of them, it seems like a pretty
even spread between these four classes, about 25% each.
And probably that's what you would expect.
After all, why would prime numbers show some sort
of preference for one last digit over another?
But primes aren't random, they are a definite sequence,
and they show patterns in other ways, and it's highly non-obvious how you would
prove something like this.
Or, for that matter, how do you rigorously phrase what it is you want to prove?
A mathematician might go about it something like this.
If you look at all the prime numbers less than some big number x,
and you consider what fraction of them are, say, 1 above a multiple of 10,
that fraction should approach 1 fourth as x approaches infinity,
and likewise for all of the other allowable residue classes, like 3 and 7 and 9.
Of course, there's nothing special about 10.
A similar fact should hold for any other number.
Considering our old friends the residue classes mod 44, for example,
let's make a similar histogram, showing what proportion of the primes show up in each
one of these.
Again, as time goes on, we see an even spread between the 20 different
allowable residue classes, which you can think of in terms of each spiral
arm from our diagram having about the same number of primes as each of the others.
Maybe that's what you'd expect, but this is a shockingly hard fact to prove.
The first man who cracked this puzzle was Dirichlet in 1837,
and it forms one of the crowning jewels at the foundation of modern analytic
number theory.
Histograms like these ones give a pretty good
illustration of what the theorem is actually saying.
Nevertheless, you might find it enlightening to see how it might
be written in a math text, with all the fancy jargon and everything.
It's essentially what we just saw for 10, but more general.
Again, you look at all the primes up to some bound x,
but instead of asking for what proportion of them have a residue of, say, 1 mod 10,
you ask what proportion have a residue of r mod n, where n is any number,
and r is anything that's co-primed to n.
Remember, that means it doesn't share any factors with n bigger than 1.
Instead of approaching 1 fourth as x goes to infinity,
that proportion goes to 1 divided by phi of n,
where phi is that special function I mentioned earlier that gives the
number of possible residues co-primed to n.
In case this is too clear for the reader, you might see it buried in more notation,
where this denominator and the numerator are both written
with a special prime-counting function.
The convention, rather confusingly, is to use the symbol pi for this function,
even though it's totally unrelated to the number pi.
In some contexts, when people refer to Dirichlet's theorem,
they refer to a much more modest statement, which is simply that each of
these residue classes that might have infinitely many primes does have infinitely many.
In order to prove this, what Dirichlet did was show that the primes
are just as dense in any one of these residue classes as in any other.
For example, imagine someone asks you to prove that there are
infinitely many primes ending in the number 1,
and the way you do it is by showing that a quarter of all the primes end in a 1.
Together with the fact that there are infinitely many primes,
which we've known since Euclid, this gives a stronger statement,
and a much more interesting one.
Now the proof, well, it's way more involved than would be reasonable to show here.
One interesting fact worth mentioning is that it relies heavily on complex analysis,
which is the study of doing calculus with functions whose
inputs and outputs are complex numbers.
Now that might seem weird, right?
Prime numbers seem wholly unrelated to the continuous world of calculus,
much less when complex numbers end up in the mix, but since the early 19th century,
this is absolutely par for the course when it comes to understanding how primes are
distributed.
And this isn't just antiquated technology either.
Understanding the distribution of primes in residue classes
like this continues to be relevant in modern research too.
Some of the recent breakthroughs on small gaps between primes,
edging towards that ever-elusive twin-prime conjecture,
have their basis in understanding how primes split up among these kinds
of residue classes.
Okay, looking back over the puzzle, I want to emphasize something.
The original bit of data visualization whimsy that led to these patterns,
well, it doesn't matter, no one cares.
There's nothing special about plotting p,p in polar coordinates,
and most of the initial mystery in these spirals resulted from the artifacts
that come from dealing with integer number of radians, which is kind of weird.
But on the other hand, this kind of play is clearly worth it if the
end result is a line of questions that leads you to something like Dirichlet's theorem,
which is important, especially if it inspires you to learn enough to
understand the tactics of the underlying proof.
No small task, by the way.
And this isn't a coincidence that a fairly random question
like this can lead you to an important and deep fact for math.
What it means for a piece of math to be important
and deep is that it connects to many other topics.
So even an arbitrary exploration of numbers, as long as it's not too arbitrary,
has a chance of stumbling into something meaningful.
Sure, you'll get a much more concentrated dosage of important facts by going
through a textbook or a course, and there will be many fewer uninteresting dead ends,
but there is something special about rediscovering these topics on your own.
If you effectively reinvent Euler's totient function before you've ever seen it defined,
or if you start wondering about rational approximations before learning about
continued fractions, or if you seriously explore how primes are divvied up between
residue classes before you've even heard the name Dirichlet,
then when you do learn those topics, you'll see them as familiar friends,
not as arbitrary definitions, and that will almost certainly mean that you learn
it more effectively.
Thank you.