How many points are in such set with the same norm-2

Let $L=[a,b]\cap\mathbb{N}$ with $a,b\in\mathbb{N}$, let $D\in\mathbb{N}$, and let $C=L^D$. Then I would like to know how many points are there in $C$ with the same given norm-2 $d$. I.e., I'm looking for $|A|$, where

$A = \{p\in C,\ ||p||_2=d\}$

• What kind of answer do you want? There won't be a simple nice closed formula. But for example, you might fix $a,b,d$ and ask for an estimate for the size of $|A|$ as $D\to\infty$. Or you might fix $D$ and let $a,b,d\to\infty$ in a suitable way. Of course, there are trivial cases, for example, if $a>d/\sqrt{D}$, then $A=\emptyset$. – Joe Silverman Oct 28 '15 at 21:24
• @JoeSilverman a nice-formula lower boundary will be the best option... I was thinking on using this for data compression but know I think it's not possible to apply it where I want. Having a lower limit will help me out proving that it is indeed stupid to keep researching on this path. – Carlos Navarro Astiasarán Oct 30 '15 at 0:28

The answer is the coefficient of $t^{d^2}$ in the generating function $\left( \sum_{j=a}^b t^{j^2}\right)^D$.