# A story of the value in mathematical play

October 8, 2019 3:25 PM Subscribe

*How pretty but pointless patterns in polar plots of primes prompt pretty important pondering on properties of those primes [SLYT]*

posted by

posted by

**noneuclidean**(1 comment total)Polar plots?! Perchance with perimeter pi plus pi? Perish the possibility of such a post from one with such a pen name.

posted by J.K. Seazer at 3:54 PM on October 8 [5 favorites]

I'm never surprised when one of his videos is good, but this video was good! I went in feeling appropriately skeptical of the "some person on a forum discovers mysterious systemic property of primes" but was still a little bit wowed by the spiral counts and spacing on that polar chart, so the unpacking of it in the video was very satisfying.

My one wish is that it had shown some alternate renderings for values other than 2*pi radians as the arc length of a full turn, to illustrate further the way the particular emergent visual groups of phi(6) and phi(44) and phi(710) spirals depended on that value and the coincidence of approximations of pi. The absolute plainness of a rendering for a full turn being exactly 6, the different phi(n) groupings that would emerge for various other irrational values, etc.

Also I think implied by the explanation here is that if you zoomed out even farther, the curvature of the phi(710) spirals would eventually become pronounced enough that a new set of striations at phi(x) for some larger x approximating a multiple of 2*pi/r would assert itself in a new set of initially gentle spirals.

posted by cortex at 4:03 PM on October 8 [7 favorites]

My one wish is that it had shown some alternate renderings for values other than 2*pi radians as the arc length of a full turn, to illustrate further the way the particular emergent visual groups of phi(6) and phi(44) and phi(710) spirals depended on that value and the coincidence of approximations of pi. The absolute plainness of a rendering for a full turn being exactly 6, the different phi(n) groupings that would emerge for various other irrational values, etc.

Also I think implied by the explanation here is that if you zoomed out even farther, the curvature of the phi(710) spirals would eventually become pronounced enough that a new set of striations at phi(x) for some larger x approximating a multiple of 2*pi/r would assert itself in a new set of initially gentle spirals.

posted by cortex at 4:03 PM on October 8 [7 favorites]

Yep, I do believe so. The next approximation of pi is 103993/33102 (

posted by noneuclidean at 4:36 PM on October 8 [3 favorites]

*see OEIS sequences A002485 and A002486*), so there would be phi(2*103993)=103993 spirals (103993 is prime).posted by noneuclidean at 4:36 PM on October 8 [3 favorites]

I don't do enough pi mucking to know, but I wonder if other reasonably good approximations of pi, if not actually better in strict terms than 355/113, would manifest before it got that far, just by virtue of the curvature of the phi(710) spirals getting pronounced enough to functionally become noise.

posted by cortex at 4:49 PM on October 8 [1 favorite]

posted by cortex at 4:49 PM on October 8 [1 favorite]

Penny Pingleton is permanently and positively punished!

posted by battleshipkropotkin at 4:52 PM on October 8 [2 favorites]

posted by battleshipkropotkin at 4:52 PM on October 8 [2 favorites]

Somehow I knew this was a link to 3Blue1Brown. I love that channel.

posted by daq at 4:55 PM on October 8 [1 favorite]

posted by daq at 4:55 PM on October 8 [1 favorite]

>

I had the same thought, cortex. There really are good reasons that 2 pi is used as a standard for angle around a circle in many situations, but I don’t they apply in this case. Any number could be used. I wonder specifically about what number would yield Fibonacci number counts of spirals. 1.618033989, perhaps?

posted by bitslayer at 5:01 PM on October 8 [1 favorite]

*Alternate renderings for values other than 2*pi radians*...I had the same thought, cortex. There really are good reasons that 2 pi is used as a standard for angle around a circle in many situations, but I don’t they apply in this case. Any number could be used. I wonder specifically about what number would yield Fibonacci number counts of spirals. 1.618033989, perhaps?

posted by bitslayer at 5:01 PM on October 8 [1 favorite]

Yeah, I'd choose Φ 1.618033988749895 - Infinite fractions and the most irrational number. You'd have to get to really bignum before you started hitting the approximations that are close enough to full rotations to appear to create spirals... I think...

posted by zengargoyle at 6:31 PM on October 8 [1 favorite]

posted by zengargoyle at 6:31 PM on October 8 [1 favorite]

Funny, I've been amateurishly fooling around with primes lately too. Maybe some person who went further in math than I did can trivialize this:

So you take the prime factorization of some positive integer, then take the sum of the squares of the exponents in the prime factorization. This could in some high-dimensional way be taken as an analogue of the "distance" of the integer from 1. Cool, I found that other people have had this idea of using primes as basis vectors. Concretely, 5 (prime) would be one (square) unit from 1, 6 would be 2

Anyway. Thought I'd leave this here and maybe I won't waste work hours tweaking my script anymore.

posted by Tad Naff at 8:01 PM on October 8 [2 favorites]

So you take the prime factorization of some positive integer, then take the sum of the squares of the exponents in the prime factorization. This could in some high-dimensional way be taken as an analogue of the "distance" of the integer from 1. Cool, I found that other people have had this idea of using primes as basis vectors. Concretely, 5 (prime) would be one (square) unit from 1, 6 would be 2

^{1}×3^{1}so 1^{2}+1^{2}=2 units from 1, 24 (2^{3}×3^{1}) would be 3^{2}+1^{2}=9 units from 1, etc. I thought maybe something would pop out from playing with finding the "distance" between various numbers, but nothing so far. So I tried something else: I wrote a little script to generate the "distances" for all the integers (yes, all, it's probably up to around 4 million now), then I plotted how many have a distance of 1, 2, etc. from 1. Yes, if I had*all*of the integers then it would just be a solid block, but taking the integers up to some largeish N there's a pattern like an exponentially decaying wave, with maxima*near*every distance=n^{2}+2 (as the distance increases, the maximum seems to get a little bit smaller, so it might be at 226 instead of the "expected" 227. And there are some distances that are really unpopular, you have to go pretty far before you find one that has a distance of e.g. 48.Anyway. Thought I'd leave this here and maybe I won't waste work hours tweaking my script anymore.

posted by Tad Naff at 8:01 PM on October 8 [2 favorites]

I love love love animated data visualization’s ability to convey mathematical concepts without freaking people out.

posted by mantecol at 10:03 PM on October 8

posted by mantecol at 10:03 PM on October 8

*Yeah, I'd choose Φ 1.618033988749895*

I had the exact same thought! I started playing with it using Octave and it gives some really lovely patterns.

Here are a few.

I decided to tweak things a bit so they're not true Archimedean spirals any more; instead, I'm plotting (R, Θ) = (sqrt(p), f(p)). Using the square root basically density-normalizes things so that the small numbers don't get super clumped up near zero (because the area of a circle is proportionate to the square of its circumference) while only squishing the spiral arms in a relatively clean way.

For the 3Blue1Brown video, f(p)=p. I replicated that as a comparison with the square root squishing.

My first thought was to try traversing Φ rotations per integer step, instead of π radians, and I actually like that one the best. Here f(p) = 2πΦp. Without thinking about it too much, I kind of thought this would eliminate the spiral arm structure caused by structure of the integers themselves, and maybe there wouldn't be any spirals left. But actually there are still really lovely spirals in the primes! I'm not sure but I think this might be related to the patterns you see in the Ulam spiral.

Then I decided to try Φ radians per integer step, f(p) = Φp. I think this one looks really lovely as well, and in a purely visual sense is maybe the most pleasing to me. But in some sense I feel like π is still lurking here explaining some of the pattern, whereas the previous one where π is explicitly accounted for is sort of more "purely" about Φ.

Octave/Matlab code in case anyone else wants to play:

N = 10000;

phi = (1+sqrt(5))/2;

x = 1:N;

isp = isprime(x);

rad = @(y)sqrt(y);

theta = 2*pi*x*phi;

polar(theta, rad(x), 'y.');

hold all;

polar(theta(isp), rad(x(isp)), 'r.');

posted by biogeo at 11:13 PM on October 8 [3 favorites]

On a little more thinking, I think I've got a better explanation for what happens when you use an angular step rate of Φ rotations per integer. If you look at all the integers, you see no tendency to get spirals because Φ has no good fractional approximations, just as

Very fun.

posted by biogeo at 11:35 PM on October 8 [3 favorites]

**zengargoyle**alluded to: it is the "most irrational" number. But if you were to take steps of 2Φ, or 3Φ, or 5Φ... these are necessarily somewhat "less irrational" and will have fractional approximations that will produce regular spiral patterns. So when you look at the prime numbers, you end up excluding these numbers... which means that you get spiral patterns again!Very fun.

posted by biogeo at 11:35 PM on October 8 [3 favorites]

Sweet! biogeo. I wasn't thinking of changing the Θ from 1 to Φ but changing the space such that the circle was Φ (or 2Φ) radians instead of 2π radians. If the circle is rational the modulos will eventually be rays once you get past the really small primes. Maybe if you changed π to Φ and keep the (p,p). Seems like finding a pattern in the primes in the space of the most irrational number that isn't our pattern matching brain would be interesting.

posted by zengargoyle at 1:13 AM on October 9

posted by zengargoyle at 1:13 AM on October 9

I came for the alliteration, I stayed for the pretty picture, I'm sharing for the mathematics.

The phenomenon of thinking about an idea in your own head and realizing that you've uncovered a truth about arithmetic or logic that will be true in the head of every other human --- it's an amazing feeling, even if you've never been so fortunate as to be the

posted by fantabulous timewaster at 12:30 PM on October 9

The phenomenon of thinking about an idea in your own head and realizing that you've uncovered a truth about arithmetic or logic that will be true in the head of every other human --- it's an amazing feeling, even if you've never been so fortunate as to be the

*first*person to uncover such a fact. This video does a great job of explaining what that feeling is like.posted by fantabulous timewaster at 12:30 PM on October 9

*Sweet! biogeo. I wasn't thinking of changing the Θ from 1 to Φ but changing the space such that the circle was Φ (or 2Φ) radians instead of 2π radians*

If you change the circle so as to pretend that it subtends phi radian-like-things, then the angle between each consecutive integer is 1/phi turns.

If you take the biogeo approach and set the angle between consecutive integers to be phi turns, then since phi is greater than 1, you can subtract 1 turn and not change the angle- it will still point in the same direction.

But a peculiar property of phi is that phi-1 = 1/phi. So the two approaches are the same.

posted by Jpfed at 1:17 PM on October 9 [3 favorites]

Yeah Jpfed, I'd pretty much convinced myself that the two were the same, but it was bedtime. I blame cortex

posted by zengargoyle at 1:57 PM on October 9

My one wish is that it had shown some alternate renderings for values other than 2*pi radians as the arc length of a full turn, to illustrate further the way the particular emergent visual groups of phi(6) and phi(44) and phi(710) spirals depended on that value and the coincidence of approximations of pi. The absolute plainness of a rendering for a full turn being exactly 6, the different phi(n) groupings that would emerge for various other irrational values, etc.for wanting to come at it from let's make the circle Φ instead of 2π (τ).

posted by zengargoyle at 1:57 PM on October 9

*Yeah, I'd choose Φ 1.618033988749895 - Infinite fractions and the most irrational number yt .*

Hmm, the problem is that every irrational number is approximated nicely by a series of rational numbers. (Rationals are everywhere dense within the irrationals.) So it's hard to say how much difference it will make.

I am dumb so I plotted it with gnuplot. Here you can see the normal 2pi polar plot vs the phi plot, for the first million primes.

I have to say I was quite surprised how much more uniform the phi version looks at first glance than the 2pi version, which has super-obvious spirals.

If you view the phi plot on, say, a small cell phone screen it will probably look completely uniform. But when you zoom in a little more the spirals become quite obvious.

posted by flug at 1:52 AM on October 10 [1 favorite]

Noting that phi is approximated by fractions 1, 1/2, 3/2, 5/3, 8/5, 13/8, 21/13, etc I wondered what our polar prime graph would look like under these successive approximations of phi.

I am dumb, so I made some animated graphs of this with gnuplot.

Each shows the first 1 million primes polar-graphed under each of those successive fractions--ie, the primes divided by 1, then 1/2, then 3/2, then 5/3, etc per full revolution.

One animated graph is zoomed all the way out to see all 1 million primes and the other is zoomed in to the center by a factor of about 10.

The first 20 approximations are shown for the zoomed-in version--after that no further change can be be discerned. For the zoomed-out version, the first 42 approximations are shown--again, the graph does not noticeably change after that.

What is remarkable about them is that the first several steps show straight lines emanating from the center point--just what you expect for rational numbers. But after a certain point (roughly the 15th step) the straight lines merge together visually and then arcs become the most prominent feature--similar to, though more subtle than, the arcs in the 2*pi version of the polar prime graph.

posted by flug at 4:33 AM on October 10 [1 favorite]

I am dumb, so I made some animated graphs of this with gnuplot.

Each shows the first 1 million primes polar-graphed under each of those successive fractions--ie, the primes divided by 1, then 1/2, then 3/2, then 5/3, etc per full revolution.

One animated graph is zoomed all the way out to see all 1 million primes and the other is zoomed in to the center by a factor of about 10.

The first 20 approximations are shown for the zoomed-in version--after that no further change can be be discerned. For the zoomed-out version, the first 42 approximations are shown--again, the graph does not noticeably change after that.

What is remarkable about them is that the first several steps show straight lines emanating from the center point--just what you expect for rational numbers. But after a certain point (roughly the 15th step) the straight lines merge together visually and then arcs become the most prominent feature--similar to, though more subtle than, the arcs in the 2*pi version of the polar prime graph.

posted by flug at 4:33 AM on October 10 [1 favorite]

By the way, this reminds me a lot of the "period-doubling path to chaos" that you find with the famous logistic map.

It's obviously quite different a lot of the particulars, but the idea that you start with with nice, well-behaved, rational splits, they split again a few times, but then at a certain point it's like all hell breaks loose and you just have chaos. But within that chaos there is a lot of the original order you started with.

For the logistic map (and, interestingly,

posted by flug at 5:04 AM on October 10

It's obviously quite different a lot of the particulars, but the idea that you start with with nice, well-behaved, rational splits, they split again a few times, but then at a certain point it's like all hell breaks loose and you just have chaos. But within that chaos there is a lot of the original order you started with.

For the logistic map (and, interestingly,

*all*other similar equations) the Feigenbaum Constants tell you exactly where that chaotic region is going to start and behave.posted by flug at 5:04 AM on October 10

**flug**, those are lovely! You might enjoy this video from Numberphile that goes into much more on the origin of spiral arms when plotting positive integers in this way, and why phi doesn't really produce spiral arms. Also relevant are this video from Mathologer discussing why phi is the "most irrational" number, and another video from Numberphile on orchard problems and another implication of phi being poorly approximated by rational numbers.

In the interest of visualizing how different integer multiples of phi produce different spiral arms, I made a few more plots showing the greatest and least prime factors of every natural number up to 10000, plotted on these square root spirals.

posted by biogeo at 9:23 AM on October 10 [2 favorites]

Sorta related for graphing sequence nerdery....

Numberphile recently did this series on graphs of Integer Sequences: Amazing Graphs on Numberphile

And then a podcast with the creator:

posted by zengargoyle at 1:09 PM on October 11 [1 favorite]

Numberphile recently did this series on graphs of Integer Sequences: Amazing Graphs on Numberphile

And then a podcast with the creator:

We speak with Neil Sloane - creator and keeper of the famed ‘On-line Encyclopedia of Integer Sequences’.The Number Collector (with Neil Sloane) - Numberphile Podcast

posted by zengargoyle at 1:09 PM on October 11 [1 favorite]

I had to share another set of images because I think they're really pretty. I switched from plotting with Octave to using Python+Matplotlib as an exercise for myself, and I think the results are much prettier.

posted by biogeo at 7:26 PM on October 11 [1 favorite]

posted by biogeo at 7:26 PM on October 11 [1 favorite]

« Older 129 tsp of pepper OR 2 cherry pits OR 85... | The biggest lie tech people tell themselves — and... Newer »

posted by adzm at 3:39 PM on October 8 [3 favorites]