Library · Geometric Probability · Chapter 52
Visible lattice points
Problem 52.1
Let be a large integer. Choose two integers independently and uniformly from . As , what is the probability that ?
Solution. Let for the uniform distribution on . For each prime , let . As , .
Two integers are coprime iff no prime divides both. The events across primes are “essentially independent” in the large- limit: the joint probability is the probability that divides both and , which tends to , matching the product of individual probabilities.
To justify passing from finitely many primes to all primes, first retain only primes . Their joint divisibility probabilities converge as stated. Uniformly in , the probability that a prime divides all 2 sampled integers is at most , so the union bound makes the omitted probability at most , which tends to as .
Hence in the limit, This Euler product is the reciprocal of , and Euler’s classical evaluation gives . Therefore
Geometric interpretation. Lattice points with are exactly those visible from the origin: the line segment from to passes through no other lattice point. Hence is the asymptotic fraction of the integer grid visible from the origin. The appearance of in a lattice-counting problem is one of the oldest and most striking examples of a bridge between number theory and geometry.
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