# Is there a nice expression for the number of lattice points on a sphere? [duplicate]

Is there a nice expression for the number of points in $\mathbb{Z}^3$ which lie a distance of $\sqrt{n}$ from the origin? Here, $n$ is of course a positive integer.

-

## marked as duplicate by François G. Dorais♦, Qiaochu Yuan, Noah Snyder, Hailong Dao, Reid BartonApr 26 '10 at 20:30

Let me rephrase your question as follows: is there a closed form expression for the cube of the theta series, $\bigl(\sum_{n\in\mathbb Z}q^{n^2}\bigr)^3$. The answer is "no", although for a very close cube, $\bigl(\sum_{n\in\mathbb Z}(-1)^nq^{(6n+1)^2/24}\bigr)^3$, one has $\sum_{n=0}^\infty(-1)^n(2n+1)q^{(2n+1)^2/8}$. – Wadim Zudilin Apr 26 '10 at 8:01
@Wadim: the poster did not ask for a closed form expression, he asked for a "nice expression". Firstly, can you really assert with confidence that there is no "closed form expression"? And secondly, so much is known about the generating function---it spans the space of level 4 weight 3/2 modular forms, and there are surely by now computer algebra packages which efficiently compute coefficients---that one might argue that "it's the coefficient of q^n in the unique normalised weight 3/2 level 4 modular form, and a lot is known about coeffs of modular forms" is a "nice expression" for the number! – Kevin Buzzard Apr 26 '10 at 9:39
@Kevin: another level 4 weight 3/2 modular form, linearly independent with $f(q)$, is $\bigl(\sum_{n\in\mathbb Z}(-1)^nq^{n^2}\bigr)^3$. – Wadim Zudilin Apr 26 '10 at 10:45
See my answer mathoverflow.net/questions/3596/… – David Speyer Apr 26 '10 at 11:48
@Kevin: since this is an exact duplicate and you already got some very nice answers, I hope you don't mind my voting to close. – Hailong Dao Apr 26 '10 at 20:29

We (me, Michel, and Venkatesh) write something about this question in the preprint "Linnik's Ergodic method and the distribution of integral points on spheres."

In particular, in section 3 we explain how when n is squarefree and not congruent to 7 mod 8 the solution set of x^2 + y^2 + z^2 = n (up to the natural SO_3(Z) action) is naturally a torsor for a certain class group, so that in particular the size of the set is equal to the size of the class group. None of this is really original to us, I should emphasize! Maybe the use of the word "torsor," at most.

-

There is one answer to your question that is classical, discovered by Dirichlet. The number of proper representations of $n$ as a sum of three squares can be expressed as a sum of Jacobi symbols, for example $$r_3'(n) = 24\sum_{m \leq n/4}\left(\frac{m}{n}\right)$$ if $n \equiv 1{\;}(4)$. Here $r_3'(n)$ denotes the number of proper representations, where $x,y,z$ in $x^2 + y^2 + z^2 = n$ has no common factor. If $n$ is squarefree then $r_3(n) = r_3'(n)$, otherwise $r_3(n)$ is given by a sum $$r_3(n) = \sum_{d^2|n}r_3'(n/d^2)$$ The above formula strongly suggests that there is no simple closed form expression for $r_3(n)$.

Whether this answer really qualifies as nice is uncertain. It is necessary to separate into cases. The formula looks slightly different when $n \equiv 3{\;}(4)$. How it looks when $n$ is even I do not know.

I should mention that Gauss had expressed the number of proper representations of $n$ as a sum of three squares in terms of class numbers of binary quadratic forms. Dirichlet obtained his formulas for $r_3'(n)$ by applying his class number formula.

-