"Stars and bars" technique with integer numbers

138 Views Asked by At

I'm failing to extend the "stars and bars" technique from Natural to integer numbers. HELP!

How many vectors $\mathbf{X}$ exist such that $\mathbf{X}$ is a vector of $D$ integer numbers where each element $\mathbf{X}(i)$ is between $-N$ and $+N$ and $\sum_{i=1}^D |\mathbf{X}(i)| = N$?

I'm looking for the combinatorial formula as a function of $D$ and $N$.

Thank you!

2

There are 2 best solutions below

1
On

Start by ignoring all the negative options for the $X(i)$. Now you have a classic stars and bars problem that allows $0$ in the sum. Any sum that involves $k$ zeros and $D-k$ nonzeros represents $2^{D-k}$ solutions because you can negate all the nonzero items. You need to condition on the number of zeros.

2
On

The number of such vectors, i. e. the number of points of $1$-norm $N\geq 1$ in cubic lattice $\mathbb{Z}^D$ is equal to $$A(D,N)=\sum_{k=1}^D\binom{D}{k}\binom{N-1}{k-1}2^k$$ where $1\leq k\leq D$ is the number of components which are different from zero, $\binom{D}{k}$ is the number of ways to select $k$ component out of $D$, $2^k$ is the number of ways to arrange the sign of each non-zero component, and $\binom{N-1}{k-1}$ is the number of positive integer solutions of the equation $z_1+\dots +z_k=N$ (see "stars and bars" technique). See also OEIS sequence A035607.