Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Let $r_2(n)$ denote the number of representations of $n$ as a sum of two squares.

What is known about the sum of squares of this function,

$\sum_{i=1}^n r_2(i)^2$

In particular is anything known about the asymptotics as $n \rightarrow \infty$?

share|cite|improve this question
I believe that $r_k(i)$ is the number of ways to write $i$ as a sum of $k$ squares. (Cf. the SquaresR function in Mathematica.) – Aeolian Mar 6 '13 at 3:21
Yep, I mistakenly put $r_k$ instead of $r_2$, fixed now =) – Loadge Mar 6 '13 at 6:43
up vote 7 down vote accepted

Asymptotics are known for all integer moments of $r_2$: for any $m \ge 1$, there is an explicit constant $a_m$ such that $\sum_{n \le x} r_2(n)^m \sim a_m\cdot x\,(\log x)^{2^{m-1}-1}$. ($m=0$ also holds if we interpret $0^m$ as $0$.)

This result, including the precise constant (and a uniform generalization to other positive binary quadratic forms), can be found in V. Blomer and A. Granville, “Estimates for representation numbers of quadratic forms”, Duke Math. J. 135 (2006). Here's the PDF.

share|cite|improve this answer
Thanks Erick, I will check out the reference – Loadge Mar 6 '13 at 6:46

If you want to know exact formulae for these types of sums, I highly recommend "Number Theory in the Spirit of Ramanujan" by Bruce Berndt.

On page 56, a proof is given of $r_2(n) = 4 \sum_{d|n, d\ odd} (-1)^{(d-1)/2}$.

You can do a Dirichlet multiplication to get a double sum for $r_2^2(n)$.

By the way, after reading this book, I am absolutely astounded at how great a mathematician Jacobi was. He developed the $q$-series methods that enabled him to get explicit formulae for the number of representations on any integer as the sum of a number of squares or triangular numbers. Reading a list of his accomplishments is, like wow! He and Ramanujan would have gotten along famously.

share|cite|improve this answer
Thanks for the post, will add to my reading list =) – Loadge Mar 6 '13 at 6:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.