[Math] Using Exponential Generating Functions on Counting Problems

combinatorics

Is it possible to use exponential generating functions to solve problems where repetition is wanted?

For example, if I wanted to solve the following problem which wants distinct possibilities…

How many different 5-letter words can be formed from the letters from the word ABRACADABRA if duplicated letters are allowed but no letter can be used more times than it occurs in the word ABRACADABRA ?

5 distinct letters, A repeated five times, B twice, C once, D once, R twice.

Then, the function would be
$$ F(x) = (1 + \frac {x}{1!} + \frac {x^2}{2!} + \frac {x^3}{3!} + \frac {x^4}{4!} + \frac {x^5}{5!}) (1 + \frac {x}{1!} + \frac {x^2}{2!})^2 (1 + \frac {x}{1!})^2 $$
$$ F(x) = \frac {x^{11}}{120} + \frac {3 x^{10}}{40} + \frac {2 x^9}{5} + \frac {19 x^8}{12}+ \frac{289 x^7}{60}+\frac{331 x^6}{30}+\frac{2221 x^5}{120}+\frac {545 x^4}{24} + \frac{121 x^3}{6}+\frac{25 x^2}{2}+5 x+1 $$

Therefore, the answer would be $5!(\frac {1271}{120})$

However, how would I be able to apply it to the following problem?

How many 5-card hands (from an ordinary deck) have at least one card of each suit?

4 suits, repeated 13 times

$ 52*51*50*49*48 = 311,875,200 $ total possibilities

$$ G(x) = (\frac {x^{13}}{13!} + \frac{x^{12}}{12!}+ \frac{x^{11}}{11!} + \frac{x^{10}}{10!} + \frac{x^9}{9!} + \frac{x^8}{8!} + \frac{x^7}{7!} + \frac{x^6}{6!} + \frac{x^5}{5!} + \frac{x^4}{4!} + \frac{x^3}{3!} + \frac{x^2}{2!} + \frac{x}{1!} + 1)^4 $$

Of course, this would just give me unique combinations, so it doesn't work. Is there an actual method to solve using exponential generating functions? Is it possible or even recommended?

Best Answer

"How many 5-card hands (from an ordinary deck) have at least one card of each suit?"

First, as a sanity check, a non-GF solution. There must be two cards of one suit and one each of the remaining three suits. There are 4 ways to choose the special suit, $\binom{13}{2}$ ways to choose its two cards, and 13 ways to choose the card from each of the remaining three suits. So the number of hands is $$4 \cdot \binom{13}{2} \cdot 13^3 = 685,464$$

Now let's try a solution using an ordinary power series generating function. Each suit can contribute 1 to 13 cards, and $n$ cards can be selected from a suit in $\binom{13}{n}$ ways, so the OPSGF is $$f(x) = \left[ \binom{13}{1}x + \binom{13}{2} x^2 + \binom{13}{3}x^3 + \dots + \binom{13}{13} x^{13} \right]^4$$ The coefficient of $x^n$ is the number of n-card hands. If all we are interested in is the coefficient of $x^5$, we can write $$f(x) = x^4 \left[ \binom{13}{1} + \binom{13}{2} x + O(x^2) \right]^4 = x^4 \left[ \binom{13}{1}^4 + \binom{4}{1} \binom{13}{1}^3 \binom{13}{2} x +O(x^2) \right]$$ so the coefficient of $x^5$ is $\binom{4}{1} \binom{13}{1}^3 \binom{13}{2}$, in agreement with our previous answer.

Now for the original question: the corresponding exponential generating function is $$g(x) = \left[ \binom{13}{1}x + \frac{1}{2!} 2! \binom{13}{2} x^2 + \frac{1}{3!} 3! \binom{13}{3}x^3 + \dots + \frac{1}{13!} 13! \binom{13}{13} x^{13} \right]^4$$ which is the same as our OPSGF, because now we are considering the order of the cards in the hand to be significant, and $n$ cards can be selected from 13 in $n! \binom{13}{n}$ ways taking order into account. The number of n-card hands, considering the order of the cards to be significant, is the coefficient of $\frac{1}{n!} x^n$. If you expand g(x) in the same way as we did for the OPSGF, the coefficient of $\frac{1}{5!} x^5$ is $5! \binom{4}{1} \binom{13}{1}^3 \binom{13}{2}$. But then if you do not want to consider the order of the cards to be significant, we have over-counted, and we must divide by 5! to compensate, leading us back to our original answer. The bottom line is that there is really not much difference between the two approaches, using an OPSGF or an EGF.