The following question is well known:



> 
> Consider representations of a given integer as sums of two squares, i.e. solutions to $a^2 + b^2 = n$ in $a,b\in\mathbb Z$ with $n$ fixed. As $n \to \infty$, are the normalized points $\left(\frac a {\sqrt n}, \frac b {\sqrt n}\right)$ uniformly distributed on the unit circle?
> 
> 
> 


An equivalent formulation is given by:



> 
> Denote by $\Delta(n)$ the *discrepancy*
>  $$\Delta(n) = \sup\_{\Gamma\text{ arc on }\mathcal S^1} \left|\frac {\text{number of points for }n\text{ in }\Gamma}{\text{number of points for }n} - \frac {\text{Length}(\Gamma)} {2\pi}\right|$$
>  Then as $n \to \infty$, is it true that $\Delta(n) \to 0$?
> 
> 
> 


The answer is "it depends on what you mean by $n \to \infty$". Obviously, for many $n$ there are no points at all or a small number of points. Even if we require the number of points to grow to infinity, a counterexample was constructed by J. Cilleruelo in *The distribution of the lattice points on circles, J. Number Theory 43 (1993), no. 2, p. 198-202*.


An answer in the positive direction is given by Erdős and Hall in *On the angular distribution of Gaussian integers with fixed norm, Discrete Math 200 (1999), p. 87-94*. The formulation is something like this (which I reproduce here in a simplified fashion):



> 
> For "almost all" integers $n \le x$ that are representable as a sum of two squares, we have $\Delta(n) \le \log ^{-\kappa} x$, where $\kappa > 0$ is an absolute constant.
> 
> 
> 


A similar result (with essentially the same analysis) was given earlier by Kátai and Környei in *On the distribution of lattice points on circles, Ann. Univ. Sci. Budapest., Sect. Math. 19 (1977), p. 87-91*.


I have two questions:


1. The analysis done by Erdős and Hall and by Kátai and Környei is based on an averaging argument. This means they say nothing about which $n$ give low discrepancy, only that most $n$ do. Is there a known result that gives criteria on $n$ to ensure low discrepancy? (In contrast, Cilleruelo's counterexample construction gives a criterion to ensure *high* discrepancy.)
2. It seems odd to me that this result is so recent (1999 or even 1977): It has been done in higher dimensions, which seems a lot harder, in 1959 (Pommerenke), and in [this MathOverflow question](https://mathoverflow.net/questions/133410/hecke-equidistribution) a reference to a similar problem was given from 1920.


Is this "folklore question" - if so, what is "new" about the more recent results? Could you give me a reference for the simplest way to solve the problem if what I want is to show that for "many sequences of integers" $n \to \infty$ (preferably, with description) we have $\Delta(n) \to 0$, and I don't care about the speed of convergence?


On the other hand, if this indeed is a new result - how come it wasn't known in the 1950s?



Angular equidistribution of lattice points on circles
If $p\equiv 1 \pmod 4$ then we may write $p=a^2+b^2$ in a unique way with $a$, $b$ both positive and 
$b< a$. Corresponding to such a representation, write $a+bi = \sqrt{p} e^{i\theta(p)}$ with $\theta(p) \in (0,\pi/4)$.  

If now $n=p\_1\cdots p\_k$ (assume for simplicity that $n$ is odd and square free) where the $p\_j$'s are $1\pmod 4$, 
then by multiplying $\sqrt{p\_j}e^{\pm i\theta({p\_j})}$ we find many representations of $n$ as a sum of two squares, and the 
angles corresponding to these representations are $\sum\_{j} \epsilon\_j \theta(p\_j)$ where $\epsilon\_j=\pm 1$. We can 
also multiply these representations by $\pm 1$ and $\pm i$ at the end, but that clearly doesn't affect our discussion. The problem then is about the equidistribution of the angles $\sum\_{j=1}^{k} \epsilon\_j \theta(p\_j)$ when we vary $\epsilon\_j$ over all the $2^k$ possible choices of sign. 


Now suppose there is some subset of the $\theta(p\_j)$ (say $\{ \theta(p\_1), \ldots, \theta(p\_\ell)\}$) which is 
equidistributed in $(0,\pi/4)$ (that is $\ell$ is large, and the discrepancy of these points for arcs in $(0,\pi/4)$ is small).  

Then using Weyl's criterion (or the Erdos-Turan discrepancy bound) one can see that the points $\sum\_{j=1}^{\ell} \epsilon\_j \theta(p\_j)$ will get equidistributed $\pmod{2\pi}$ (that is the discrepancy will be small). Since the points in $\sum\_{j=1}^{k} \epsilon\_j \theta(p\_j)$ are $2^{k-\ell}$ translates of this equidistributed set, it follows that they too are equidistributed. This gives a criterion for when you should expect equidistribution of angles, and is essentially the criterion used in 
Cilleruelo's paper referenced in my comment. Since most numbers have a lot of prime factors, and $\theta(p)$ is 
equidistributed in $(0,\pi/4)$ as $p$ runs over all primes, this criterion can be used to show angular equidistribution for 
almost all numbers that are sums of two squares. As a concrete example, if $N= \prod\_{p\le z, p\equiv 1\pmod 4} p$ then it follows that the angles corresponding to representations of $N$ as a sum of two squares are equidistributed (as $z\to \infty$). 


On the other hand, if the points $\theta(p\_j)$ (for $1\le j\le k$) all accumulate near rational numbers with the same denominator, 
then one will not get equidistribution. Thus for example if all the $\theta(p\_j)$ are small, then one has non-uniform distribution, and this is what Cilleruelo does to produce examples with high discrepancy. 


