Consider 4 different letters: a, b, c and d. Imagine you have access from 4 up to 12 letters, with at least 1 letter of each. For example, if I have 5 letters, one possible combination could be one $a$, one $b$, one $c$ and two $d$'s. Considering the case where it is irrelevant which letters are repeated, in how many ways can I choose the letters? By hand, I know the answer is 14, but the goal is to solve this problem using generating functions.

I know that the generating function $A(x)$ for the letter "a", for example, is $$A(x) = x + x^2 + x^3 = x \left(\frac{1-x^3}{1-x}\right)$$ so, if the type of letters to be repeated were important, the total generating function would be \begin{align} A(x)B(x)C(x)D(x) & = \left(x \left(\frac{1-x^3}{1-x}\right)\right)^4 \\ & = x^4 + 4x^5 + 10x^6 + 16x^7 + 19x^8 + 16x^9 + 10x^{10} + 4 x^{11} + x^{12} \end{align} and the answer would be 81, the sum of all coefficients. The part where I'm struggling is, since the letters to be repeated are irrelevant, then the generating functions for the letters apart from $a$ should somehow depend on the numbers of $a$'s chosen in each case. I have to somehow subtract the extra irrelevant cases.

  • 1
    $\begingroup$ The number of partitions of the number $k$ into $m$ or fewer parts all of size $n$ or less is given by the coefficient of $q^k$ in the expansion of the Gaussian Binomial Coefficient $\binom{m+n}{m}_q=\prod_{i=1}^{m}\dfrac{1-q^{m+n-i+1}}{1-q^i}$. In your case you want $m=4$ and $n=2$ you then sum all coefficients of powers of $q$ except $q^0$. $\endgroup$ – N. Shales Feb 23 '17 at 2:20
  • 1
    $\begingroup$ Actually, you may include the $q^0$ coefficient if you are including the choice "abcd" but you get 15 not 14. The generating function expands to $1+q+2q^2+2q^3+3q^4+2q^5+2q^6+q^7+q^8$ for this question. I.e. There is 1 case using 1 of each letter, 1 case using 5 letters, 2 cases using 6 letters, 2 cases using 7 letters, 3 cases using 8 letters and so forth. $\endgroup$ – N. Shales Feb 23 '17 at 2:44
  • 1
    $\begingroup$ Amazing, thank you very much for your answer! $\endgroup$ – GKiu Feb 23 '17 at 11:44
  • 1
    $\begingroup$ You're welcome. For more on Gaussian Binomial Coefficients see the link or just Google it. $\endgroup$ – N. Shales Feb 23 '17 at 13:42

We consider words of length $4$ up to $12$ built from a four character alphabet $\{a,b,c,d\}$ . The following holds

  • Each word contains each of the four characters at least once

  • The position of the characters don't matter: e.g. $$aabcd\equiv badca$$

  • Multiplicity of characters matter, but not which character has a specific multiplicity: e.g. $$aabbcd\equiv abbcdd$$

With these rules, the problem boils down to look for integer partitions with exactly $4$ parts and size from $4$ up to $12$. If we consider e.g. the words of length $n=8$ there are $5$ different types \begin{align*} &5+1+1+1\qquad\longrightarrow &aaaaabcd\\ &4+2+1+1\qquad\longrightarrow &aaaabbcd\\ &3+3+1+1\qquad\longrightarrow &aaabbbcd\\ &3+2+2+1\qquad\longrightarrow &aaabbccd\\ &2+2+2+2\qquad\longrightarrow &aabbccdd\\ \end{align*}

The generating functions for the number of integer partitions with at most $k$ parts is given by \begin{align*} P^{(\leq k)}(z)=\prod_{m=1}^k\frac{1}{1-z^m}\tag{1} \end{align*} This can be found e.g. in Example I.7 in Analytic Combinatorics by P. Flajolet and R. Sedgewick.

Since we need a generating function which counts all integer partitions with exactly $4$ parts we obtain from (1)

\begin{align*} P^{(= 4)}(z)&=P^{(\leq 4)}(z)-P^{(\leq 3)}(z) =\prod_{m=1}^4\frac{1}{1-z^m}-\prod_{m=1}^3\frac{1}{1-z^m}\\ &=z^4\prod_{m=1}^4\frac{1}{1-z^m}\\ &=z^4 + z^5 + 2 z^6 + 3 z^7 + 5 z^8 + 6 z^9\\ &\qquad + 9 z^{10} + 11 z^{11} + \color{blue}{15} z^{12} + 18 z^{13} + \cdots \end{align*} Here the coefficient of $z^n, 4\leq n\leq 12$ gives (with some help of Wolfram Alpha) the number of wanted words.

$$ $$

Example: $n=15$

Let's look for example at the blue colored value which tells us, there are $\color{blue}{15}$ different partitions of $12$ with four parts.

\begin{align*} 9+1+1+1&&6+3+2+1&&5+3+2+2\\ 8+2+1+1&&6+2+2+2&&4+4+3+1\\ 7+3+1+1&&5+5+1+1&&4+4+2+2\\ 7+2+2+1&&5+4+2+1&&4+3+3+2\\ 6+4+1+1&&5+3+3+1&&3+3+3+3 \end{align*}

Note: With respect to some comments, the $q$-binomial coefficient comes into play when we are interested in the number of partitions with at most $k$ parts each at most $l$. See example I.16 in Analytic Combinatorics.

  • $\begingroup$ Thank you for your answer, I only noticed it now! $\endgroup$ – GKiu Mar 8 '17 at 15:46
  • $\begingroup$ @GonçaloQuinta: You're welcome! Everything's fine! :-) $\endgroup$ – Markus Scheuer Mar 8 '17 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.