5

What is the total number of solutions for following equation

$$x_1+x_2+x_3+.....+x_k=n$$

with a maximum value of $m$, where $0\leq x \leq m$. No two variables should contain a maximum value $m$.

Example: $x_1+x_2+x_3=3$ with a maximum value $2$ ($n=3$, $m=2$, $k=3$)

Total possible ways is $7$: $$\{1,1,1\}, \{0,1,2\}, \{0,2,1\}, \{1,0,2\}, \{1,2,0\}, \{2,0,1\}, \{2,1,0\}$$

I've done it manually but I don't how to come up with a formula. I've been struggling for last one week. Is there any formula?

leonbloy
  • 66,202
Malka
  • 61

1 Answers1

3

Hint: You can divide the solutions into two groups. One, those which attain the maximum value ($x_i = m$ for some $i$, and $x_j < m$ for all $j\ne i$); the other, in which $x_i < m$ for all $i$.

Then you can count the cardinality of each set by looking into this question.

Specifically, adapting the linked pdf (formula E, page 441), we get that the number of compositions of $k$ numbers $0\le x_i<m$ with $\sum x_i = n$ is given by

$$F(n,m,k)= \sum_{j=0}^{\lfloor n/m \rfloor} (-1)^j {k \choose j}{n+k - j \, m -1 \choose k-1}$$

Then we have

$$C(n,m,k) = k \, F(n-m,m,k-1) + F(n,m,k) $$

In your example:

$$C(3,2,3) = 3 \, F(1,2,2) + F(3,2,3) = 3 \times 2 + 1 = 7$$

leonbloy
  • 66,202
  • :Will this formulat considers condition "Only one variable out of k variables contains maximum value m"? – Malka Mar 21 '13 at 06:15
  • Example:x1+x2+x3+x4=6 with max value 3.n=6,k=4,m=3.Solutions {3,3,0,0},{3,0,3,0},{0,3,3,0},{0,0,3,3} are invalid – Malka Mar 21 '13 at 06:16
  • Yes, that restriction is taken into account, see the hint, the two groups correspond (respectively) to the two terms in $C(n,m,k)$ formula – leonbloy Mar 21 '13 at 11:14
  • ... and, regarding your first comment, I gather that it actually should read "at most one variable" instead of "only one variable". – leonbloy Mar 21 '13 at 11:45
  • Is there any generic formula for given both minimum value and maximum values. – Malka Apr 30 '13 at 08:52
  • What about marking you past questions as answered before asking new questions? http://math.stackexchange.com/faq#howtoask – leonbloy Apr 30 '13 at 13:24