Let $|\cdot|$ denote the usual norm in $\mathbb{Z}^d$. Given a finite subset $S \subset \mathbb{Z}^d$, let $\varphi(S) = \sum\_{z \in S}|z|^2$. Given $m \in \mathbb{N}$, what is the size of $\varphi^{-1}(m)$? In particular, a rough upper bound would suffice.



How many finite subsets in $\mathbb{Z}^d$ have a given sum of squares?
$|\varphi^{-1}(m)|$ is a coefficient at $x^m$ in the product
$$
\prod\_{s\in \mathbb{Z}^d} (1+x^{|s|^2}):=F(x)
$$
Hence for $0<x<1$ we have $$|\varphi^{-1}(m)|\leq x^{-m} F(x).$$
Minimising RHS in $x$ we get a reasonable upper bound. To be more specific, denote $x=e^{-t}$, $t>0$. Then
$$
\log |\varphi^{-1}(m)|\leq mt+\sum\_s \log(1+e^{-t|s|^2}).
$$
RHS contains a Riemann integral sum for the integral $I=\int\_{\mathbb{R}^d} \log(1+e^{-t|x|^2}) dx$. Alas, the Riemann sum is not less than the integral, but let's believe for a moment that they are quite close. Then $I=t^{-d/2} C\_0$ for a constant $C\_0$, so we get an estimate $mt+C\_0t^{-d/2}$. Minimizing by $t$ we get an upper estimate $C(d)m^{d/(d+2)}$.


