Let $r(n)$ denote the number of representations of $n$ as the sum of two squares. Are there any known results on $$\sum \_{n\leq x\atop {n\equiv a(q)}}r(n)$$ and in particular is there an asymptotic formula?



Sums of two squares in arithmetic progressions
The first result in this direction seems to be due to R. A. Smith, ``The Circle Problem in an Arithmetic Progression,'' Can. Math. Bull. 11 (2), 175–184 (1968). He showed that if we write
$$\sum \_{n\leq x\atop {n\equiv a(q)}}r(n) =\pi x \cdot \frac{\eta\_{a}(q)}{q^2}+ R\_{q,a}(x)$$
where $\eta\_{a}(q) := \{ (x\_1,x\_2) \in (\mathbb{Z}/q\mathbb{Z)}^2 : x\_1^2 +x\_2^2 \equiv a \bmod q\}$, then
$$R\_{q,a}(x) = O\left( x^{\frac{2}{3} + \xi} q^{-\frac{1}{2}(1+3\xi)}\gcd(a,q)^{1/2}\tau(q) \right)$$
for any $\xi \in (0,1/3)$. This is non-trivial for $q \le x^{\frac{2}{3}-\varepsilon}$. In particular, as $x$ tends to infinity, your expression is asymptotic to $\pi x$ times the probability that $x\_1^2+x\_2^2 \equiv a \bmod q$ (for uniformly drawn $x\_1,x\_2$ mod $q$). If you consider $a$ and $q$ as fixed, this answers your question.


The state-of-the-art result is due to [D. I. Tolev, ``On the remainder term in the circle problem in an arithmetic progression,''](https://link.springer.com/article/10.1134/S0081543812010233) Tr. Mat. Inst. Steklova 276 (2012), Teoriya Chisel, Algebra i Analiz, 266--279; translation in Proc. Steklov Inst. Math. 276 (2012), no. 1, 261–274. He showed that
$$R\_{q,a}(x) = O\left( (q^{\frac{1}{2}}+x^{\frac{1}{3}}) \gcd(a,q)^{1/2}\tau^4(q)\log^4 x \right).$$
Interestingly, for $a=1$, there is a result which is superior in certain ranges of $x$ and $q$, see P. D. Varbanets, “Lattice Points in a Circle Whose Distances from the Center Are in an Arithmetic Progression,” Mat. Zametki 8 (6), 787–798 (1970) [Math. Notes 8, 917–923 (1970)].


All three results are explained in Tolev's paper.




---


In the 2002 PhD thesis of Michael J. Dancs under R. Vaughan, titled "On a Variance arising in the Gauss Circle Problem", he proves (independently of the above) that
$$f(q,a):=\lim\_{x \to \infty} \frac{\sum \_{n\leq x\atop {n\equiv a(q)}}r(n) }{\pi x}$$
exists and can be written as
$$f(q,a)=q^{-3} \sum\_{k=1}^{q} \exp\left( 2\pi i \frac{-ak}{q} \right) S(q,k)^2,$$
where $S(q,a)$ is a quadratic Gauss sum mod $q$. This gives a different expression for $\eta\_a(q)/q^2$, which was better suited for the applications given by Dancs. This is done in Theorem 2.1. He then proceeds to prove, in Theorem 2.2, the estimate
$$R\_{q,a}(x) = O\left( (\sqrt{x}+q) \log q\right).$$
For small $q$ this is better than Smith's work. Still, it is superseded by Tolev's estimates.


