1. Home
  2. Explore
  3. Mathematics
  4. Prime Numbers and Pi

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Prime Numbers and Pi

Prime Spirals, Rational Approximations of π, and Dirichlet's Theorem

Polar Coordinates and the Prime Spiral Plot

In polar coordinates, points in the plane are described by a distance (radius) r from the origin and an angle θ (theta) measured from the positive horizontal axis. The angle is given in radians, where 2π2\pi2π radians corresponds to one full circle. Adding 2π2\pi2π to the angle does not change the point's location, making polar coordinates non‑unique.

A curious exploratory plot takes each positive integer n and places a point at coordinates (n,n)(n, n)(n,n) — that is, a point at distance n from the origin with an angle of n radians. This process creates an Archimedean spiral: as n increases, the radius grows linearly and the angle rotates by one radian per step, causing the points to coil outward.

When only primes are plotted, the pattern initially appears random. However, zooming out reveals striking structures:

  • At intermediate scales, galactic‑like spiral arms appear, with some arms missing.

  • At larger scales, the spirals give way to straight rays that come in clumps of four, with occasional gaps.

These patterns are not caused by the primes themselves. The same spirals appear for all whole numbers (just cleaner), so the spiral structure is a geometric artifact of using integer radian steps. The puzzle splits into two independent questions:

  1. Why do spirals (and later rays) form at specific scales, and what determines their number?

  2. When only primes are shown, why do only certain arms/rays remain?

The Spirals: Rational Approximations of 2π2\pi2π

Residue Classes and Spiral Arms

Each step forward increases the angle by 1 radian. After k steps, the total angle is k radians. If k is close to an integer multiple of 2π2\pi2π, then the angle of the n-th point and the angle of the (n+k)(n+k)(n+k)-th point are almost the same. Consequently, the points with indices belonging to the same residue class modulo k (i.e., all numbers with a given remainder when divided by k) lie on a gently curving spiral.

A residue class mod m is the set of integers that leave a specific remainder when divided by m. For example, numbers that are 2 more than a multiple of 6 form the residue class 2 mod 6. This terminology (also called congruence class) is standard in number theory.

Scale 1: Six Radians (Near 2π2\pi2π)

Six radians is just slightly less than 2π2\pi2π (since 2π≈6.2832\pi \approx 6.2832π≈6.283). After 6 steps, the angle is 6−2π≈−0.2836 - 2\pi \approx -0.2836−2π≈−0.283 radians relative to a full turn, i.e., a small clockwise offset. Each subsequent group of 6 steps adds another small offset, producing a gentle spiral.

  • There are 6 spiral arms, one for each residue class mod 6.

  • The arm for residues 0 mod 6 contains all multiples of 6.

  • Subsequent arms correspond to residues 1, 2, 3, 4, 5 mod 6.

Scale 2: Forty‑Four Radians (≈ 7×2π2\pi2π)

Computing the number of full turns in 44 radians:

442π≈7.0000…\frac{44}{2\pi} \approx 7.0000\ldots2π44​≈7.0000…

More precisely, 44/744/744/7 is a well‑known rational approximation for 2π2\pi2π (since π≈22/7\pi \approx 22/7π≈22/7, so 2π≈44/72\pi \approx 44/72π≈44/7). Taking 44 steps is almost exactly 7 full turns, with a tiny under‑rotation. This brings the angle of points separated by 44 indices very nearly into alignment, forming distinct spirals.

  • There are 44 spiral arms, one per residue class mod 44.

  • The arms again correspond to the 44 possible remainders 0, 1, 2, …, 43.

Scale 3: 710 Radians (≈ 113×2π2\pi2π)

The approximation 355/113355/113355/113 for π\piπ yields 2π≈710/1132\pi \approx 710/1132π≈710/113. Indeed,

7102π≈113.000095,\frac{710}{2\pi} \approx 113.000095,2π710​≈113.000095,

so 710 radians is an extremely close approximation to 113 full turns. This rational approximation is unusually good compared to approximating other irrationals like eee or 2\sqrt{2}2​. As a result, points spaced by 710 indices have nearly identical angles, and the corresponding residue classes produce straight rays (at first glance) rather than spirals.

  • There are 710 residue classes mod 710, but due to the density of points, many rays overlap.

  • The near‑perfect alignment means that the spiraling is so gentle that it is imperceptible over a long range.

Filtering for Primes: Euler's Totient Function

When the plot is restricted to prime numbers, many entire residue classes disappear because they consist entirely of composite numbers (or contain only a single prime).

Example: Residue Classes mod 6

Among the six residue classes mod 6, only two can contain primes (other than the primes 2 and 3 themselves):

  • 0 mod 6: all multiples of 6 — no primes (except possible 2? but 2 is 2 mod 6, 3 is 3 mod 6).

  • 2 mod 6: even numbers > 2 — no primes.

  • 3 mod 6: multiples of 3 > 3 — no primes.

  • 4 mod 6: even numbers — no primes.

  • 1 mod 6: can contain primes.

  • 5 mod 6: can contain primes. Thus only two spiral arms survive. (The primes 2 and 3 are special and lie in arms that otherwise hold no primes.)

Example: Residue Classes mod 44

The modulus 44 = 22×112^2 \times 1122×11. A residue class r mod 44 can contain infinitely many primes only if r is co‑prime (or relatively prime) to 44 — that is, gcd⁡(r,44)=1\gcd(r,44)=1gcd(r,44)=1. If r shares any prime factor (2 or 11) with 44, then every number in that residue class is divisible by that factor (and hence composite, except possibly the case r=r =r= the factor itself for the single prime equal to that factor).

  • Even residues (0, 2, 4, …) are all even, so no primes.

  • Multiples of 11 (0, 11, 22, 33) are either 11 itself or composites (except 11 is prime, but 11 mod 44 is a single point).

  • The remaining residues that are odd and not divisible by 11 have the possibility of containing primes.

  • The number of such residues between 1 and 44 that are co‑prime to 44 is given by Euler's totient function ϕ(44)=20\phi(44) = 20ϕ(44)=20. Hence 20 spiral arms survive when plotting primes mod 44.

Example: Residue Classes mod 710

The modulus 710 = 2×5×712 \times 5 \times 712×5×71. The co‑prime residues are those not divisible by 2, 5, or 71. Their count is

ϕ(710)=710(1−12)(1−15)(1−171)=280.\phi(710) = 710 \left(1-\frac12\right)\left(1-\frac15\right)\left(1-\frac1{71}\right) = 280.ϕ(710)=710(1−21​)(1−51​)(1−711​)=280.

Thus, 280 out of the 710 residue classes can potentially contain primes; all others are ruled out by a small prime factor. This explains:

  • Why the rays at the largest scale appear in clumps of four (the surviving residues are grouped by modulo 5 and 71 patterns), and

  • Why occasional "missing teeth" occur (the four residues divisible by 71 among the co‑prime residues correspond to rays that will not contain primes).

Definition: Euler's totient function ϕ(n)\phi(n)ϕ(n) counts the integers kkk with 1≤k≤n1 \le k \le n1≤k≤n such that gcd⁡(k,n)=1\gcd(k,n)=1gcd(k,n)=1. These numbers are called the totitives of nnn.

Dirichlet's Theorem on Primes in Arithmetic Progressions

The empirical observation that primes appear evenly distributed among the allowable residue classes is not a coincidence — it is a profound result known as Dirichlet's theorem (proved by Dirichlet in 1837).

Statement (Informal)

Fix a modulus n and a residue r that is co‑prime to n (i.e., gcd⁡(r,n)=1\gcd(r,n)=1gcd(r,n)=1). Then the arithmetic progression r,r+n,r+2n,…r, r+n, r+2n, \ldotsr,r+n,r+2n,… contains infinitely many prime numbers. Moreover, as the bound xxx grows, the proportion of primes up to xxx that fall into each such residue class approaches 1/ϕ(n)1/\phi(n)1/ϕ(n).

Example: Last Digits of Primes (mod 10)

For n=10n=10n=10, the residues co‑prime to 10 are 1, 3, 7, 9 (since 2 and 5 divide 10). Thus:

  • Primes (other than 2 and 5) must end in 1, 3, 7, or 9.

  • Dirichlet's theorem guarantees infinitely many primes in each of these four classes, and the density of each class among all primes is 14=1ϕ(10)\frac14 = \frac{1}{\phi(10)}41​=ϕ(10)1​.

  • Histograms of primes confirm an even distribution as more primes are considered.

Formal Statement (with Notation)

Let π(x)\pi(x)π(x) denote the prime‑counting function (number of primes ≤ xxx). Let π(x;n,r)\pi(x; n, r)π(x;n,r) count primes ≤ xxx that are congruent to rrr modulo nnn. Then for any nnn and any rrr with gcd⁡(r,n)=1\gcd(r,n)=1gcd(r,n)=1,

lim⁡x→∞π(x;n,r)π(x)=1ϕ(n).\lim_{x\to\infty} \frac{\pi(x; n, r)}{\pi(x)} = \frac{1}{\phi(n)}.limx→∞​π(x)π(x;n,r)​=ϕ(n)1​.

Equivalently, π(x;n,r)∼1ϕ(n)xlog⁡x\pi(x; n, r) \sim \frac{1}{\phi(n)} \frac{x}{\log x}π(x;n,r)∼ϕ(n)1​logxx​ as x→∞x \to \inftyx→∞, by the Prime Number Theorem.

Significance and History

  • Dirichlet's theorem is a cornerstone of analytic number theory. Its proof introduced the use of Dirichlet characters and L‑functions, blending number theory with complex analysis.

  • The theorem shows that primes are not only infinite in total (Euclid) but also plentiful in every arithmetic progression where they could possibly exist (except possibly for one modulus where the progression contains a single prime equal to the modulus).

  • Modern research on small gaps between primes (e.g., work toward the twin prime conjecture) relies on deeper refinements of Dirichlet's ideas, particularly how primes distribute across residue classes.

The Deep Connection: Rational Approximations and the Totient Function

The visual exploration of (p,p)(p,p)(p,p) in polar coordinates ties together:

  • Rational approximations of π\piπ: the numbers 6, 44, 710 correspond to the denominators of increasingly accurate approximations of 2π2\pi2π (i.e., 6≈2π6 \approx 2\pi6≈2π, 44/7≈2π44/7 \approx 2\pi44/7≈2π, 710/113≈2π710/113 \approx 2\pi710/113≈2π). These approximations arise from the continued fraction expansion of π\piπ.

  • Euler's totient function: the number of surviving spirals/rays when plotting only primes equals ϕ(n)\phi(n)ϕ(n) for the relevant modulus nnn.

  • Dirichlet's theorem: the even distribution of primes among the co‑prime residue classes explains why the observed arms appear with roughly equal density.

Conclusion: The Value of Playful Exploration

Although plotting (p,p)(p,p)(p,p) in polar coordinates is arbitrary and the resulting patterns are artifacts of using radians (an unnatural unit for integer steps), the exploration naturally leads to deep and interconnected mathematical ideas. By reconstructing concepts like residue classes, Euler's totient, and Dirichlet's theorem through personal discovery, a student encounters these topics as meaningful structures rather than arbitrary definitions. Such playful engagement with data visualization can illuminate important branches of number theory and motivate further study of analytic methods.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent