Ma · Mathematics

How Many Integer Lattice Points Are Inside a Circle?

Published By the 9to5Science editorial team

At a glance

  1. 1. Set the circle

    For a circle centered at the origin, write its radius as R and use x² + y² ≤ R².

  2. 2. Choose each column

    For every integer x from −⌊R⌋ to ⌊R⌋, find the largest allowed integer y.

  3. 3. Count each column

    Add 2⌊√(R² − x²)⌋ + 1 for each x.

  4. 4. Check the boundary

    If the circle is open rather than closed, remove the lattice points that lie exactly on its circumference.

A lattice point is a point whose coordinates are both integers. For a circle centered at the origin, counting the lattice points inside it means counting integer pairs (x,y)(x,y) whose distance from the origin is no greater than the radius.

The area of the circle, πR2\pi R^2, gives a useful estimate, but it is not generally the exact count. The exact count can be found by checking the possible integer xx-coordinates and counting the allowed yy-coordinates in each vertical column.

Exact formula for a centered circle

Let the circle have radius R≥0R\geq 0 and equation x2+y2=R2x^2+y^2=R^2. For a fixed integer xx, the points in the disk satisfy

y2≤R2−x2.y^2\leq R^2-x^2.

If ∣x∣≤R|x|\leq R, the permitted integer values of yy run from −⌊R2−x2⌋-\lfloor\sqrt{R^2-x^2}\rfloor through ⌊R2−x2⌋\lfloor\sqrt{R^2-x^2}\rfloor. Thus that column contributes 2⌊R2−x2⌋+12\lfloor\sqrt{R^2-x^2}\rfloor+1 points. Summing over all possible integer xx gives

N(R)=∑x=−⌊R⌋⌊R⌋(2⌊R2−x2⌋+1).N(R)=\sum_{x=-\lfloor R\rfloor}^{\lfloor R\rfloor}\left(2\left\lfloor\sqrt{R^2-x^2}\right\rfloor+1\right).

This formula counts points inside or on the circle. It applies even when RR is not an integer.

Worked example: radius 5

For R=5R=5, the integer xx-coordinates range from −5-5 to 55. Because the disk is symmetric about the vertical axis, count x=0x=0 once and double the counts for positive xx:

xx-coordinateAllowed integer yy-coordinatesPoints in column
00−5-5 through 551111
11−4-4 through 4499
22−4-4 through 4499
33−4-4 through 4499
44−3-3 through 3377
550011

Therefore,

N(5)=11+2(9+9+9+7+1)=81.N(5)=11+2(9+9+9+7+1)=81.

So there are 81 integer lattice points inside or on the circle of radius 5. If “within” means strictly inside, exclude the 12 points on the circumference: (±5,0)(\pm5,0), (0,±5)(0,\pm5), and the eight points obtained by changing the signs of (3,4)(3,4). The strict count is 81−12=6981-12=69.

Connection to sums of two squares

Another way to organize the count is by distance from the origin. A lattice point on the circle of radius n\sqrt n corresponds to an integer solution of x2+y2=nx^2+y^2=n. Let r2(n)r_2(n) be the number of such ordered integer pairs, with signs and coordinate order counted. Then the number inside or on a radius-RR circle is

N(R)=1+∑n=1⌊R2⌋r2(n),N(R)=1+\sum_{n=1}^{\lfloor R^2\rfloor}r_2(n),

where the extra 11 counts the origin. This viewpoint separates the points on each individual circle (each value of nn) from the points in the whole disk.

For n≥1n\geq1, a classical formula is r2(n)=4(d1(n)−d3(n))r_2(n)=4(d_1(n)-d_3(n)), where d1(n)d_1(n) and d3(n)d_3(n) count the positive divisors of nn congruent to 1 and 3 modulo 4, respectively. For example, the positive divisors of 25 are 1, 5, and 25, all congruent to 1 modulo 4. Thus r2(25)=4(3−0)=12r_2(25)=4(3-0)=12, matching the 12 lattice points on the radius-5 circumference.

If the circle has a different center

For a circle centered at (a,b)(a,b) with radius RR, the condition is (x−a)2+(y−b)2≤R2(x-a)^2+(y-b)^2\leq R^2. For each integer xx with ∣x−a∣≤R|x-a|\leq R, the allowed integer yy values run from

⌈b−R2−(x−a)2⌉to⌊b+R2−(x−a)2⌋.\left\lceil b-\sqrt{R^2-(x-a)^2}\right\rceil \quad\text{to}\quad \left\lfloor b+\sqrt{R^2-(x-a)^2}\right\rfloor.

Count the integers in that range for each such xx and add them. The centered-circle formula is a special case with a=b=0a=b=0.

Common mistakes

  • Using area as the exact count: πR2\pi R^2 estimates the number of lattice points, but it need not be an integer and usually is not the exact answer.
  • Forgetting the floor: The largest permitted integer yy is the floor of the square root, not the square root itself.
  • Mixing up boundary conventions: “Inside” may mean strictly inside, while “inside or on” includes the circumference. State which count you want.
  • Counting only positive coordinates: The formula counts negative coordinates and zero as well. For example, (3,4)(3,4) and (−3,4)(-3,4) are distinct lattice points.

References

  1. An Introduction to the Theory of Numbers — G. H. Hardy and E. M. Wright

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.