Get AI summaries of any video or article — Sign up free
Why do prime numbers make these spirals? | Dirichlet’s theorem and pi approximations thumbnail

Why do prime numbers make these spirals? | Dirichlet’s theorem and pi approximations

3Blue1Brown·
5 min read

Based on 3Blue1Brown's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.

TL;DR

Plotting (p, p) in polar coordinates turns arithmetic progressions into geometric spiral arms because adding k to p rotates by k radians and increases radius by k.

Briefing

Plotting points (p, p) in polar coordinates—using radius r = p and angle θ = p radians—creates outward Archimedean spirals. When all integers are included, the spirals look clean. Filtering down to primes makes the picture look chaotic at first, then reveals a structured “Milky Way” of spiral arms and missing sections. The central insight is that the gaps and surviving arms come from basic divisibility constraints on primes, while the long-run balance of primes across the remaining arms is governed by Dirichlet’s theorem.

The construction turns each step of +1 in p into a rotation by 1 radian while also increasing the radius by 1. Because 6 radians is close to 2π, counting by 6 produces points whose angles nearly complete a full turn each time; visually, that near-commensurability separates the integers into six spiral arms. More precisely, the arm corresponds to a residue class modulo 6: numbers that leave the same remainder when divided by 6. When primes are selected, most arms vanish. A prime cannot be a multiple of 6, cannot be 2 more than a multiple of 6 (those are even), and cannot be 3 more than a multiple of 6 (those are divisible by 3). Only the residue classes compatible with primality remain, aside from the small exceptions 2 and 3.

Zooming out changes the scale. Now the relevant near-rotation is 44 radians, which is close to 7 full turns because 44/(2π) is just above 7. This yields 44 residue classes modulo 44, each forming its own spiral arm. Primes eliminate entire arms whenever the corresponding residue class forces a composite structure—e.g., residues that make numbers even or divisible by 11. What survives are exactly the residue classes that are coprime to 44 (share no prime factors with 44). Counting those coprime residues gives Euler’s totient function: φ(44) = 20. The picture’s “missing teeth” and the number of visible arms trace directly to this totient count.

The same mechanism repeats at an even larger scale using a striking rational approximation: 710 radians is extremely close to an integer multiple of 2π. That approximation is tied to the famous fraction 355/113 for π, since 355/113 ≈ π. Because 710 is built from prime factors 2, 5, and 71, residue classes modulo 710 that are divisible by any of these factors cannot contain primes (except for the factor itself). Visually, this produces alternating rays, occasional gaps, and clumps whose structure reflects which residue classes are ruled out by divisibility.

The most consequential part is not the geometry but the distribution. Within the residue classes that remain possible—those coprime to the modulus—primes appear to spread evenly. Dirichlet’s theorem makes that expectation precise: for any modulus n and any residue r that is coprime to n, the primes congruent to r (mod n) have asymptotic density 1/φ(n). In other words, every admissible residue class gets infinitely many primes, and in the long run they occupy an equal share among the φ(n) allowed classes. The proof’s machinery leans on analytic number theory, including complex analysis, and the theorem underpins modern work on prime gaps and related conjectures.

Cornell Notes

Plotting points (p, p) with angle θ = p radians turns arithmetic structure into geometry: near-integer multiples of 2π create visible spiral arms. Modulo 6, the near-commensurability of 6 radians with 2π splits integers into six residue-class arms; most disappear for primes because many residues force evenness or divisibility by 3. Modulo 44, the near-commensurability of 44 radians with 7 turns creates 44 arms, but primes only survive in residue classes coprime to 44, counted by φ(44)=20. At the larger scale, the exceptional approximation 355/113 ≈ π (equivalently, 710 radians ≈ integer·2π) explains why rays look straight for a long distance. Dirichlet’s theorem then guarantees that primes are not just present but asymptotically evenly distributed across all admissible residue classes, each with density 1/φ(n).

Why do spiral arms appear at all when plotting (p, p) in polar coordinates?

Each increment in p increases the radius by 1 and rotates by 1 radian. When the step size k makes k radians close to a whole number of turns (multiples of 2π), points with the same remainder mod k land at nearly the same angles each cycle, tracing separate spiral arms. That’s why k=6 produces six arms: 6 radians is just under 2π, so adding 6 to p nearly completes a turn each time. The same logic later uses k=44 and k=710.

How does filtering to primes remove specific spiral arms modulo 6?

Residue classes mod 6 correspond to numbers of the form 6m + r. A prime cannot be divisible by 2 or 3. So the arms for r=0 (multiples of 6), r=2 (even numbers), and r=3 (multiples of 3) vanish, leaving only residue classes compatible with primality—plus the special cases 2 and 3 themselves. The “missing arms” are therefore direct consequences of divisibility, not a mysterious property of primes.

What changes at the larger scale with modulus 44, and why does φ(44)=20 matter?

Because 44 radians is close to 7 full turns, the plot separates into residue classes mod 44, each forming an arm. Primes cannot lie in residue classes that force a factor shared with 44. Since 44 = 2^2·11, any residue class that makes numbers even or divisible by 11 contains no primes (except the modulus factors themselves, which are too small to affect the large-scale arms). The count of residue classes coprime to 44 is φ(44)=20, matching the number of admissible arms that can actually contain primes.

How does the approximation 355/113 ≈ π connect to the geometry at modulus 710?

The plot uses angle increments of 710 radians. Since 2π radians per full rotation, the number of rotations is 710/(2π). The transcript notes this is extremely close to 113, meaning 710 radians ≈ 113·2π. That corresponds to the well-known rational approximation 355/113 ≈ π (because 2π·113 ≈ 710 implies π ≈ 355/113). When each step adds almost the same tiny angular excess, a residue class mod 710 looks nearly like a straight line for a long distance.

What does Dirichlet’s theorem add beyond the divisibility-based gaps?

Divisibility explains which residue classes are impossible for primes. Dirichlet’s theorem addresses the remaining ones: for any modulus n and any residue r coprime to n, primes congruent to r (mod n) occur infinitely often and have asymptotic density 1/φ(n). So the primes don’t just show up sporadically; they spread evenly among the φ(n) admissible residue classes, matching the “even distribution” suggested by the histograms.

Review Questions

  1. In the polar plot, what role does the near-relationship between k radians and multiples of 2π play in producing spiral arms?
  2. For a modulus n, which residue classes are guaranteed to contain no primes (except possible small exceptions), and how is that determined using gcd(r, n)?
  3. State the key density conclusion of Dirichlet’s theorem in terms of φ(n) and residue classes coprime to n.

Key Points

  1. 1

    Plotting (p, p) in polar coordinates turns arithmetic progressions into geometric spiral arms because adding k to p rotates by k radians and increases radius by k.

  2. 2

    Spiral arms correspond to residue classes modulo k; near-commensurability (k ≈ integer·2π) makes each residue class trace a distinct curve.

  3. 3

    Most spiral arms disappear for primes because many residue classes force divisibility by small primes (e.g., mod 6 eliminates multiples of 2 and 3).

  4. 4

    At modulus 44, the surviving arms are exactly those residue classes coprime to 44, and their count is φ(44)=20.

  5. 5

    At modulus 710, the exceptional rational approximation 355/113 ≈ π explains why rays look nearly straight for a long distance.

  6. 6

    Dirichlet’s theorem guarantees that primes are asymptotically evenly distributed across all residue classes coprime to n, with density 1/φ(n).

Highlights

The “missing spiral arms” are not mystical: they come from residue classes that force primes to be divisible by 2, 3, 11, or other factors of the modulus.
φ(44)=20 isn’t just a number-theory fact—it matches the count of residue-class arms that primes can actually occupy when working mod 44.
The near-straight rays at large scale trace back to the exceptional approximation 355/113 ≈ π, expressed geometrically as 710 radians ≈ 113·2π.
Dirichlet’s theorem turns the visual intuition of “even spread among allowed arms” into a precise asymptotic density statement: 1/φ(n) per admissible residue class.

Topics

  • Prime Spirals
  • Residue Classes
  • Euler Totient
  • Rational Approximations
  • Dirichlet’s Theorem

Mentioned

  • Greg Martin
  • Dirichlet
  • Euclid
  • φ
  • mod