Library · Geometric Probability · Chapter 52

Visible lattice points

Revised Report an error

Problem 52.1

Let NN be a large integer. Choose two integers m,nm, n independently and uniformly from {1,2,…,N}\{1, 2, \ldots, N\}. As N→∞N \to \infty, what is the probability that gcd⁡(m,n)=1\gcd(m, n) = 1?

Solution. Let PN=P(gcd⁡(m,n)=1)P_N = \mathbb{P}(\gcd(m,n) = 1) for the uniform distribution on {1,…,N}2\{1, \ldots, N\}^2. For each prime pp, let Ap={(m,n):p∣m and p∣n}A_p = \{(m,n) : p \mid m \text{ and } p \mid n\}. As N→∞N \to \infty, P(Ap)→1/p2\mathbb{P}(A_p) \to 1/p^2.

Two integers are coprime iff no prime divides both. The events {Ap}\{A_p\} across primes pp are “essentially independent” in the large-NN limit: the joint probability P(Ap1∩⋯∩Apk)\mathbb{P}(A_{p_1} \cap \cdots \cap A_{p_k}) is the probability that p1p2⋯pkp_1 p_2 \cdots p_k divides both mm and nn, which tends to 1/(p1⋯pk)21/(p_1 \cdots p_k)^2, matching the product of individual probabilities.

To justify passing from finitely many primes to all primes, first retain only primes p≤Mp\leq M. Their joint divisibility probabilities converge as stated. Uniformly in NN, the probability that a prime p>Mp>M divides all 2 sampled integers is at most p−2p^{-2}, so the union bound makes the omitted probability at most ∑m>Mm−2\sum_{m>M}m^{-2}, which tends to 00 as M→∞M\to\infty.

Hence in the limit, P∞=∏p(1−1p2).P_\infty = \prod_p \left(1 - \frac{1}{p^2}\right). This Euler product is the reciprocal of ζ(2)=∑n≥1n−2\zeta(2) = \sum_{n \geq 1} n^{-2}, and Euler’s classical evaluation gives ζ(2)=π2/6\zeta(2) = \pi^2/6. Therefore P∞=1ζ(2)=6π2≈0.6079.■\boxed{P_\infty = \frac{1}{\zeta(2)} = \frac{6}{\pi^2} \approx 0.6079.} \qedhere

Geometric interpretation. Lattice points (m,n)(m, n) with gcd⁡(m,n)=1\gcd(m, n) = 1 are exactly those visible from the origin: the line segment from (0,0)(0,0) to (m,n)(m,n) passes through no other lattice point. Hence 6/π26/\pi^2 is the asymptotic fraction of the integer grid visible from the origin. The appearance of π\pi in a lattice-counting problem is one of the oldest and most striking examples of a bridge between number theory and geometry.

Lattice points in the grid \{1, \ldots, 10\}^2 . Points visible from the origin (filled rose) are exactly those with coprime coordinates; hidden points (open grey) are behind visible ones on the line through the origin. Asymptotically, the visible fraction is 6/\pi^2 .
Lattice points in the grid {1,…,10}2\{1, \ldots, 10\}^2. Points visible from the origin (filled rose) are exactly those with coprime coordinates; hidden points (open grey) are behind visible ones on the line through the origin. Asymptotically, the visible fraction is 6/π26/\pi^2.
import numpy as np
Nmax, N = 10**4, 10**6
m = np.random.randint(1, Nmax+1, N)
n = np.random.randint(1, Nmax+1, N)
p = (np.gcd(m, n) == 1).mean()
print(f"sim: {p:.5f}   exact: {6/np.pi**2:.5f}")
# sim: 0.60811   exact: 0.60793
Report an error on this page

Reports are stored by Netlify. See the privacy note.