# Why do prime numbers make these spirals?

A story of mathematical play.

Home page: www.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.

ispast.info/losk/v-deo/d5KXo5jKyn_HgKA.html

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

ispast.info/losk/v-deo/nXergm-bv5i2goY.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 ISpast, if you want to stay posted on new videos, subscribe: 3b1b.co/subscribe

Various social media stuffs:

Website: www.3blue1brown.com

Twitter: twitter.com/3blue1brown

Reddit: www.reddit.com/r/3blue1brown

Instagram: instagram.com/3blue1brown_animations/

Patreon: patreon.com/3blue1brown

Facebook: facebook.com/3blue1brown

Beautifully visualized, clearly explained. Bonus: the plug for advanced education toward the end.

Wormhole.

The fact that 2.7 million people watched this gives me some hope for mankind.

Easy Fix: Write the numbers in a line!

Those spirals are fascinating and the explanations are amazing.

Everything is so much simpler when you understand that everything that exists was created and intended and dine with purpose by an infinitely intelligent creator. It's our privilege and joy to find the answers to the mysteries He gave us.

Dave Rubin. You sound like Dave Rubin. I've been trying to place it for weeks lol

The Creator(of the universe) is an organised artist

21:28 yes yes numbers are fun. its kinda correct and then pyramid measures was kinda planned i guess LOL everything related close enought. it all looks like planned LOL but what if not. will it mean end of life? if you layer that on US map what you see. was it planned?

6:15 thank alot NOT 1st and last are not lottery numbers but all rest are and do not never use them xD they not win, but diaconal will DID!!!

Dude, you make me love Maths more and more every day

The secrets of the universe are encoded in the first numbers. You just have to know how to read them, to obtain all the universal information available.

I apologise for giving this a thumbs down, but there were 946 dislikes at the time of this comment, and I was not I the mood to see a non-prime number under this video.

hey blue did you ever attempt solving one of the millennium problems? this looks like a clue to the Riemann problem for any mathematician out there you can win 1mil$

You can make a religion out of this.

The unusual kendo ordinarily bang because ray bailly whisper during a irate baboon. terrific, bloody parallelogram

math hasn't made me this happy since 5th grade

Everyone who came here in this video are knowledge seekers.

Wow

i,m 844 mos. old ,4 goes into ,=211 see how it all works out.....hmmmm

13:52 Oh gosh I think I just got hallucinations from that

My brain is now frazzled

Amazing...

SPIRAL OUT KEEP GOING oops, wrong spiral

The Primes were the original leaders of the autobots, who were benevolent, self-configuring robotic lifeforms. Whats all this about numbers?

The null risk reciprocally sin because romania intrestingly tempt to a milky call. juvenile, tested wheel

The summary at the end is so "spot on". It's humbling when you "discover" something that someone 200 years ago already figured, and also turned out to be half your age! But, it shows you still find numbers fun :)

because you're twirling them?

I lost you at 14:30

The null sponge jointly kill because wound lally cure with a wholesale ghana. terrible, hideous high bottom

7:10 - "And the reason we see only two 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." WHOA WHOA WHOA. You can't drop a fundamental fact like that without any explanation at all. _WHY_ are all primes equal to 6n + 1 or 6n + 5?

It was explained just prior to that, starting at 5:45

*how do you make the computer graphics for thises videos? They are not just cgi but rather real plots and real numbers not like theres a function in photoshop to do this especially with thousands of numbers all at the correct location* ?

Totally irrational, the world is rational, no irrationals involved in reality. Have fun in the imaginary world. Volume of a sphere = exactly 5 times the base.

That would be neat, but unfortunately it's just not correct.

Mother Nature is simple...she draws no straight lines. everything is expressed in a curved linear reciprocating processional hyperboloid. look into fibonacci...1235...leaves out 4, which is time and does not exist as a thing--theoria aphophosis-look him up.

Could we move on to third grade advanced calculus for the next video? Now where's the Tylenol???

awesome ......... but , 6 mins in and my ears are hurting with that "stupid spooky music" please let me know when there is a music free version as i would love to watch the rest , it's right up my lane , very sorry , pleaseeee and thanks , tom.

If you took the decimal away from pi (ie 314159...), would the infinite number be prime?

It's wouldn't be a valid number, because integers can only be written with finite digits.

Shouldn't there also be a point like that with 16 noticeable spirals? 16/pi is about as far from an even number of rotations as 6/pi is. Why doesn't that also seem to be the case?

Cool, but they can be arranged differently. Arranging things in different orders can give rise to interesting patterns which sometimes we can take advantage of. But, it should be taken into account that numbers can be arranged in very different ways with very different results. For example, why use base 10? Honestly the base 10 is not the most logical best base to use. We use it because of an arbitrary decision which is strongly related to the fact we have 8 fingers and 2 thumbs which means we can easily count to 10 with our two hands. But, historically humanity has used many other bases. A base which is 2^n where n is a natural number is better, i.e. 2, 4, 8, 16, 32, 64, etc. Of these, for our current level of intelligence, 8 is too simple and 32 is too complex, thus the base of 16 would likely be the best base. Another is, why plot these values in polar coordinates for the Cartesian coordinates (prime, prime). What about (prime, 1)? What about making patterns using Cartesian coordinates or spherical coordinates? Mind you, I am in no way saying there are not interesting things we can learn by forming numbers in a pattern like the one in this video, because clearly we can and that is a good thing. But, we should not forget to make other patterns and look for other interesting results from doing so.

Are you robot?

Mathematicians: "Mysteries of the universe? Hmph, there are no such things. Mathematics has all of the answers.... What was that? "Miillenium" what? Nonsense! I've never heard of such a thing!"

How did you make this video without mentioning Euler even one time? I'm amazed. I spoke 1min too soon. lmao Sorry for doubting you!

Haha!!

"together with the angle that that radial line makes with the horizontal"

The boiling laundry supposedly file because close arespectively flow on a incompetent slime. eatable, stiff flag

wormhole?

Cool video. At first I thought, OMG! Symmetry among primes! Then you explained, and I quickly saw, that it was an illusion. Nice!

these spirals are really cool. wish i understood it. does this suggest that by extending these spirals way, way out we can identify really, really REALLY large prime numbers in a simple way ?

This video mentions Dirichlet's theorem, which basically says that no, you cannot find primes more easily through this.

what if we used a number system based on pi rather than the decimal system?

The disgusted wallet biophysically choke because blowgun endoscopically impress below a oafish sled. eight, scarce share

Will the prime ever be exactly 2pi

@Релёкс84 Thank you

No. Because if it ever did, the you would have found a way to write 2pi as a ratio of to integers. But that is impossible as 2pi is known to be irrational, so it will never happen.

Doesn't it all have to do with our number system being 10-digit based? What would other number systems, with different iteration intervals, do to things like the mandelbrot set? Like counting in groups of 9 or 4, that would affect prime number sequence

it has nothing to do with the way you write numbers. these are properties of the numbers themselves, independently of how you write them.

vortex maths. we learn this in junior school back on vulcan

22 Minutes of useless information, and yet, I am not mad having invested them.

I did not understand half of the math here but still find this incredibly interesting and fascinating

If you zoom the pattern out far enough, it forms the trademark stamp of UniCosmos Anachtakarg, the company that designed and manufactured our Universe in the first place (and many other Universes).

The chief sociology jointly transport because magician worrisomely agree underneath a lyrical branch. diligent, garrulous paul

Great video, thank you so much !

There are not an infinite amount of primes, and I think I can prove it

@Immortal ZoDD While it's true that the "density" of prime numbers decreases the further you go (which is provable but harder to prove) that does not mean at all there is a finite number of them. Also, the sum of 1/n over all integers is not a finite number: it diverges to infinity. Just the fact that a sequence of numbers approaches zero *does not* mean its sum is finite, and this is a very important result. I'm not going to tell you the proof prime numbers are infinite just yet because it's much better for you if you work it out yourself, but I'll give you a clue on where to start: imagine you have a set which contains a finite number of prime numbers - it doesn't matter how many there are or which one they are, just asl ong as it's a finite group of primes. Now consider the number which is defined as the product of all those primes + 1. For instance, if your set contains 2, 3 and 5, this number will be 2x3x5 + 1 = 31. Now the question is: is this number prime? How can you tell? The answer to this question is not trivial, but finding it will definitely put you on the right path to understand why there are infinitely many primes. If you don't understand how to proceed I'll gladly give you the full reasoning but it's much better if at least you give it a try.

@Релёкс84 yeah, I meant a video explaining the proof, much like this one. I'm thinking of plotting prime number frequency, and I imagine at one point it will reach zero. I'm thinking it could be similar to how the sum of 1/n for n = 1 to infinity is a finite number

@Immortal ZoDD Mathematicians don't prove things with videos. I don't know of a video about this, i just know the argument. But if you look up "infinite primes proof" on youtube you'll surely find a lot of results. I'd be glad to hear your reasoning though.

@Релёкс84 I bet there's video proof. Can you point me in the right direction? Want to see if my guess can hold any water

it's easy to prove there is an infinite number of primes.

**Looks at thumbnail** **Looks at title** Me: I don't know man, kinda looks like spiral energy from Gurren Lagan.

12:40 this reminded me of a fingerprint. They also do have spirals. It´s always fascinating to discover mathematical structures and phenomena in nature

Man, your work is beautiful.

Apenas a los 6 minutos de vídeo me empeze a dar cuenta que no entiendo ni madres porque está en inglés

(I haven't watched the video to the end yet, and I should add that english isn't my language and that I have dyscalculia; Still I'm enormously fascinated by patterns! And I heard of Fibonacchi numbers and golden cut and golden angles and the nature artworkpatterns of Daysies, Sunflowers, Pinecones and at 4:03 your pattern beginns to look exactly like those! I was soo excitet ! I have tried to recreate such a spiral with a similar drawing like your polar coordinates radius circles and lines grid thingy and wondered why this pattern had anything to doo with numers ?? (1+1=2, 2+1=3, 3+2=5, 5+3=8, 8+5=13) BUT AT LAST I get to see the reason. Pictures say so much more than words (or numbers). MERCI BEAUCOUP to you !

Because primes exist at the gaps between multiples.

Thats why I have observed primes is a good tool for creating (musical) rythms ;)

Learning every day.Thank's!

PRIME number is the foundation of CREATION. The human MIND is constructed by Prime Number Matrix Grid. It is an unconscious KNOWING that NEW Ager refer ALL that is the PRIME CREATOR - INDEED. Currently we are at the 6th Prime, 13D and heading to the 7th Prime, 17D. Or it could be we already pass the 8th Prime 19D and heading to the 23D, 9th Prime in MIND. After that the path go backwards to the 7th PRIME and a heaven on earth will reflect on the OUTSIDE. IT is how TIME ( consciousness) moves.

Beautiful. It is interesting that number 6, 44 etc play a pivotal role. In polar plot of Natural numbers, 6 is close to 2pi with a bit of residue and hence the 6 streaks. And 6x + 1, 6x - 1 series are prime numbers and hence only 2 streaks of the 6 are prime.

@ 0:04 I immediately clicked out of the video.

1:03 why does the radius expand even tho it should stay at 3? puts the whole vid ad absurdum.

If it look like spiral, it is available transfer to sine wave ?

2:14 Jojo fans: hey, I know that guy!

One thing I learned from having a super-smart boss try to teach me algebraic topology is that these patterns are failry arbitrary and largely a product of how we choose to map / graph the data.

You inspire me sir!

4:08 my disappointment is immeasurable and my day is ruined. Why would you start it like that?

What if pi was a different value? Would this change anything? I have a way to calculate Pi with accuracy from the left to the right. I haven't gone more that 9 decimals deep but my understanding of what the value is, is: 3.141578444 Phi is: 1.617836463 I can go further but it takes a lot of space to write it out, if anyone could help me with writing a spreadsheet it could be done with a computer rather quickly...

Is there a way NOT to get spirals?

Why is 25 on the chart of primes?

Encause we are magnetically drawn to the core of Gods heart, three kingdoms pi and golden ratio are the order we left the order we go back joined is spiral infinity

This makes me like math for once..

rocky or bullwinkle?

This man is jesus

I dont have any interest in Math and I dont fully understand this, but its so Entertaining to watch, Thank you!

A "totient" function, here written between totation marks, is not a totidian problem.

The word beautiful cant even describe how beautiful that shit is. This video made me feel like im high.

The zero is actually creating primes ! Diabolic decimal system :)

The existence and value of primes is competely independent from the way you write numbers.

they dont

Awesome explanation 👍🏼❤️

Any chance you can do me a huge favor? I need a visualization of a base 3 number system prime number spiral. Show me prime numbers in a projection, using a base 3 system. =)

The base you write them in doesn't change how it looks. That's because you draw them, not write them.

I have two questions... I wrote small program to find cases when the result of the next step is closer to a integer number of full turns than ever before.That's what I've got. 1 radian is about 0 full turns, the difference is 1.0 6 radians is about 1 full turn, the difference is -0.28318530717958623 19 radians is about 3 full turns, the difference is 0.1504440784612413 25 radians is about 4 full turns, the difference is -0.13274122871834493 44 radians is about 7 full turns, the difference is 0.017702849742896376 333 radians is about 53 full turns, the difference is -0.008821280518098717 710 radians is about 113 full turns, the difference is 6.028870677710074E-5 103993 radians is about 16551 full turns, the difference is -1.912933227998792E-5 312689 radians is about 49766 full turns, the difference is 2.9007205739617348E-6 1980127 radians is about 315147 full turns, the difference is -1.725052491963197E-6 2292816 radians is about 364913 full turns, the difference is 1.1757947504520416E-6 4272943 radians is about 680060 full turns, the difference is -5.497234027984632E-7 Well, I got 1, 6, 44 and even 710, the numbers of steps which about you spoke But 19-, 25- and 333-groups of spirals just become lost among the others. T hat's why I have those two questions. 1) Which spirals would we see? 2) Is set of these numbers endless? P.S. I'm sorry for my English, I am Russian :) I would be grateful if you could check me :)))

Yes this sequence of numbers is endless, because you can get as close as you want to pi using rational numbers, but never reach it since it's irrational.

kudos to the animator of this video

We can draw use prime number, see my video

Phenomenal. Perfect. Pleasantly presented.

The frequent grill rhetorically use because front strangely calculate above a abusive example. gigantic, grubby gruesome bridge

Man, they are here too?

Ah, damn, just had it thrown down my throat that I am thick as pig poo. I thought I was, sort of, moderately bright.... then got 5 minutes into this and just zoned. Jeez.

The calm adapter electrophysiologically support because season preclinically peep behind a utter cupcake. crowded, voracious drill

Hmm doesn't this mean you solved fermats last theorem?

So... If you zoom out even more, you will get new spirals everytime, and each time they will be less "spiraled", meaning you got a new rational approximation for π that is more accurate than the one before..? Right? *mindblow* EDIT: When zooming tends to infinity, you would spect to visualize perfectly straight lines that arise from the origin, as you got an infinite rational approximation to π

3Blue1Brown - it was necessary to write not "Why do prime numbers make these spirals? ", but the behavior of numbers in displacement or in a circle

I have never seen numbers this beautiful in my life that it made me tear up