# How many integer solutions are there on an $n$ dimensional hypersphere of radius $\sqrt{r}$ centered at the origin?

Let $\phi(n,r)$ be the number of integer solutions of $\sum\limits_{i=1}^n x_i^2=r$.

Then $\phi(2,r)=4\sum\limits_{d|r}\chi(d)$ where $\chi (x)=sin(\frac{\pi x}{2})=\cases{ 1\text{ when }x\cong 1 \text{ mod }4 \\ -1 \text{ when }x\cong 3 \text{ mod }4 \\ 0 \text{ when } 2|x }$

And $\phi(4,r)=8\sum\limits_{d|r}\psi(d)$ where $\psi (x)=\cases{x \text{ when }x\ncong 0 \text{ mod }4 \\ 0 \text{ when }x\cong 0 \text{ mod }4 }$

I am asking for leads on theta series. What else is known about $\phi(n,r)$? Is there an explicit formula for other $n$? Is there an explicit formula in $n$ and $r$?

Thanks to WillJagy for the helpful comments. The wolfram article on this is nice. Particularly, formula (37) of that article is pretty impressive in light of how complicated this gets in the case $$n=3$$. For this case check out the MO post for a summary and then this Bateman paper for the whole story.

The piece by Ono is pretty rewarding and has a lot of good leads. I found that we don't have an explicit formula for $$\phi(n,r)$$ but we do have a formula for a specific class of hyperspheres. Namely, when the dimension $$n$$ is given by $$(2s)^2$$ or $$(2s+1)^2-1$$ we know how many solutions can be given for all $$r$$. These appear as corollary 2 of that paper but they are not easily recreated in a contained way.

Here some more easily contained formulae:

$$\phi(6,r)=16\sum_{d|r} \bigg( \frac{ -4}{r/d} \bigg)d^2-4\sum_{d|r}\bigg( \frac{ -4}{d} \bigg)d^2$$

Where above appears Legendre-Jacobi-Kronecker symbols.

$$\phi(8,r)=16\sum_{d|r}(-1)^{d+r}d^3$$

Also appears this quote

"Therefore, the problem of computing non-trivial formulas for $$r(s; n)$$ [ which is $$\phi(n,s)$$ in the notation of this SE post] remains since the coefficients of cusp forms, although small, rarely have simple descriptions." [Ono]

Speaking of computability, I will shamelessly plug a generalization of this S.E. question. Instead of asking "how many solutions are there to $$\sum_{i=1}^n{x_i^2}=r$$?" We can ask "how many solutions are there to $$\sum_{i=1}^n{x_i^{y_i}}=r$$?"

• $\sum_{r=0}^\infty \phi(n,r)$ can be used to create a limit for the volume of the $n$th dimensional hypersphere. Here is an example for $n=8$. desmos.com/calculator/twvtr8if86 – Mason Aug 10 '18 at 4:27
• Here is a proof of the 8 dimensional case – Mason Oct 23 '18 at 3:20