# Why do prime numbers make these spirals?

HTML-code

**Published: 08 October 2019**- A story of mathematical play.

Home page: 3blue1brown.com

Brought to you by you: 3b1b.co/spiral-thanks

Based on this Math Stack Exchange post:

math.stackexchange.com/questions/885879/meaning-of-rays-in-polar-plot-of-prime-numbers/885894

Want to learn more about rational approximations? See this Mathologer video.

iloverimini.mobi/video/CaasbfdJdJg/video.html

Also, if you haven't heard of Ulam Spirals, you may enjoy this Numberphile video:

iloverimini.mobi/video/iFuR97YcSLM/video.html

Dirichlet's paper:

arxiv.org/pdf/0808.1408.pdf

Important error correction: In the video, I say that Dirichlet showed that the primes are equally distributed among allowable residue classes, but this is not historically accurate. (By "allowable", here, I mean a residue class whose elements are coprime to the modulus, as described in the video). What he actually showed is that the sum of the reciprocals of all primes in a given allowable residue class diverges, which proves that there are infinitely many primes in such a sequence.

Dirichlet observed this equal distribution numerically and noted this in his paper, but it wasn't until decades later that this fact was properly proved, as it required building on some of the work of Riemann in his famous 1859 paper. If I'm not mistaken, I think it wasn't until Vallée Poussin in (1899), with a version of the prime number theorem for residue classes like this, but I could be wrong there.

In many ways, this was a very silly error for me to have let through. It is true that this result was proven with heavy use of complex analysis, and in fact, it's in a complex analysis lecture that I remember first learning about it. But of course, this would have to have happened after Dirichlet because it would have to have happened after Riemann!

My apologies for the mistake. If you notice factual errors in videos that are not already mentioned in the video's description or pinned comment, don't hesitate to let me know.

------------------

These animations are largely made using manim, a scrappy open-source python library: github.com/3b1b/manim

If you want to check it out, I feel compelled to warn you that it's not the most well-documented tool, and it has many other quirks you might expect in a library someone wrote with only their own use in mind.

Music by Vincent Rubinetti.

Download the music on Bandcamp:

vincerubinetti.bandcamp.com/album/the-music-of-3blue1brown

Stream the music on Spotify:

open.spotify.com/album/1dVyjwS8FBqXhRunaG5W5u

If you want to contribute translated subtitles or to help review those that have already been made by others and need approval, you can click the gear icon in the video and go to subtitles/cc, then "add subtitles/cc". I really appreciate those who do this, as it helps make the lessons accessible to more people.

------------------

3blue1brown is a channel about animating math, in all senses of the word animate. And you know the drill with YouTube, if you want to stay posted on new videos, subscribe: 3b1b.co/subscribe

Various social media stuffs:

Website: 3blue1brown.com

Twitter: twitter.com/3blue1brown

Reddit: reddit.com/r/3blue1brown

Instagram: instagram.com/3blue1brown_animations/

Patreon: patreon.com/3blue1brown

Facebook: facebook.com/3blue1brown

3Blue1Brown4 days backImportant error correction: In the video, I say that Dirichlet showed that the primes are equally distributed among allowable residue classes, but this is not historically accurate. (By "allowable", here, I mean a residue class whose elements are coprime to the modulus, as described in the video). What he actually showed is that the sum of the reciprocals of all primes in a given allowable residue class diverges, which proves that there are infinitely many primes in such a sequence.

Dirichlet observed this equal distribution numerically and noted this in his paper, but it wasn't until decades later that this fact was properly proved, as it required building on some of the work of Riemann in his famous 1859 paper. If I'm not mistaken, I think it wasn't until Vallée Poussin in (1899), with a version of the prime number theorem for residue classes like this, but I could be wrong there.

In many ways, this was a very silly error for me to have let through. It is true that this result was proven with heavy use of complex analysis, and in fact, it's in a complex analysis lecture that I remember first learning about it. But of course, this would have to have happened after Dirichlet because it would have to have happened after Riemann!

My apologies for the mistake. If you notice factual errors in videos that are not already mentioned in the video's description or pinned comment, don't hesitate to let me know.

3Blue1Brown I’m a German ninth grader and I like maths and ur vid but now my brain makes weird noises and smokes.

101 x 20 = 2020. 101 is a very interesting prime, I think. At least it is palindrome

@Joe Banks First, let's make it clear between ourselves, that plane is a surface of a 2-sphere with an infinite radius. Secondly: S1 sphere is a boundary of a 2d disc, S2 sphere is a surface of a 3d ball and S3 sphere is a surface of a 4d ball (neither of the latter two you can see, or, to remain on a side of caution, most of us can't see them). This goes on. I think, then, that you wanted to see something where spiral is drawn in 3 d space and coordinates are (r, α, β), where α and β are angles from the x and y positive axes. Pity we don't enjoy true 3d vision, but only a binocular ("stereographic"? - where did Riemann got his idea from) projection of such onto a part of a sphere. I guess, you can go on from here on your own. I think it would be doable in GeoGebra. (I think 3Blue1Brown should use the standard terminology for spheres in his other videos. Moreover, geometric algebra and a proper torus are waiting.)

an important erratum and I surprise to myself get it in the second read. It is too specific information that is hard to google it and find some Wikipedia about it, well I don't research enough is true too. cheers!

my question is this, this points are on one plane of a circle, or i guess saying it's represented in 2D, what would this look like represented as a 3D sphere?

Hello im enjoy

Those patterns don't look very pointless to me. More like pointyful...

The last minute of your talk was profound, enlightening and valuable: the connections of deep math concepts to many manifestations of reality. Thanks.

When i was in 11th grade i figured out the primes followed 5k+6, 7k+6 kind of sequence (i had to think about this bcs of my exam failure) and noticed there was some weird pattern. Appently i was right i guess. But still that damn exam

Man, if my math class played a video related to the topics we were studying in a similar fashion before giving the lecture, I would've been so much hyped for it.

The practical and professional utility of understanding maths aside, videos like this highlight just how visceral the subject can be, and worth studying simply for curiosities sake. As someone who has long lamented my ignorance of the subject, thank you for increasing my motivation to do something about it!

Now play the pattern through morse code, the Illuminati wishes to speak with you.

Someone chose to plot numbers in a way that made a pretty pattern and was then surprised that a subset of these numbers made a modified version of this pattern... Hooplidooda!

Damn!!!! I want him as my tutor.

I dont understand a thing but im thoroughly enjoying this video

What makes those histograms and not bar charts? I thought histograms varied in bar width and used area to represent data?

After seeing a video on Eratosthenes' sieve with Cyberworld by X-ray Dog as its music years ago, I can't help listening to the music while watching this video.

I can never thank you enough 3blue1brown. Just how much you made me love math!

i know you are this smart science guy and all but you spitting all over me man

Suggestion: Series about Navier-Stokes

*Hits the bong*

“Damn those LSD fractal flashbacks are coming again”

Hey Grant, can you make T-shirts of these prime number spirals?

Please do part 2 where you talk about primes in complex analysis! I'm taking a complex analysis class right now!

Your opening reminded me of another alliteration. "The president's predecessors had a propensity to prevaricate, but the present president's prevarications are prolific. "

Because... Aliens!

I don’t know why but this brought tears to my eyes. 😍

Another beautiful video!

i have another strange curve for you, i took a set that went like i colored one black one red than two black and two red, then i took the bottom of it and i made it in a parabola, move the bottom up one, move the bottom up two, etc, i did this for both the positive and negative and i got wo clearly defined curves that had another section in the middle (this section was a cone like curve) that was clearly different, it had no seeming reason for it to be the sorta random it is. why does doing this make these sota curves?

Any interesting video ideas come to mine about the Ackermann Function?

Magnificent!

Awesome video

I have read Uzumaki by Junji Ito! I find this video very spirally indeed

This is the human experience. Our shared understanding of the world and how we attempt to understand the intricacies of it. The knowledge passed down to us that doesn't have an end, the knowledge that not only answers questions but spurs new ones in its place.

Cheers to you 3Blue1Brown, you give explanation to the rigor that drives some people away from exploring the truly beautiful world of mathematics.

this is so amazing, mindblowing and awe inspiring at the same time... Thanks for sharing the explanation and the beautiful animations!!!

what if you do just composites?

This is so fantastic!

yes?

... Pure logic... My head feels fuzzy, my cheeks are flushed, and... Oh my.

quick question what platform/software is used for graphing numbers like these?

There is no "divine" etc.. in that. Since primes are distinctive numbers in maths, fractals and spirals are creating themselves obeying the second law of thermodynamics which is increased entropy.

The set (p,p) in polar coordinates is a subset of the Archimedean spiral r = a*theta where a =1. Since this equation maps a spiral of course (p,p) will map a spiral since it is a subset of the Archimedean spiral. Other than that you can basically answer this using theta = s/r.

If you'd zoom out even further, would there be another close approximation of pi that shows in the spiral? Is this a pattern that goes on infinitely?

the spiral comes from the fact that 3~<π

The spiral comes because the Set S = {(r,theta)| r = theta = p, where p is prime} forms a subset of the Archimedean spiral A = {(r,theta)| r = a*theta, a E R} where a = 1 and r = some prime.

I would like to se a simulation or visualization on how prime numbers and other stuff would look like on a binary, 11, 24 or another number of digits sistems. Like, ending with the same number in prime is only an artifact of the 9 digit sistem we have build. What if there was only 6 or 21 digits?

I just want to say one thing, this guy re-ignited my love for Mathematics !

This is probably how Hawking saw physics in the universe.

ok

No fucking way that’s amazing

Love your videos! Always a joy to watch

Mathematik scheint mir das Problem der Menschen zu sein die die Sprache nicht benutzen.

Nun es ist ganz einfach.. wenn nicht alles wüsste an welchen Platz es zu stehen hätte würde man über eine bestimmte Anzahl an Nummern = Variabel von Erschaffungen nicht hinaus kommen.

Between this video and the "pi hiding in prime regularities" video, I'm hoping that there's a circular trajectory coming back around to the role of primes in the zeta function. I just finished re-reading "The Music of the Primes" by Marcus du Sautoy, and I'm wondering (thanks to this video) if there's a connection between the spirals in this video and the complex-plane spirals in the Riemann video around the 7-minute mark.