Unique integer solutions to $\sum\limits_{i=1}^n a_i = A$ when $l \leq a \leq u$ and $a,A,l,u \in \mathbb{N}$

64 Views Asked by At

I'm trying to find a analytical way for finding the total amount of unique solutions to equation:

$$\sum\limits_{i=1}^n a_i = A, \text{when } l \leq a \leq u,$$ where $a,A,l,u \in \mathbb{N}$. For example:

$$\sum\limits_{i=1}^2 a_i = 4, \text{when } 1 \leq a \leq 3,$$ has solution three unique solutions $(2,2), (1,3), (3,1)$. I haven't found a strategy for this type of problem in any literature, but it seems to be a type of problem that interest mathematicians.

1

There are 1 best solutions below

0
On BEST ANSWER

First let $b_i=a_i-\ell$ for $i=1,\ldots,n$; the number of integer solutions to

$$\sum_{i=1}^na_i=A$$

satisfying $\ell\le a_i\le u$ for $i=1,\ldots,n$ is the same as the number of integer solutions to

$$\sum_{i=1}^nb_i=A-\ell n$$

satisfying $0\le b_i\le u-\ell$ for $i=1,\ldots n$. The accepted answers to this question and this question give the answer, albeit without going into much detail:

$$\sum_{k=0}^n(-1)^k\binom{n}k\binom{A-\ell n+n-1-k(u-\ell+1)}{n-1}\;,$$

where the upper number in the last binomial coefficient can be simplified in various ways. To the best of my knowledge there is no nice closed form for this.

The problem can also be solved using generating functions, but evaluating the desired coefficient is typically as messy as computing the sum above.