Combinatorics – Counting Bounded Integer Solutions to $\sum_ia_ix_i\leqq n$

combinatorics

How to use the stars and bars method?

Say I want to find number of combinations I can get with $x_1+x_2+x_3+x_4=22$,
where $x_i\in\mathbb{N}$.

Is this the correct time to apply the method?

This is being repurposed in an effort to cut down on duplicates, see here:

Coping with abstract duplicate questions

and here: List of abstract duplicates

Best Answer

Yes, the Stars-and-Bars approach works great here, but you should know that there are two "versions" of the Stars-and-Bars approach. In both versions, we look for the number of distinct integer solutions to an equation such as yours.

In the first version, we require that every $x_i$ must be a positive integer.

In the second version, the restriction eases to include all non-negative $x_i$.

So, for example in your case, $x_1= 0, x_2=9, x_3=0, x_4=13$ would be one distinct solution in the second version, but would not be a solution in the first version.

I. positive integers $x_i$

For any pair of positive integers n and k, the number of distinct k-tuples of positive integers whose sum is $n$ is given by the binomial coefficient $${n - 1\choose k-1}.$$

In your case, $k = 4, n=22$. So the number of distinct solutions $(x_1, x_2, x_3, x_4)$ where the $x_i \in \mathbb Z, x_i>0$ is given by $$\binom{22-1}{4-1} = \binom{21}{3} = \frac{21!}{3!18!} = 1330$$


II. non-negative integers $x_i$

For any pair of natural numbers n and k, the number of distinct k-tuples of non-negative integers (which includes the possibility that one or more of the $x_i$ are zero) whose sum is $n$ is given by the binomial coefficient $$\binom{n + k - 1}{n} = \binom{n+k-1}{k-1}.$$

In your problem, $k = 4, n = 22.$ Here, the distinct solutions $(x_1, x_2, x_3, x_4)$ will include those from $I.$, but also allows 4-tuples in which one or more of the $x_i$ are zero: $x_i \in \mathbb Z, x_i\geq 0$.

$$\binom{22 + 4 -1}{22} = \binom{25}{22} = \dfrac{25!}{22!3!} = 2300$$

Related Question