2

I read a question recently, asking

In how many ways can $3$ letters be chosen from $AABBBC$?

The solution says 'It is possible to derive a formula that can be applied in all such cases'. However, it does not do so, instead going about a case-based analysis and recommending that the reader do the same.

I am unsure whether said formula was omitted because it is too complicated, or if the writers meant to say 'it is impossible'. So I set about trying to derive such a formula.

My formulation of the question:

Let there be $a_1$ objects of type $1$, $a_2$ of type $2$, and so on, till we have $m$ types of objects, with type $i$ having $a_i$ objects. All objects of the same type are identical, and two objects of different types are different. Find the number of ways $n$ in which $k$ objects can be selected, assuming $k\leq\sum a_i$.

Alternative formulations I thought of:

  1. How many solutions does the equation $x_1+x_2+\dots+x_m=k$ have, where $x_i\in\Bbb N,\;\;0\leq x_i\leq a_i$? (This is similar to this question, except that here the order of the numbers matters and each number has constraints.)

  2. Let $h=x_1+x_2+\dots+x_m$, where $x_i\in\Bbb N,\;\;0\leq x_i\leq a_i$. As each $a_i$ takes all its possible values, how many times does $h=k$?

  3. Let there be an $m$-dimensional space, where a general point has coordinates $(x_1,x_2,\dots,x_m)$. How many lattice points does the part of the $(m-1)$ dimensional space $\sum x_i=k$ contained in the portion of the $m$-dimensional space given by $0\leq x_i\leq a_i$ have?

I tried starting with $m=1$ and proceeding from there.

$\text{WLOG}\quad a_i\leq a_{i+1}$


$m=1$

Then there are $a_1$ identical objects, and there is only $1$ way of choosing $k$ objects, as all are identical.


$m=2$

From here already I run into problems. If $a_1+a_2=k$, then $n=1$. If not, then things get much more complicated. It matters by where $k$ lies with respect to them, and also how they lie with respect to each other.

Here, if $k\leq a_1,a_2$, then $n=k+1$. If $k$ lies between $a_1,a_2$ then $n=a_1+1$.


$m=3$

If $k\leq a_1$, then $n=\frac{(k+1)(k+2)}2$.

If $a_1\leq k\leq a_2$, then $n=\frac{(a_1+1)(2k-a_1+2)}{2}$

If $a_2\leq k\leq a_3$, there are two cases, when $a_1+a_2\leq k$ or $a_1+a_2\geq k$.

It was at this point that I gave up.


Please help.

DynamoBlaze
  • 2,781
  • 2
    The general formula has $2^m$ terms and comes from either an inclusion-exclusion formula, or from generating functions. – Thomas Andrews Aug 08 '19 at 00:12
  • @ThomasAndrews What do you mean? The source question asks in how many ways can be chosen from AABBBC. Each choosing, supposse AAB, is equivalent to an arrangement of $x_i$, in this case $2,1,0$. – DynamoBlaze Aug 08 '19 at 00:19
  • Yes, my second (now deleted) comment was wrong. Misread. – Thomas Andrews Aug 08 '19 at 00:20

1 Answers1

2

The generating function approach to the original problem is to find the coefficient of $x^3$ when expanding $$f(x)=(1+x+x^2)(1+x+x^2+x^3)(1+x)$$ This can be rewritten as:

$$f(x)=\frac{1}{(1-x)^3}\left(1-x^3\right)\left(1-x^4\right)\left(1-x^2\right)$$

Then we can expand $$(1-x^3)(1-x^4)(1-x^2)=1-x^2-x^3-x^4+x^5+x^6+x^7-x^9.$$

We also have $$\frac{1}{(1-x)^3}=\binom{0+2}{2}+\binom{1+2}{2}x+\cdots + \binom{n+2}{2}x^n+\cdots$$

So you get that the coefficient of $x^n$ in $f(x)$ can be written as:

$$\binom{n+2}{2}-\binom{n}{2}-\binom{n-1}{2}-\binom{n-2}{2}+\binom{n-3}{2}+\binom{n-4}{2}+\binom{n-5}{2} - \binom{n-7}{2}$$

Implicitly, this means the value is $0$ when $n\geq 7,$ since the degree of $f(x)$ is $6.$

Then we get the when $n=3$ is:

$$\binom{5}{2}-\binom{3}{2}-\binom{2}{2}=10-3-1=6$$

because only the first three terms are non-zero.


For your general example, the generating function is:

$$f(x)=\frac{1}{(1-x)^m}\prod_{i=1}^{m}\left(1-x^{a_i+1}\right)$$

So if $$p(x)=\prod_{i=1}^{m}\left(1-x^{a_i+1}\right)=\sum_{i} p_ix^i$$

Then we use that $$\frac{1}{(1-x)^m}=\sum_{n=0}^{\infty}\binom{n+m-1}{m-1}x^n$$ to get the coefficient for $x^n$ in $f(x)$ is:

$$\sum_{i} p_i\binom{n+m-1-i}{m-1}\tag{1}$$

So, given the $a_i,$ you can compute the polynomial $p(x)$ which has at most $2^m$ terms. Then the number of ways to get a sub-(multi)-set of size $n$ is $(1).$


You can also take this as an inclusion-exclusion argument where $A=\{(b_1,\dots,b_m)\mid b_1+\cdots+b_m=n\}$ and the subsets $A_j=\{(b_1,\dots,b_m)\in A\mid b_j>a_j\}.$

Then you use inclusion-exclusion to get that:

$$\begin{align}|A\setminus \left(A_1\cup\cdots\cup A_m\right)|=&|A|\\&-\left(|A_1|+\cdots+|A_m|\right)\\&+\left(|A_1\cap A_2|+|A_1\cap A_3|+\cdots + \left|A_{m-1}\cap A_m\right|\right)\\&+\cdots\end{align}$$

Thomas Andrews
  • 177,126
  • Yep. Clear, complete, correct (and more than needed for the problem). (+1) – David G. Stork Aug 08 '19 at 18:16
  • How do you get the expression for $1\over(1-x)^3$? – DynamoBlaze Aug 08 '19 at 18:47
  • 1
    @MalayTheDynamo It can be gotten by taking the derivative twice of $\frac{1}{1-x}$ and then divide by $3!=6.$ Alternatively, you can think of the coefficient of $x^n$ of $\frac{1}{(1-x)^3}=(1+x+x^2+\cdots)^3$ as the number of ways to solve $b_1+b_2+b_3=n$ for integers $b_i\geq 0.$ This number being $\binom{n+2}{2}$ can be done via the stars and bars argument. https://en.wikipedia.org/wiki/Stars_and_bars_(combinatorics) – Thomas Andrews Aug 08 '19 at 18:53
  • @ThomasAndrews Thank you! This explains everything! +1 and accepted! – DynamoBlaze Aug 08 '19 at 18:55