Prerequisite - PnC and Binomial Coefficients
So far every problem discussed in previous articles has had sets of distinct elements, but sometimes problems may involve repeated use of elements. This article covers such problems, where elements of the set are indistinguishable (or identical or not distinct).
Permutations with repetition -
Counting permutations when repetition of elements can be easily done using the product rule.
Example, number of strings of length
The number ofr -permutations of a set ofn objects with repetition isn^r .
Combinations with repetition -
Counting the number of combinations with repetition is a bit more complicated than counting permutations. Consider a set of
To solve the above problem we will first take a look at a similar problem that is arranging bars(|) and stars(*). Suppose there are 5 bars and 3 stars. One possible arrangement is -
||*||**|
They can be arranged in
Our original problem is similar to the above problem. The bars represent divisions between the types of elements such that each type is separated by a bar and the number of stars is
If a star is before the nth bar, then that means an item of nth type is selected, except for the last type where the star can be after a bar. For example, the arrangement mentioned above, ||*||**|, represents a selection of 1 element of 3rd type and 2 elements of 5th type.
In this way our original problem can be thought of as arranging
There areC(r+n-1,r) = C(r+n-1,n-1) r -combinations from a set withn elements when repetition is allowed.
- Example 1 - In how many ways can 4 drinks can be chosen out of 6 possible types of drinks? There is no restriction on the number of drinks of a type that can be chosen and drinks of the same type are indistinguishable.
- Solution - The above scenario is a direct application of finding combinations with repetition. So the number of 4-combinations is -
C(6-1+4,4) = C(9,4) = 126 .
- Example 2 - How many solutions does the equation
x_1+x_2+x_3=11 have, wherex_1, x_2,\:and\:x_2 are non-negative integers?
- Solution -
x_1, x_2,\:and\:x_2 can have values ranging from 0 to 11. This situation is analogous to finding 11-combinations of 3 types of objects.
So number of solutions is -C(3-1+11,11) = C(13,11) = C(13,2) = 78
- Example 3 - Consider the same question as Example 2 but with the additional constraint that
x_1 \geq 1 .
- Solution - Since the minimum value of
x_1 is 1, the effective equation becomesx_1+x_2+x_3=10 . So the number of solutions is-C(3-1+10,10) = C(12,10) = C(12,2) = 66
- Example 4 - Consider the same question as Example 2 but with the additional constraint that
x_1 < 2 .
- Solution - Since the constraint is not a lower limit but an upper limit, it cannot be solved in the same way as in Example 3. There is another way of solving such problems.
For each type of object we assign a polynomial of the form -x^{ll} + x^{ll+1} +...+ x^{ul} , where 'll' and 'ul' are the lower and upper limits for that type of object.
Then all such polynomials are multiplied and the coefficient ofx^r is the number ofr -combinations.
In our case, there is a constraint only onx_1 . Its polynomial therefore is-x^0 + x^1
Polynomial forx_2 andx_3 is-x^0+x^1+x^2+x^3+x^4+x^5+x^6+x^7+x^8+x^9+x^{10}+x^{11}
Since multiplying polynomials can be tedious, we use a trick which uses the binomial theorem.
The above polynomial can be extended to be an infinite series since the higher order terms won't make any difference as we are only looking for the coefficient ofx^{11} .
So the polynomial forx_2 andx_3 is-x^0+x^1+x^2+x^3+...+x^{11}+...
The above polynomial is also the expansion for(1-x)^{-1} .
On multiplying the polynomials we get-(1+x)*\frac{1}{(1-x)^2} \frac{1}{(1-x)^2} can be expanded through binomial theorem for negative exponents. We won't need to expand the complete polynomial, as we just need the termsx^{11} andx^{10} , because they will be multiplied by 1 andx to get terms ofx^{11} .\frac{1}{(1+x)^n} = \sum_{k=0}^{\infty} \binom{n+k-1}{k} (-1)^k x^k .
Forx^{10} k=10 , we get-\binom{2 + 10 - 1}{10} (-1)^{10} (-x)^{10} = 11x^{10}
Forx^{11} k=11 , we get-\binom{2 + 11 - 1}{11} (-1)^{11} (-x)^{11} = 12x^{11}
On multiplying the above obtained terms withx and 1 we get terms ofx^{11} . On adding them up we get-23x^{11} .
Therefore there are 23 solutions to the given equation.
- Example 5 - Consider the same question as in Example-2 but with an inequality i.e.
x_1+x_2+x_3 \leq 11 .
- Solution - We could solve this problem in 2 ways.
One way is to add up allr -combinations for values ofr starting from 0 upto 11 i.e.x_1 + x_2 + x_3 = r for0\leq r \leq11 . We get the following values-
Forr = 0, ways = C(3-1+0,2) = C(2,2) = 1
Forr = 1, ways = C(3-1+1,2) = C(3,2) = 3
Forr = 2, ways = C(3-1+2,2) = C(4,2) = 6
Forr = 3, ways = C(3-1+3,2) = C(5,2) = 10
Forr = 4, ways = C(3-1+4,2) = C(6,2) = 15
Forr = 5, ways = C(3-1+5,2) = C(7,2) = 21
Forr = 6, ways = C(3-1+6,2) = C(8,2) = 28
Forr = 7, ways = C(3-1+7,2) = C(9,2) = 36
Forr = 8, ways = C(3-1+8,2) = C(10,2) = 45
Forr = 9, ways = C(3-1+9,2) = C(11,2) = 55
Forr = 10, ways = C(3-1+10,2) = C(12,2) = 66
Forr = 11, ways = C(3-1+11,2) = C(13,2) = 78
Total number of solutions = 364
The above problem is the same as finding the number of solutions for the equation-x_1+x_2+x_3+x_4 = 11
The extra variable can be thought of as the difference of 11 and(x_1+x_2+x_3) .
Whenx_1+x_2+x_3 is 0,x_4 is 11. Sox_4 takes values accordingly.
And the number of solutions of this equation is - C(4-1+11,4-1) = C(14,3) = 364.
References -
Permutations and Combinations
Discrete Mathematics and its Applications, by Kenneth H Rosen