In the case of a square lattice, the exact number of points within a circle of radius r centered in the center is (see: [http://mathworld.wolfram.com/GausssCircleProblem.html](https://mathworld.wolfram.com/GausssCircleProblem.html):
$$N(r)=1+4Floor(r)+4 \sum\_{x=1}^{Floor(r)}{Floor(\sqrt{r^2−x^2)}}$$
And in the case of an hexagonal lattice, I found in this post [An exact counting solution for the number of points within a circle of radius $r$ centered on a lattice point in a $A\_2$ hexagonal lattice](https://mathoverflow.net/questions/110186/an-exact-counting-solution-for-the-number-of-points-within-a-circle-of-radius-r) that the number of points within a circle of radius r centered in the center is:
$$ N(r)= \sum\_{x = -Floor(\frac{r}{\sqrt{3}})}^{Floor(\frac{r}{\sqrt{3}})}( 1 + 2 Floor(\sqrt{r^2 - 3 x^2}) + \sum\_{x = -Floor(\frac{r}{\sqrt{3}} + \frac{1}{2}) + \frac{1}{2}}^{Floor(\frac{r}{\sqrt{3}} + \frac{1}{2}) - \frac{1}{2}}( 2 Floor(\sqrt{r^2 - 3 x^2} + \frac{1}{2}). $$
And I checked this expression with the values in <http://oeis.org/A053416> and I don't obtain the same values for an r.
Can you guide me where I am wrong?
In my research I want to obtain the number of the lattice points for square and hexagonal lattices in function of lattice constant and region size.
[This is the structure that I obtain numerrically](https://i.stack.imgur.com/tRtk5.png)
I am new to this subject and I appreciate all the suggestions.



The exact number of points within a circle of radius r centered on a lattice point in a hexagonal lattice? Review expression Gauss circle problem
By identifying the lattice points with numbers of the form $x - y\omega$, $\omega = e^{2\pi i / 3}$, $x, y \in \mathbb{Z}$, we find that we want to count Diophantine solutions to $x^2 + xy + y^2 \le r^2$. From $$\sum\_{m, n \in \mathbb{Z}} q^{m^2 + mn + n^2} = 1 + 6 \sum\_{n \ge 0} \left(\frac{q^{3n+1}}{1 - q^{3n+1}} - \frac{q^{3n+2}}{1-q^{3n+2}}\right)$$ (see e.g. Michael D. Hirschhorn (1999) [Three Classical Results on Representations of a Number](http://www.mat.univie.ac.at/%7Eslc/wpapers/s42hirsch.pdf), Séminaire Lotharingien de Combinatoire, B42f) we get $$N(r) = 1 + 6 \sum\_{k=0}^\infty \left\lfloor \frac{r^2}{3k+1} \right\rfloor - \left\lfloor \frac{r^2}{3k+2} \right\rfloor$$


