Academy
MathsNumber TheoryDirichletCounting 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 abnab \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 1xa1 \leq x \leq a and 1yb1 \leq y \leq b (positive integers) is simply a×ba \times b.

For non-integer bounds: lattice points with 1xX1 \leq x \leq X and 1yY1 \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,y1x, y \geq 1 and xynxy \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 yn/xy \leq n/x).

Total: D(n)=x=1nnxD(n) = \sum_{x=1}^{n} \left\lfloor \frac{n}{x} \right\rfloor

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

Therefore: D(n)=x=1nnx=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 xynxy \leq n:

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

This symmetry gives a smarter way to count.

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

Points with xmx \leq m and ymy \leq m (the "square" region): m2m^2.

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

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

Therefore: D(n)=2x=1mnxm2D(n) = 2\sum_{x=1}^{m} \left\lfloor \frac{n}{x} \right\rfloor - m^2

where m=nm = \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 x1x \geq 1, y1y \geq 1, ycxy \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=1npx/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 x1x \geq 1, y1y \geq 1, x+ynx + y \leq n:

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

Total: x=1n1(nx1)=(n1)(n2)2\sum_{x=1}^{n-1}(n-x-1) = \frac{(n-1)(n-2)}{2}.

This is (n12)\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=11010/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=1310/x=10+5+3=18\sum_{x=1}^{3} \lfloor 10/x \rfloor = 10 + 5 + 3 = 18.

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

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

These are lattice points with xy20xy \leq 20 and xyx \leq y — the points on or below the diagonal.

m=20=4m = \lfloor \sqrt{20} \rfloor = 4. Using symmetry: D(20)=2x=1420/x16=2(20+10+6+5)16=8216=66D(20) = 2\sum_{x=1}^{4}\lfloor 20/x\rfloor - 16 = 2(20+10+6+5) - 16 = 82 - 16 = 66.

Points with aba \leq b: D(20)+202=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., a220a^2 \leq 20, giving a{1,2,3,4}a \in \{1,2,3,4\} — then halve.)

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

The sum dn1\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,y1x, 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.