# 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.

nlworld.info/key/video/pJmSpcfJm4GVgJ4

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

nlworld.info/key/video/yn6mhJ6akJqEgoQ

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 NLworld, 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

But Pi is an inexact number. So much for the mathematical perfection of the universe...

What do you even mean by "inexact number" ?

Would also like to see the points plotted in cylindrical coords like (2,2,2), (3,3,3),(5,5,5) etc. Those spirals would curl up like smoke from a fire.

I was just learning about LRAM in my calculus class, and it came up when he mentioned using calculus with functions using complex numbers.

This is the best way I've heard this described

I do not know where to ask this question. I noticed a peculiar mathematical phenomenon, while looking at the calculation of 662314 days with different length years (don't ask). The math is 662314/359 = 1,844.8857938718662952646239554318, which is 1844 and 318 days. That is, 0.8857938718662952646239554318 x 359 = 318 days. Further, 0.8857938718662952646239554318 x 360, instead of 359, is 318.88579387186629526462395543175. The exact same decimal. The difference at the end is simply due to the places my calculator can produce. That is, we can do this into infinity. I noticed that the result is due to the relationship between 359 and 360, or any odd number and that number plus 1. For instance, if we take 663840 days, which is 1844 x 360, and divide it by 359, we get 1,849.1364902506963788300835654596, which is 1849 years and 49 days. The remainder of 0.1364902506963788300835654596 x 360 is 49.136490250696378830083565456.This means it is not the large number we start with that creates this phenomenon. If we take 662314 and divide it by three, we get 220,771.33333333333333333333333333. The remainder multiplied by 3 results in 1. If it is multiplied by 4, it results in 1.3333333333333333333333 I do not know what this rule is, since without a name for it, it is very difficult to look up on Google.

I'd like to see the pattern in primes if there were any. But there are none except all prime waves cross at zero. Light waves of different lengths, all starting at zero and going off into infinity is the way to think of prime numbers. I call them prime waves. They go both directions from zero, positive and negative. So for example the number 3. It would generate a prime wave that crosses the number line at zero, then 3, then 6, then 9 and so forth out into infinity. The thing about primes is you have to travel the wave until it crosses off all of the numbers in it's path as it crosses the number line. Each new prime number starting a new prime wave and all of the prime waves combined traveling out from zero until they don't cross out a number on the number line. And this new prime becoming a new prime wave traveling out with the other prime waves at the speed of light crossing out all of the multiples of the existing prime numbers until the next prime number is found. Our speed is the speed of light. Thus you could calculate how far the prime waves traveling at the speed of light would travel in a year. And thus how many new primes can theoretically be found per year using the speed of light as the basis for calculation.

I might add that the distance between numbers can be any size. So it would be the speed of our fastest computer that determines the speed of our lightwaves.

The Eratostene's filter leaving empty field like the galaxies arms

Yeah I don't see any new revelations here about pi or primes. When I was a kid in school pi was this mysterious number that was used to calculate circles. Yet it is so easy to make pi something that even a small child can grasp. If you calculate the circumference of a square, lets say each side is 1, then to go around that square is 4. Now set a circle in that square and the circumference is 3.14 or pi. So the ratio is 4 to 3.14 The ratio of the circumference of a square to a circle's circumference that fits inside that square. And really that ratio is not really just 4 to 3.14. It is also the ratio of one side of the square or 1 to one side of the circle, or 1/4th of the circle or .785. So 1 to .785, that is the exact same ratio as pi.

You were doing an excelled job of explaining until you got the the primes but I see it now. The primes are doubled also. So the prime number 3 would be (3, 3). 5 would be (5, 5) and so on.

🥱😴

I usually hear this called aliasing.

Am I the only one who saw Veritasium in the Patreon list?

like your videos, thk!

Well no shit!

The panoramic low indirectly rub because psychiatrist microbiologically identify for a acceptable side. free, flashy slime

This is the dumbest thing i've ever seen.... Seriously ppl..... The first thing they do is write the numbers in a spiral pattern then afterwards marvel at the fact that if you remove some numbers it still looks like a spiral.

I like your simplicity of a solution.

Are there primes in all different number bases?

Primes are independent of the base or whatever system you use to write them with.

So, if someone plans to animate hyperspace, they can just take prime numbers!

Beautiful 👍

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.

Take a cold shower

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?