How many Hurwitz integers are inside a ball centered at 0 with radius R? (exact solution) It is equivalent to ask these two questions:


*

*Given a 4-d ball centered at 0 with radius R, how many integer lattice points $p_1\in\left\{(n_1,n_2,n_3,n_4):n_i\in\mathbb{Z}\right\}$ are inside it?

*Given a 4-d ball centered at 0 with radius R, how many points $p_2\in\left\{(n_1,n_2,n_3,n_4)+\frac{1}{2}(1,1,1,1):n_i\in\mathbb{Z}\right\}$ are inside it?
I hope to get an exact solution, in terms of infinite sum of some floor functions. 
 A: This is a classical variation on Gauss circle problem. It is reasonable to expect that the number $N(R)$ of lattice points in the region $x^2+y^2+z^2+w^2\leq R^2$ is close to the volume of such region, namely $\frac{\pi^2}{2}R^4$. On the other hand, if we consider a unit hypercube centered at each lattice point, the union of such hypercubes belongs to the region $x^2+y^2+z^2+w^2\leq\left(R+1\right)^2$, hence
$$ N(R) = \frac{\pi^2}{2}R^4+O(R^3)\tag{1} $$
is simple to prove. To improve the error term is non-trivial: you may have a look at Voronoi's technique for improving the error term in the original Gauss circle problem.
The $2$-dimensional and $4$-dimensional cases share much more. By denoting as
$$ r_2(n)=\left|\left\{(a,b)\in\mathbb{Z}^2:a^2+b^2=n\right\}\right| $$
$$ r_4(n)=\left|\left\{(a,b,c,d)\in\mathbb{Z}^2:a^2+b^2+c^2+d^2=n\right\}\right| \tag{2}$$
explicit formulas for $r_2$ and $r_4$ can be derived from Lambert series and the Jacobi triple product.
We have:
$$ r_2(n) = 4\left(\sum_{\substack{d\mid n \\ d\equiv 1\!\!\pmod{4}}}\!\!\!\!1-\sum_{\substack{d\mid n \\ d\equiv 3\!\!\pmod{4}}}\!\!\!\!1\right)=4(\chi_4*1)(n)\tag{3}$$
$$ r_4(n) = 8 \sum_{\substack{d\mid n\\ 4\nmid d}} d \tag{4} $$
and a simple proof of $(4)$ can be found here. In explicit terms, we clearly have
$$ N(R) = 1+\sum_{n=1}^{R^2}r_4(n) = 1+8\sum_{n=1}^{R^2}\sum_{\substack{d\mid n\\ 4\nmid d}} d.\tag{5} $$
By denoting $\sigma(n)=\sum_{d\mid n}d$, the classical result 
$$ \sum_{n\leq x}\sigma(n) = \frac{\pi^2}{12}x^2 +O(x) \tag{6}$$
leads to:
$$\begin{eqnarray*}N(R) &=& 8\left(\frac{\pi^2}{12}R^4+O(R^2)\right)-8\sum_{m=1}^{\lfloor R^2/4\rfloor}\sum_{\substack{d\mid 4m\\ 4\mid d}}d\\ &=&\frac{2\pi^2}{3}R^4+O(R^2)-32\sum_{m=1}^{\lfloor R^2/4\rfloor}\sigma(m)\\&=&\frac{\pi^2}{2}R^4+O(R^{\color{red}{2}})\tag{7}\end{eqnarray*}$$
improving $(1)$.

Despite the idea of exploiting the explicit formula $(5)$ (which can be seen as an algebraic interplay between $S^3$ and the quaternion group $\mathbb{H}$) is quite natural, it looks like $(7)$ is an actual achievement. In the literature I found the bound $N(R)=\frac{\pi^2}{2}R^4+O(R^2\log\log R)$ and Walfisz' statement about the optimality of $(7)$, but no proof of $(7)$ at all. I guess we have it now.
