Academy
Maths›Number Theory›Dirichlet›Counting Lattice Points

Counting Lattice Points

A lattice point is a point with integer coordinates. Counting how many lie under a curve connects geometry, the floor function, and divisor sums in a single idea.

Draw the curve y=n/xy = n/x for some positive integer nn. How many points with positive integer coordinates lie on or below it?

This is not a geometry problem dressed up as number theory. It is number theory — because the lattice points under y=n/xy = n/x are exactly the pairs (a,b)(a, b) with ab≤nab \leq n, which counts divisors.


What is a lattice point?

A lattice point is a point (x,y)(x, y) where both xx and yy are integers.

The integer lattice is the grid Z2\mathbb{Z}^2 — all points with integer coordinates. Counting lattice points in a region is a fundamental technique in number theory.


Lattice points in a rectangle

The number of lattice points (x,y)(x, y) with 1≤x≤a1 \leq x \leq a and 1≤y≤b1 \leq y \leq b (positive integers) is simply a×ba \times b.

For non-integer bounds: lattice points with 1≤x≤X1 \leq x \leq X and 1≤y≤Y1 \leq y \leq Y number ⌊X⌋×⌊Y⌋\lfloor X \rfloor \times \lfloor Y \rfloor.


Lattice points under y=c/xy = c/x

Fix a positive integer nn. Count lattice points (x,y)(x, y) with x,y≥1x, y \geq 1 and xy≤nxy \leq n.

Approach 1 — Sum by column. For each fixed x=1,2,…,nx = 1, 2, \ldots, n, the number of valid yy is ⌊n/x⌋\lfloor n/x \rfloor (since y≤n/xy \leq n/x).

Total: D(n)=∑x=1n⌊nx⌋D(n) = \sum_{x=1}^{n} \left\lfloor \frac{n}{x} \right\rfloor

What is this sum? For each pair (x,y)(x, y) with xy≤nxy \leq n, we are counting 1. Equivalently, for each integer k≤nk \leq n, we count the number of ways to write k=xyk = xy with x,y≥1x, y \geq 1 — which is the number of divisors d(k)d(k).

Therefore: D(n)=∑x=1n⌊nx⌋=∑k=1nτ(k)D(n) = \sum_{x=1}^{n} \left\lfloor \frac{n}{x} \right\rfloor = \sum_{k=1}^{n} \tau(k)

where τ(k)\tau(k) is the number of divisors of kk.

This connection — lattice points under a hyperbola equal the sum of divisor counts — is the starting point of Dirichlet's Divisor Problem.


Symmetry across the diagonal

The hyperbola xy=nxy = n is symmetric about the line y=xy = x.

For lattice points (x,y)(x, y) with xy≤nxy \leq n:

  • Points with x<yx < y pair with points with x>yx > y (swap coordinates)
  • Points with x=yx = y satisfy x2≤nx^2 \leq n, so x≤⌊n⌋x \leq \lfloor \sqrt{n} \rfloor

This symmetry gives a smarter way to count.

Approach 2 — Use symmetry. Let m=⌊n⌋m = \lfloor \sqrt{n} \rfloor.

Points with x≤mx \leq m and y≤my \leq m (the "square" region): m2m^2.

Points with x≤mx \leq m and y>my > m — for each x≤mx \leq m, yy ranges from m+1m+1 to ⌊n/x⌋\lfloor n/x \rfloor. Count: ∑x=1m(⌊n/x⌋−m)\sum_{x=1}^{m} (\lfloor n/x \rfloor - m).

By symmetry, points with x>mx > m and y≤my \leq m give the same count.

Therefore: D(n)=2∑x=1m⌊nx⌋−m2D(n) = 2\sum_{x=1}^{m} \left\lfloor \frac{n}{x} \right\rfloor - m^2

where m=⌊n⌋m = \lfloor \sqrt{n} \rfloor.

This formula is much faster to compute than summing all nn terms.


Lattice points under y=cxy = cx (linear case)

Count lattice points (x,y)(x, y) with x≥1x \geq 1, y≥1y \geq 1, y≤cxy \leq cx for rational c=p/qc = p/q.

For each xx: yy ranges from 1 to ⌊px/q⌋\lfloor px/q \rfloor. Total: ∑x=1n⌊px/q⌋\sum_{x=1}^{n} \lfloor px/q \rfloor.

This sum — called a Dedekind sum in its general form — appears in problems about counting integers with bounded ratios.


Lattice points in a triangle

Points (x,y)(x, y) with x≥1x \geq 1, y≥1y \geq 1, x+y≤nx + y \leq n:

For each x=1,…,n−1x = 1, \ldots, n-1: yy ranges from 1 to n−x−1n - x - 1, giving n−x−1n - x - 1 points (if positive).

Total: ∑x=1n−1(n−x−1)=(n−1)(n−2)2\sum_{x=1}^{n-1}(n-x-1) = \frac{(n-1)(n-2)}{2}.

This is (n−12)\binom{n-1}{2} — the triangular number pattern.


Worked problems

Problem 1. Compute ∑k=110τ(k)\displaystyle\sum_{k=1}^{10} \tau(k) by counting lattice points.

D(10)=∑x=110⌊10/x⌋=10+5+3+2+2+1+1+1+1+1=27D(10) = \sum_{x=1}^{10} \lfloor 10/x \rfloor = 10+5+3+2+2+1+1+1+1+1 = 27.

Check: τ(1)+⋯+τ(10)=1+2+2+3+2+4+2+4+3+4=27\tau(1)+\cdots+\tau(10) = 1+2+2+3+2+4+2+4+3+4 = 27. ✓

Problem 2. Use the symmetry formula to compute D(10)D(10).

m=⌊10⌋=3m = \lfloor \sqrt{10} \rfloor = 3.

∑x=13⌊10/x⌋=10+5+3=18\sum_{x=1}^{3} \lfloor 10/x \rfloor = 10 + 5 + 3 = 18.

D(10)=2×18−9=27D(10) = 2 \times 18 - 9 = 27. ✓

Problem 3. How many pairs (a,b)(a, b) of positive integers satisfy ab≤20ab \leq 20 and a≤ba \leq b?

These are lattice points with xy≤20xy \leq 20 and x≤yx \leq y — the points on or below the diagonal.

m=⌊20⌋=4m = \lfloor \sqrt{20} \rfloor = 4. Using symmetry: D(20)=2∑x=14⌊20/x⌋−16=2(20+10+6+5)−16=82−16=66D(20) = 2\sum_{x=1}^{4}\lfloor 20/x\rfloor - 16 = 2(20+10+6+5) - 16 = 82 - 16 = 66.

Points with a≤ba \leq b: D(20)+⌊20⌋2=66+42=35\frac{D(20) + \lfloor\sqrt{20}\rfloor}{2} = \frac{66+4}{2} = 35.

(Add the diagonal points — those with a=ba=b, i.e., a2≤20a^2 \leq 20, giving a∈{1,2,3,4}a \in \{1,2,3,4\} — then halve.)

Problem 4. Prove: ∑d∣n1=τ(n)\displaystyle\sum_{d \mid n} 1 = \tau(n) by a lattice point argument.

The sum ∑d∣n1\sum_{d \mid n} 1 counts divisors of nn. Each divisor dd corresponds to the lattice point (d,n/d)(d, n/d) on the hyperbola xy=nxy = n. So τ(n)\tau(n) is the number of lattice points on xy=nxy = n with x,y≥1x, y \geq 1. ■\blacksquare


The deeper question: not just how many lattice points, but approximately how many — and how good the approximation is. That requires understanding the hyperbola's area, which is in Hyperbola Area Intuition.