# Many representations as a sum of three squares

Let $r_3(n) = \left|\{(a,b,c)\in {\mathbb Z}^3 :\, a^2+b^2+c^2=n \}\right|$. I am looking for the maximum asymptotic size of $r_3(n)$. That is, the maximum number of representations that a number can have as a sum of three squares.

Gauss proved that $r_3(n) = \frac{A\sqrt{n}}{\pi}\sum_{m-1}^\infty\left(\frac{-n}{m}\right) \frac{1}{m}$ (where $\left(\frac{a}{b}\right)$ is the Jacobi-Legendre symbol). Another similar-looking formula can be found, for example, in the bottom of the first page of this paper

A simple and non-constructive argument shows that there are infinitely many $n$'s for which $r_3(n) \ge c\sqrt{n}$ (for some constant $c$). Moreover, in an old paper of Erdős he mentions that $r_3(n) \ge c\sqrt{n}\log \log n$ can also be obtained. Unfortunately, Erdős does not provide any details and only states "By deep number theoretic results".

More specifically, my questions are (1) how can one obtain Erdős' bound? (2) What $n$'s achieve the above bounds? (3) Can one use the above formula for $r_3(n)$ to show this?

• In your lower bounds for $r_3(n)$, $n$ should be $\sqrt{n}$. See the responses below for more information. – GH from MO Sep 7 '15 at 22:58

The formula for $r_3(n)$ essentially connects this with a class number of an imaginary quadratic field, or (apart from the $\sqrt{n}$ scaling) with the value of an $L$-function at $1$. So your question may be reformulated as asking how large can $L(1,\chi_{d})$ be as $d$ runs over negative fundamental discriminants ($d$ is essentially $-n$). The distribution of these values has been extensively investigated (see for example Granville and Soundararajan where you'll find more references. To create large values of $L(1,\chi_d)$ you should find a $d$ with $\chi_d(p)=1$ for all small primes $p$ up to some point $y$. One can do this with $d$ of size about $\exp(y)$. Then for most such $d$ one will have $$L(1,\chi_d) \approx \prod_{p\le y} \Big(1-\frac{\chi_d(p)}{p} \Big)^{-1} \asymp \log \log |d|$$ by Mertens. Arguments of this type go back to Littlewood and Chowla (see the linked paper for references).

• You beat me by one minute... – GH from MO Sep 7 '15 at 22:46
• @GH from MO: That's too bad -- one of us could have saved their energy. – Lucia Sep 7 '15 at 22:47
• No, it is fun! Let me upvote you... – GH from MO Sep 7 '15 at 22:52
• @AdamSheffer: Nothing wrong with what you wrote; but note that if $n=a^2+b^2+c^2$ then $n$ is the square of the distance. (i.e. you just have a scaling issue in what you wrote) – Lucia Sep 7 '15 at 23:25
• @AdamSheffer: In these arguments you can easily restrict $d$ to be in any progression that you want, and the result carries through. The constants in the bound may depend on the progressions. – Lucia Sep 9 '15 at 20:29

Let me restrict to the number of primitive representations $$r_3^\ast(n) = \left|\{(a,b,c)\in {\mathbb Z}^3 :\, a^2+b^2+c^2=n\ \text{and}\ \gcd(a,b,c)=1 \}\right|.$$ Note that $$r_3(n)$$ can be easily expressed from this quantity as $$r_3(n)=\sum_{d^2\mid n}r_3^\ast(n/d^2).$$ Clearly $$r_3^*(n)=0$$ when $$n\equiv 0,4,7\pmod{8}$$. For the remaining cases, it follows from the work of Gauss (1801) and Dirichlet (1839) on the class number that $$r_3^\ast(n) = \frac{24}{\pi}\,\sqrt{n}\,L\left(1,\left(\frac{D}{\cdot}\right)\right),$$ where $$D=\begin{cases} -4n,&n\equiv 1,2,5,6\pmod{8},\\ -n,&n\equiv 3\pmod{8}. \end{cases}$$ This tells us that the maximal (resp. minimal) order of $$r_3^*(n)$$ is determined by the maximal (resp. minimal) order of $$L\left(1,\left(\frac{D}{\cdot}\right)\right)$$, where $$D$$ depends on $$n$$ as above. Concerning the latter quantity, Littlewood (On the class-number of the corpus $$P(\sqrt{-k})$$, Proc. Lond. Math. Soc. (2) 27 (1928), 358-372) proved under GRH that $$(\log\log|D|)^{-1}\ll L\left(1,\left(\frac{D}{\cdot}\right)\right)\ll \log\log|D|,$$ and he also proved in the same article that $$L\left(1,\left(\frac{D}{\cdot}\right)\right)\gg\log\log|D|$$ holds for infinitely many $$D$$'s. This last bound was proved unconditionally by Walfisz (On the class-number of binary quadratic forms, Trav. Inst. Math. Tbilissi 11 (1942), 57-71), and was further explicated by Granville-Soundararajan (The distribution of values of $$L(1,\chi_d)$$, Geom. Funct. Anal. 13 (2003), 992-1028). In particular, see Theorem 5b on page 998 in Granville-Soundararajan's paper, which is also available as an arXiv preprint.

In short, there are infinitely many $$n$$'s such that $$r_3(n)\gg\sqrt{n}\log\log n$$, and this is sharp under GRH.

• Thanks a lot! From looking at Chowla's paper (repository.ias.ac.in/8839/1/8839.pdf) it seems to me that he derived the opposite direction. That is, that there are many $n$'s with small $L$ values. Does this somehow imply a similar result for large value? – Adam Sheffer Sep 8 '15 at 21:35
• @AdamSheffer: It seems I got confused with the references. It was Walfisz (1942) who proved that Littlewood's upper bound is sharp (apart from the constant), while Chowla (1947) proved that Littlewood's lower bound is sharp (apart from the constant). I will update my post with more precise references. (BTW I don't know a direct connection between the existence of small $L$-values and the existence of large $L$-values.) – GH from MO Sep 8 '15 at 21:59
• Now it all makes sense :) – Adam Sheffer Sep 9 '15 at 0:50
• @AdamSheffer: In fact Walfisz's paper concentrates on the negative fundamental discriminants. These are precisely the discriminants $D$ that arise from the square-free $n$'s with $n\equiv 1,2,3,5,6\pmod{8}$, see the precise formula for $D$ in my post. – GH from MO Sep 9 '15 at 20:40
• Thank you very much. Hopefully that's the end of these questions. – Adam Sheffer Sep 9 '15 at 20:51