Exact Number of Points Within a Circle of Radius r on a Hexagonal Lattice – Number Theory

latticesmg.metric-geometrynt.number-theory

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:
$$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 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
I am new to this subject and I appreciate all the suggestions.

Best Answer

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, 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$$