Is there a nice expression for the number of lattice points on a sphere? 
Possible Duplicate:
Is there a simple way to compute the number of ways to write a positive integer as the sum of three squares? 

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.
 A: 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.
A: 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.
