0

The formula to calculate in how many ways can $k$ numbers have sum $n$ is $\binom{n+k-1}{n}$, but the only limit on summands is $n$, infact, in case of (for example) $k = 3$ and $n = 6$ the formula considers also $\{600\}$, $\{060\}$ $\{006\}$. If I want to impose a limit $L < n$ on summands there is a way to restrict $\binom{n+k-1}{n}$ in order to consider the limit or some other formula?

Thanks for the answers.

M3M3X
  • 15
  • Probably "limit" is not the best choice of terminology here, consider "maximum" or "their magnitude is bounded above by". – JustAskin Jan 08 '16 at 00:14

3 Answers3

2

Another way is to use inclusion-exclusion, best illustrated by a concrete example, say $x_1 + x_2 + x_3 + x_4 = 14,\;\; 0\le x_j \le 5$

To take care of the upper limit constraint, we deliberately pre-place $6$ in one or more $x_j$.

Applying PIE, we get $\dbinom{17}{4} - \dbinom41\dbinom{11}{4} + \dbinom42\dbinom54 = 80$

PS

The first term gives the unrestricted number of ways. If we deliberately place $6$ in one or more $x_j$, we will get the count of the violations. We can violate the limit in one term in $\binom41$ ways, in two terms in $\binom42$ ways, and we can't violate the limit in $3$ or more terms.

If you want it reduced to a formula,

$$W(n,k,L) = \sum_{j=0}^{J} (-1)^j \binom{k}{j}\binom{n+k-1 - (L+1)j}{k-1}, J = \lfloor\frac{n}{L+1}\rfloor$$

The formula corresponds to what we did as a concrete example.

  • This (obviously) gives the same general expression than my method above. It might be preferable for specific, small values of $L$. – vonbrand Jan 08 '16 at 09:53
  • Ok maybe is what I'm looking for, but I don't understand where you get those numbers. Can I have a formula please? – M3M3X Jan 08 '16 at 10:06
  • I have added a PS giving the logic and a formula – true blue anil Jan 08 '16 at 12:10
  • Ok, perfect infact if I apply this formula to $k = 8$, $n = 4$ and $L = 1$ I obtain $\dbinom{11}{7} - \dbinom81\dbinom{9}{7} + \dbinom82\dbinom77 = 330 - 8 * 36 + 28 * 1= 70$ – M3M3X Jan 08 '16 at 15:00
1

One way to solve this is to use generating functions. One term of the sum, if it is limited to $L$, is represented by:

$\begin{align} 1 + z + \dotsb + z^L = \frac{1 - z^{L + 1}}{1 - z} \end{align}$

The number of ways to get a sum $n$ of $k$ terms is represented by the coefficient of $z^n$ in:

$\begin{align} [z^n] (1 + z + \dotsb + z^L)^k = [z^n] \left( \frac{1 - z^{L + 1}}{1 - z} \right)^k \end{align}$

Expanding the numerator as a binomial power, ditto the denominator (an infinite sum in that case) gives a very messy expression for it.

In the case there is no limit $L$ (or if $n \le L$), you just get:

$\begin{align} [z^n] (1 - z)^{-k} = (1)^n \binom{-k}{n} = \binom{n + k - 1}{n} \end{align}$

as you state.

vonbrand
  • 27,812
  • This is a good solution but is quite complex to use. I would like to have a formula to replace $n$, $k$, and $L$ to obtain the solution, if exists. – M3M3X Jan 08 '16 at 10:04
  • @M3M3X, I'd like it too. But this is the simplest I've found. – vonbrand Jan 08 '16 at 10:12
1

As suggested by @vonbrand, you are looking for \begin{align} [z^n] (1 + z + \dotsb + z^L)^k = [z^n] \left( \frac{1 - z^{L + 1}}{1 - z} \right)^k \end{align} The coefficients of such a finite polynomial are expressible by a finite summation as indicated in the answer to Rolling Dice Problem.

G Cab
  • 35,272