Skip to main content

Section 5.1 Generating Functions

Subsection 5.1.1 Generating Functions (regular)

Goal: Construct a polynomial such that each coefficient is the count of part of a problem like the following (assigned later). At the DeckDich restaurant there are two choices for salad, four choices for entrée, and two choices for dessert. Salads and desserts are optional, and a patron can order up to one of everything. Each item is $10. Determine the number of meals possible for each multiple of $10.

Definition 5.1.1. Generating Function.

A function is a generating function if and only if \(g(x)=a_0+a_1x+a_2x^2+\ldots+a_nx^n+\ldots\) and \(a_i\) is the number of ways to select \(i\) items.

Subsubsection 5.1.1.1 Model

Generating functions are based on the principle that coefficients generated by expanding polynomials are inherently combinations. You may be familiar with this concept as ‘binomial coefficients’ or ‘Pascal’s Triangle.' This section establishes these connections.

Problem 5.1.2.

The typical fencing mnemonic for a binomial expansion (e.g., \((1+x)(1+x)\)) is limiting. Instead let the first term in each factor be called ‘o’ (for one) and the second term in each factor be called ‘t’ for two. The mnemonic is then ‘oo+ot+to+tt.’

  1. ‘oo+ot+to+tt’ becomes ‘oo+2ot+tt’ for the example above. Explain.

  2. What is the mnemonic for \((1+x)(1+x)(1+x)\text{?}\)

  3. How many times will ‘ttt’ show up in the triple product above?

  4. How many times will two t's and one o show up in the triple product?

Solution.
  1. By the cumulative property ‘to’ can also be written as ‘ot’, thus ‘to’=‘ot’ and ‘to’ added to ‘ot’ produces ‘2ot’.

  2. \begin{equation*} (1+x)(1+x)(1+x) = (o+t)(o+t)(o+t) = (oo+2ot+tt)(o+t) = ooo+2oot+oot+oot+2ott+ttt = ooo+3oot+3ott+ttt\text{.} \end{equation*}
    \begin{equation*} ooo+3oot+3ott+ttt = ooo+oot+oot+oot+ott+ott+ott+ttt\text{.} \end{equation*}
  3. From the previous work done in 2, ‘ttt’ would appear only once in the triple product.

  4. From the previous work done in 2, a term will two t's (‘tt’) and one o (‘o’) will occur three times in the triple product.

Problem 5.1.3.

Calculate the specified coefficients.

  1. \(x^2\) in \((1+x)^4\)

  2. \(x^3\) in \((1+x)^6\)

  3. \(x^4\) in \((1+x)^6\)

Solution.

\((1+x)^4 = (o+t)^4 = (ooo+3oot+3ott+ttt)(ott)\) \(=oooo+4ooot+6oott+4ottt+tttt\) \(6oott = 6t^2 = 6x^2\) coefficient 6

\((o+t)^6 = (oooo+4ooot+6oott+4ottt+tttt)(o+t)^2\) This is to long to expand. When expanding \((o+t)^4\text{,}\) it was similar to the 4th row of the pascal's triangle. So the coefficient of \(x^3\) is 20 from the 6th row of pascal's.

\((1+x)^6\text{,}\) the coefficient of \(x^4\) is 15 based on pascal's triangle in row 6.

Problem 5.1.4.

Consider the product \((1+x+x^2)(1+x+x^2)\text{.}\)

  1. How many times does \(x^2\) occur in the product?

  2. Why is this greater than 2?

  3. How many times does \(x^3\) occur in this product?

Subsubsection 5.1.1.2 Problems

Problem 5.1.6.

Hansel is presented with one box of chocolate covered macademia nuts and one box of turtles. If he can take zero, one, or two pieces of candy from each box, how many ways can he select two candies? three candies?

Solution.

This situation corresponds to the trionimial expansion \((1+x+x^2)^2\text{.}\) This polynomial encodes the choice of 0, 1, or 2 candies from a box by the power of \(x\) on a term. The two boxes give us the power on the expansion. Thus, the number of ways to select two candies corresponds to the coefficient on \(x^2\) in this expansion. That coefficient is \(3\text{.}\) The number of ways to choose three candies corresponds to the coefficient of \(x^3\text{,}\) which is \(2\text{.}\)

Problem 5.1.7.

Consider the product \((1+x+x^2)(x+x^2+x^3+x^4)(1+x+x^2)\text{.}\)

  1. List all the ways \(x^2\) occurs.

  2. List all the ways \(x^3\) occurs.

  3. List all the ways \(x^4\) occurs.

Problem 5.1.8.

At the DeckDich restaurant there are two choices for salad, four choices for entrée, and two choices for dessert. Salads and desserts are optional, and a patron can order up to one of everything. Each item is $10.

  1. How many options are there for a $20 order?

  2. How many options are there for a $30 order?

  3. How many options are there for a $40 order?

Solution.

There are multiple ways to interpret this problem. For the sake of exercise, we will address as many as we can.

  1. Are the dinner items unique? Or do we only care about the type of items being purchased (for example, is an almond salad and an enchilada a different meal from a caesar salad and an enchilada?).

  2. Is the diner restrict to a single item of each type (one salad, one entree, and one dessert), or are they restrict to a single item of each subtype (one almond salad, one caesar salad, one enchilada, one cordon bleu,…)?

Let's begin by assuming that we would like to find the number of possible meals in a scenario where the diner is restrict to a single selection of each type of meal item and we care only about the types that were purchased rather than the specific dish (so an almond salad is the same as a caesar salad. We only care that it is a salad). Labeling salads as S, entrees as E, and desserts as D, we see that there are:

  1. 1 $10 meal (\(E\)).

  2. 2 $20 meals (\(SE, ED\)).

  3. 1 $30 meal (\(SED\)).

  4. 0 $40 meals

For this scenario we see that the generating function that produces the correct coefficients to represent the variety of meals is:

\begin{equation*} (1+x)(x)(1+x)=x+2x^{2}+x^3 \end{equation*}

This matches our intuitiion since the diner can either buy or not buy a salad, must buy an entree, and can buy or not buy a dessert.

Let's boost the complexity a little bit. Suppose that the diner can purchase only one item of each type, but now we care about which option they chose (so an almond salad is not the same as a caesar salad). By brute force counting we see that there are:

  1. 4 $10 meals (\(E_1,E_2,E_3,E_4\)).

  2. 16 $20 meals (\(S_1E_1,S_1E_2,S_1E_3,S_1E_4,S_2E_1,S_2E_2,S_2E_3,S_2E_4,E_1D_1,E_1D_2,E_2D_1,E_2D_2,E_3D_1,E_3D_2,E_4D_1,E_4D_2\))

  3. 16 $30 meals (\(S_1E_1D_1,S_1E_1D_2,S_1E_2D_1,S_1E_2D_2,S_1E_3D_1,S_1E_3D_2,S_1E_4D_1,S_1E_4D_2,S_2E_1D_1,S_2E_1D_2,S_2E_2D_1,S_2E_2D_2,S_2E_3D_1,S_2E_3D_2,S_2E_4D_1,S_2E_4D_2\))

  4. 0 $40 meals.

We see that a function that produces the desired coefficients is:

\begin{equation*} (1+2x)(4x)(1+2x)=4x+16x^{2}+16x^{3} \end{equation*}

This matches our intuition since the diner can choose whether to buy a salad and has two options, they must buy one of 4 entrees, and they can choose whether or not to buy one of two desserts.

Exploring yet another scenario, suppose that the diner could purchase one of each individual item on the menu rather than just one of each type, but we still only care how many of each type they bought rather than the specific items (so buying an enchilada and cordon bleu is the same as buying a steak and panko shrimp). We see that there are:

  1. 1 $10 meal (\(E\))

  2. 3 $20 meals (\(SE,EE,ED\))

  3. 6 $30 meals (\(SSE,SEE,SED,EED,EEE,EDD\))

  4. 8 $40 meals (\(SSEE,SSED,SEEE,SEED,SEDD,EEEE,EEED,EEDD\))

A generating function that produces the desired coefficients is:

\begin{equation*} (1+x+x^{2})(x+x^{2}+x^{3}+x^{4})(1+x+x^{2})=x^{8}+3x^{7}+6x^{6}+8x^{5}+8x^{4}+6x^{3}+3x^{2}+x \end{equation*}

Which fits with our intuition from what we have seen before in this chapter.

Now we arrive at our ultimate construction. What if we wished to know how many possible meals our diner could purchase if they were allowed to buy one of each item (not type) and we cared about the individual menu items selected (so an almond salad is not the same as a caesar). The generating function for this scenario is:

\begin{equation*} (1+x)^{2}(4x+6x^{2}+4x^{3}+x^4)(1+x)^{2} \end{equation*}

Let's dissect this function a bit. The diner has the option to purchase \(S_1\) or not purchase it. They also have the option to buy \(S_2\) or not purchase it. This gives us the first part of the function \((1+x)^{2}\text{.}\) Similarly, they have the same options with the dessert which gives us the last part of the function. The middle part handles the options for entrees. There are 4 ways to buy one entree, 6 possible ways to buy 2, 4 ways to buy 3, and only 1 way to buy all 4. Expanding this function, we arrive at:

\begin{equation*} x^{8}+8x^{7}+28x^{6}+56x^{5}+69x^{4}+52x^{3}+22x^{2}+4x \end{equation*}

So there are:

  1. 4 $10 meals

  2. 22 $20 meals

  3. 52 $30 meals

  4. 69 $40 meals

Problem 5.1.9.

Set up a generating function to count the number of ways to select five mp3's from a collection of 5 pre-baroque, 3 baroque, 4 classical, and 10 romantic works under the following conditions.

  1. No additional conditions

  2. Must select at least one of each genre

  3. Must select at least one pre-baroque and at least one romantic

  4. May not select more than two of any type

Solution.

No Restrictions: \((x^0 + x^1 + x^2 + x^3 + x^4 + x^5)(x^0 + x^1 + x^2 + x^3)(x^0 + x^1 + x^2 + x^3 + x^4)(x^0 + x^1 + x^2 + x^3 + x^4 + x^5 + x^6 + x^6 + x^7 + x^8 + x^9 + x^{10})\)

Must select one of each genre: \((x^1 + x^2 + x^3 + x^4 + x^5)(x^1 + x^2 + x^3)(x^1 + x^2 + x^3 + x^4)(x^1 + x^2 + x^3 + x^4 + x^5 + x^6 + x^6 + x^7 + x^8 + x^9 + x^{10})\)

One pre-baroque, one romatic at a minimum: \((x^1 + x^2 + x^3 + x^4 + x^5)(x^0 + x^1 + x^2 + x^3)(x^0 + x^1 + x^2 + x^3 + x^4)(x^1 + x^2 + x^3 + x^4 + x^5 + x^6 + x^6 + x^7 + x^8 + x^9 + x^{10})\)

Can select at most two of each type: \((x^0 + x^1 + x^2)(x^0 + x^1 + x^2)(x^0 + x^1 + x^2)(x^0 + x^1 + x^2)\)

Problem 5.1.10.

Set up a generating function to count the number of ways to select coins worth \(r\) cents from the following collections of coins.

  1. 10 pennies, 7 nickels, 5 dimes, and 3 quarters

  2. 7 nickels, 5 dimes, and 3 quarters

  3. unlimited pennies, 7 nickels, 5 dimes, and 3 quarters

  4. unlimited coins of all four types

Solution.

Selecting coins worth r cents:

10 pennies, 7 nickles, 5 dimes, and 3 quarters. \((1+x+x^2+x^3+...+x^9+x^{10})(1+x^5+x^{10}+x^{15}+...+x^{30}+x^{35})(1+x^{10}+x^{20}+x^{30}+x^{40}+x^{50})(1+x^{25}+x^{50}+x^{75})\)

7 nickles, 5 dimes, and 3 quarters. \((1+x^5+x^{10}+x^{15}+...+x^{30}+x^{35})(1+x^{10}+x^{20}+x^{30}+x^{40}+x^{50})(1+x^{25}+x^{50}+x^{75})\)

Unlimited pennies, 7 nickles, 5 dimes, and 3 quarters. \((1+x+x^2+x^3+...+x^r)(1+x^5+x^{10}+x^{15}+...+x^{30}+x^{35})(1+x^{10}+x^{20}+x^{30}+x^{40}+x^{50})(1+x^{25}+x^{50}+x^{75})\)

Unlimited coins of all four types. \((1+x+x^2+x^3+...+x^r)(1+x^5+x^{10}+x^{15}+...+x^{5 \cdot \lfloor r/5 \rfloor})(1+x^{10}+x^{20}+x^{30}+x^{10 \cdot \lfloor r/10 \rfloor})(1+x^{25}+x^{50}s+x^{75}+...+x^{25 \cdot \lfloor r/25 \rfloor})\)

Problem 5.1.11.

Set up a generating function to count the number of integer solutions to \(e_1+e_2+e_3+e_4=r\) under the following conditions.

  1. \(e_i \ge 0\text{.}\)

  2. \(e_i \ge 1\text{.}\)

  3. \(e_i \ge 0\text{,}\) \(e_1, e_3\) are odd values, and \(e_2, e_4\) are even values.

  4. \(\displaystyle -3 \le e_i \le 3\)

Solution.
  1. If \(e_i \ge 0\text{,}\) we use the generating function

    \begin{equation*} \left(\sum_{i=0}^r x^i\right)^4. \end{equation*}

  2. If \(e_i \ge 1\text{,}\) we use the generating function

    \begin{equation*} \left(\sum_{i=1}^r x^i\right)^4. \end{equation*}

  3. If \(e_1\) and \(e_3\) are odd, while \(e_2\) and \(e_4\) are even, we use the following generating function, where the odd-looking bounds on the summation indices ensure that we count no higher than necessary:

    \begin{equation*} \left(\sum_{i=0}^{\lfloor \frac{r-1}{2} \rfloor} x^{2i+1} \right)^2 \left(\sum_{i=0}^{\lfloor \frac{r}{2} \rfloor} x^{2i}\right)^2. \end{equation*}

  4. If \(-3 \le e_i \leq 3\text{,}\) then we use the generating function

    \begin{equation*} (x^{-3} + x^{-2} + x^{-1} + 1 + x + x^2 +x^3)^4. \end{equation*}

Subsection 5.1.2 Generating Function Simplification

Subsubsection 5.1.2.1 Polynomial Expansions

\begin{align*} \frac{1-x^{m+1}}{1-x} & = 1+x+x^2+\ldots+x^m.\\ \frac{1}{1-x} & = 1+x+x^2+\ldots\\ \frac{1}{(1-x)^n} & = \binom {0+n-1} 0 +\binom {1+n-1} 1 x +\binom {2+n-1} 2 x^2 + \ldots\\ (1+x)^n & = \binom n 0 + \binom n 1 x +\binom n 2 x^2 + \ldots + \binom n n x^n \end{align*}

If \(f(x)=a_0+a_1 x + a_2 x^2+ \ldots \) and \(g(x)=b_0+b_1 x + b_2 x^2 + \ldots\) then

\begin{align*} f(x)g(x)= & a_0b_0+ \\ & (a_1b_0+a_0b_1)x+ \\ & (a_2b_0+a_1b_1+a_0b_2)x^2+\\ & \vdots\\ & (a_rb_0+a_{r-1}b_1+\ldots+a_0b_r)x^r+\\ & \vdots \end{align*}

Subsubsection 5.1.2.2 Process

Problem 5.1.12.

Using the polynomial expansions provided produce expansions for the following rational expressions.

  1. \(\displaystyle (1+x^2)^n\)

  2. \(\displaystyle (1-x)^n\)

  3. \(\displaystyle \frac{1}{1+x^3}\)

  4. \(\displaystyle \frac{1}{(1+x^2)^n}\)

Problem 5.1.13.

Find the coefficient of the given term.

  1. \(x^3\) in \((1+x+x^2)^3\)

  2. \(x^3\) in \((1+x+x^2)^3(1+x)\)

  3. \(x^5\) in \((1+x)^3(x^2+x^3+x^4)\)

Solution.

\(x^3\) in \((1 + x + x^2)^3\)

\((1 + x + x^2)^3 = (\frac{(1 - x^3)}{(1 - x)})^3\text{.}\) We know this by reversing the polynomial expansion.

Let \(f(x) = (1 - x)^3\)

\(f(x) = \binom 3 0 - \binom 3 1 x + \binom 4 2 x^2 + \binom 5 3 x^3 + \binom 6 4 x^4 + \binom 7 5 x5 + \binom 8 6 x^6 + \binom 9 7 x^7 + \binom 10 8 x^8 + ...\)

Let \(g(x) = \frac{1}{(1 - x)^3}\)

\(g(x) = 1 + \binom 3 1 x + \binom 4 2 x^2 + \binom 5 3 x^3 + \binom 6 4 x^4 + ...\)

The coefficient of \(x^3 = a_3b_0 + a_2b_1 + a_1b_2 + a_0b_3\) where \(f(x) = a_0 + a_1x + a_2x^2 + \ldots\) and \(g(x) = b_0 + b_1x + b_2x^2 + \ldots\)

We substitute in the values to find that this equals \((-3)(1) + (0)(\binom 3 1) + (1)(\binom 4 2) + (1)(\binom 5 3)\)

\(= -3 + 0 + 6 + 10 = 13\)

The coefficient of \(x^3\) is 13.

Problem 5.1.14.

Find the coefficient of the given term.

  1. \(x^6\) in \(\left(\frac{1}{1-x^2}\right)^3\)

  2. \(x^{17}\) in \(\left(\frac{1}{1-x^2}\right)^3\)

  3. \(x^5\) in \(\frac{(1+x)^5}{(1-x)^3}\)

Solution.

Expanding the equation, we get

\begin{equation*} \left(\frac{1}{1-x^2}\right)^3= (1+ x^2 + x^4 + ...)^3 \end{equation*}

We are searching for the \(x^6\) term. There are 3 ways to select \(1 \cdot 1 \cdot x^6\text{,}\) 6 ways to select \(1 \cdot x^2 \cdot x^4\) and 1 way to select \(x^2 \cdot x^2 \cdot x^2\text{.}\) So, the coeeficent is 10.

The expansion only produces even powers, so the coefficent will be zero.

Expanding the equation using the earlier formula, we get

\begin{equation*} \frac{(1+x^5)^5}{(1-x)^3}= (1+5x+10x^2+10x^3+5x^4+x^5)(1+3x+6x^2+10x^3+15x^4+21x^5+\ldots) \end{equation*}

To get x^5, we can either choose \(x \cdot x^4\) (90 ways), \(x^2 \cdot x^3\) (160 ways) or \(1 \cdot x^5\) (22 ways). So, the coefficient is 272.

Problem 5.1.15.

Find the coefficient of the given term.

  1. \(x^{11}\) in \((x^3+x^4+x^5)^9\)

  2. \(x^7\) in \(\left(\frac{1-x^5}{1-x}\right)^7\)

  3. \(x^7\) in \((1+x+x^2+x^3+x^4)^7\)

Solution.

For the first part, clearly the coefficient on \(x^{11}\) is zero since the lowest power to have a nonzero coefficient in the expansion will be \(x^{27}\)

Alternatively, one can find the solution by finding the coefficients of several sub-products and using the formula presented in the text for finding a given coefficient. Since our interest is in the \(x^{7}\) term, only up to the 7th coefficient need ever be calculated in any product.

\begin{equation*} (1+x+x^{2}+x^{3}+x^{4})^{2}=1+2x+3x^{2}+4x^{3}+5x^{4}+4x^{5}+3x^{6}+2x^{7}+x^{8} \end{equation*}

multiplying that result by \(1+x+x^{2}+x^{3}+x^{4}\) we get:

\begin{equation*} 1+3x+6x^{2}+10x^{3}+15x^{4}+18x^{5}+19x^{6}+18x^{7}+\ldots \end{equation*}

squaring that we get:

\begin{equation*} 1+6x+21x^{2}+56x^{3}+126x^{4}+246x^{5}+426x^{6}+666x^{7}+\ldots \end{equation*}

then finally multiplying by \(1+x+x^{2}+x^{3}+x^{4}\) produces the desired result. We need only use the formula to find the coefficient for \(x^{7}\) in this case:

\begin{equation*} C_7=666\cdot1+426\cdot1+246\cdot1+126\cdot1+56\cdot1=1520 \end{equation*}

Which produces the same result!

Subsubsection 5.1.2.3 Problems

Problem 5.1.16.

You are painting 14 classrooms. You have enough green to paint at most 4 classrooms, enough blue to paint at most 5 classrooms, and an unlimited supply of white and beige paint. How many ways can the 14 (identical) classrooms be painted.

Solution.

Using what we already know, let's break the problem into pieces. We suspect that the white and beige classroom options can be represented by the product of the polynomials:

\begin{equation*} (1+x+x^2+\ldots+x^13+x^14)^2 \end{equation*}

The green paint options of the generating function is representated by:

\begin{equation*} (1+x+x^2+x^3+x^4) \end{equation*}

And finally the blue paint options:

\begin{equation*} (1+x+x^2+x^3+x^4+x^5) \end{equation*}

Which gives us our entire generating function:

\begin{equation*} (1+x+x^2+\ldots+x^13+x^14)^(1+x+x^2+x^3+x^4)(1+x+x^2+x^3+x^4+x^5) \end{equation*}

When expanded, this will be pretty big. So we would like to not work harder than we have to. Remember, we want to know how many possible options we have for painting 14 classrooms. So we are seeking the coefficient of \(x^14\) and need not calculate past the 14th coefficient for any subproduct we choose. We can see that the product of the white and beige portions of the generating function is quite easy to find:

\begin{equation*} 1+2x+3x^2+4x^3+5x^4+6x^5+7x^6+8x^7+9x^8+10x^9+11x^{10}+12x^{11}+13x^{12}+14x^{13}+15x^{14}+\ldots \end{equation*}

The product for the blue and green options is also quite simple:

\begin{equation*} 1+2x+3x^2+4x^3+5x^4+5x^5+4x^6+3x^7+2x^8+x^9 \end{equation*}

And we can find the coefficient on the \(x^{14}\) term of their product using the simple formula \(a_{14}b_0+a_{13}b_1+a_{12}b_2+...a_2b_{12}+a_1b_{13}+a_0b_{14}\text{.}\)

\begin{equation*} C_{14}=15 \cdot 1+14 \cdot 2+13 \cdot 3+12 \cdot 4+11 \cdot 5+10 \cdot 5+9 \cdot 4+8 \cdot 3+7 \cdot 2+6 \cdot 1=315 \end{equation*}

Which gives us our answer. There are 315 ways to paint 14 classroom given these paint options.

Problem 5.1.17.

How many ways can you select eight jelly beans from five types under the following conditions.

  1. You can select from two to four of each type.

  2. You must have at least one of each type.

  3. There are only two of types 1 to 3, three of type 4, and an unlimited number of type 5.

  4. There are an unlimited number of each type.

Solution.

Find the coefficient of \(x^8 in (x^2 + x^3 + x^4)^5\)

We are selecting 8 items so we are finding the \(x^8\) term. There are 5 groups so the generating function is to the fifth power. In each group, we have one way we can select 2, 3, or 4 items so we have \((x^2 + x^3 + x^4)\)

\(x^8\) has a coefficient of 0 because the least power is \((x^2)^5 = x^10\)

So, there are 0 ways to select 8 jelly beans when we select 2 to 4 of each type.

We use the same setup to find the coefficient of \(x^8 in (x + x^2 + x^3 + x^4)^5\)

This is because we are selecting 8 items so we find \(x^8\) power. We have 5 groups where the restrictions are the same, so the generating function is to the 5th power. We have 1 way we can select 1, 2, 3, or 4 items, which gives us the polynomial \(x + x^2 + x^3 + x^4\text{.}\)

Note that we can select up to 4 jelly beans from one group because if we chose 5, then we must select 3 more jelly beans from the remaining 4 groups. This means that one group is left without being chosen from.

Let's list the ways we can get \(x^8\) power. For each of the following ways to get \(x^8\) there are more ways achieved by reordering.

\(x \cdot x \cdot x \cdot x \cdot x^4\) produces 5 ways total.

\(x \cdot x \cdot x \cdot x^2 \cdot x^3\) produces 20 ways. Using the “ool” method, we have 3 dividers and 2 distinguishable items, so \(2 \cdot \frac{(2 + 3)!}{2! 3!} = 20 ways total.\)

\(x \cdot x \cdot x^2 \cdot x^2 \cdot x^2\) produces 10 ways. Using the "ool" method, we have 2 dividers and 3 indistinguishable items, so \(\frac{(3 + 2)!}{3! 2!} = 10 ways total.\)

There are no other ways to multiply the terms together to produce \(x^8th\) power. From the 3 items in the list, we have 5 + 20 + 10 = 35 total ways, so the coefficient of \(x^8\) is 35 and so the number of ways to select 8 jelly beans where we must select at least of each type is 35 ways.

Find the coefficient of \(x^8 in (1 + x + x^2)^3(1 + x + x^2 + x^3)(1 + x + x^2 + ...)\)

This is because we are selecting 8 items so we find \(x^8\) power. We have 3 groups that we can select 0, 1, and 2 items from 1 way, we have 1 group that we can select 0, 1, 2, or 3 items from 1 way, and we have 1 group where we can select as many items as we want 1 way each.

Using polyomial expansions, we can rewrite the generating fuction:

\((\frac{1 - x^3}{1 - x})^3 (\frac{1 - x^4}{1 - x}) (\frac{1}{1 - x})\)

This can again be rewritten:

\((\frac{1}{1 - x})^5 (1 - x^3)^3 (1 - x^4)\)

To find the coefficient of \(x^8\text{,}\) let's separate this into more managable pieces.

Let \(f(x) = (1 - x^3)^3 (1 - x^4)\)

Expand: \(f(x) = (1 - 2x^3 + x^6)(1 - x^3)(1 - x^4)\)

\(f(x) = (1 - 3x^3 + 3x^6 - x^9)(1 - x^4)\)

\(f(x) = 1 - 3x^3 - x^4 + 3x^6 + 3x^7 + ...\) (we only need to know up to the \(x^8\) power.)

Now let \(g(x) = \frac{1}{(1 - x)^5}\)

Using polynomial expansion again, \(g(x) = \binom 4 0 + \binom 5 1 x \binom 6 2 x^2 + \binom 7 3 x^3 + \binom 8 4 x^4 + \binom 9 5 x^5 + \binom 10 6 x^6 + \binom 11 7 x^7 + \binom 12 8 x^8 + \ldots\)

The coefficient of \(x^8 is a_8b_0 + a_7b_1 + a_6b_2 + a_5b_3 + a_4b_4 + a_3b_5 + a_2b_6 + a_1b_7 + a_0b_8\text{,}\) where \(f(x) = a_0 + a_1x = a_2x^2 + \ldots\) and \(g(x) = b_0 + b_1x = b_2x^2 + \ldots\)

Note that the values are 0 for a8, a5, a2, and a1.

Substitute the values from f(x) and g(x): \((3)(\binom 5 1) + (3)(\binom 6 2) + (-1)(\binom 8 4) + (-3)(\binom 9 5) + (1)(\binom 12 8)\)

\(= 15 + 180 - 70 - 378 + 495 = 242\)

The coefficient of \(x^8\) is 242, and so there are 242 ways to select 8 jelly beans with the restrictions above.

Find the coefficient of \(x^8 in (1 + x + x^2 + x^3 + ...)^5\)

This is because we are selecting 8 items so we find \(x^8th\) power. We have 5 groups where the restrictions are the same, so the generating function is to the 5th power. We can choose from 0 up to as many jelly beans as we would like, and there is 1 way to choose each number of jelly beans, so the polynomial is \(1 + x + x^2 + \ldots\)

Using polynomial expansion rules, the generating function can be rewritten:

\((\frac{1}{1 - x})^5 = \frac{1}{(1 - x)^5}\)

Again using polynomial expansion, this can be once more rewritten:

\(\binom 4 0 + \binom 5 1 x + \binom 6 2 x^2 + \binom 7 3 x^3 + \binom 8 4 x^4 + \binom 9 5 x^5 + \binom 10 6 x^6 + \binom 11 7 x^7 + \binom 12 8 x^8 + \ldots\)

See that the coefficient of \(x^8\) is \(\binom 12 8 = 495\text{.}\) Thus, the number of ways to select 8 jelly beans where we can select any number of each type is 495 ways.

Problem 5.1.18.

How many ways can six copies of Goethe's Faust, seven copies of Han's Christian Andersen's fairy tales, and eleven copies of Dumas' Le Comte Monte Christo be divided evenly between two people?

Subsection 5.1.3 Exponential Generating Functions

Definition 5.1.19. Exponential Generating Function.

A function is an exponential generating function if and only if \(g(x)=a_0+a_1\frac{x}{1!}+a_2\frac{x^2}{2!}+\ldots+a_n\frac{x^n}{n!}+\ldots\) and \(a_i\) is the number of arrangements of \(i\) items.

Subsubsection 5.1.3.1 Model

Problem 5.1.20.

Consider the following.

  1. Count the number of ways to arrange the letters “foot.”

  2. Count the number of ways to arrange the letters “foof.”

  3. Count the number of ways to arrange the letters “toot.”

  4. Add the previous three counts.

  5. Find the coefficient of \(x^4/4!\) in \((x^2/2!+x^3/3!+\ldots)(1+x/1!+x^2/2!+\ldots)(1+x/1!+x^2/2!+\ldots)\) Note the coefficient of \(x^4/4!\) in \(5x^4/4!\) is 5 and in \(x^4/3!\) it is 4.

Solution.

The word foot consists of 2 o's, 1 f, and 1 t. Since this is obviously a permutation of indistinguishable elements, there are:

\begin{equation*} \frac{4!}{2!}=12 \end{equation*}

ways of arranging the letters.

The word foof consists of 2 o's and 2 f's. Since this is obviously a permutation of indistinguishable elements, there are:

\begin{equation*} \frac{4!}{2!\cdot 2!}=6 \end{equation*}

ways of arranging the letters.

The word toot consists of 2 o's and 2 t's. Since this is obviously a permutation of indistinguishable elements, there are:

\begin{equation*} \frac{4!}{2!\cdot 2!}=6 \end{equation*}

ways of arranging the letters.

The sum of all these arrangements is \(12+6+6=24\) so it is implied that we are seeking this number when we try to use our new tool. Let's see what happens when we start taking some products and look for the coefficient on this new exponential generating function.

\begin{equation*} \left(\frac{x^2}{2!}+\frac{x^3}{3!}+\frac{x^4}{4!}+\cdots \right)\left(1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+\cdots \right)\left(1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+\cdots \right) \end{equation*}

We would prefer not to expand these polynomials into something very, very large. Fortunately, there are only a couple of products from these series that can result in an \(x^{4}\) term. The only ways to get a term of \(x^{4}\) is are any of the following products. Let's examine them and try to determine what they might mean:

  1. \(\frac{x^2}{2!} \cdot \frac{x^2}{2!} \cdot 1\) If we assume that the first series is the number of o's, the second is the number of f's and the third is the number of t's, then our previous experience with generating functions might lead us to believe that this product might give us the number of ways to arrange 2 o's, 2 f's, and 0 t's. \(\frac{x^2}{2!} \cdot \frac{x^2}{2!} \cdot 1 = \frac{x^4}{4} = \frac{6x^4}{4!}\) So the coefficient produced by this product is 6, which matches what we found for the arrangements of foof when we did it by other methods.

  2. \(\frac{x^2}{2!} \cdot 1 \cdot \frac{x^2}{2!}\) If we make the same assumptions, this should be the number of ways to arrange 2 o's, 0 f's, and 2 t's, which some quick calculations tells us is 6.

  3. \(\frac{x^2}{2!} \cdot x \cdot x\) Making the same assumptions yet again, we assume that this is the number of ways to arrange 2 o's, 1 f, and 1 t. \(\frac{x^2}{2!} \cdot x \cdot x = \frac{x^4}{2} = \frac{12x^4}{4!}\) Which matches what we found when we calculated the number of arrangements of letters foot using permutations of indistinguishable objects.

  4. \(\frac{x^3}{3!} \cdot x \cdot 1\) this should be 3 o's, 1 f, and 0 t's. This product is \(\frac{x^4}{6}=\frac{4x^4}{4!}\) Some quick work with permutations tells us that this matches the result of our assumption.

  5. \(\frac{x^3}{3!} \cdot 1 \cdot x\) this should be 3 o's, 0 f's, and 1 t. This product is \(\frac{x^4}{6}=\frac{4x^4}{4!}\) Some quick work with permutations tells us that this matches the result of our assumption.

  6. \(\frac{x^4}{4!} \cdot 1 \cdot 1\) this should be 4 o's, 0 f's, and 0 t's. Clearly the coefficient is 1 in this product and there is also only one way to arrange 4 o's

These results give us a coefficient on \(x^{4}\) of 33. Doing the permutations of indistinguishable elements on a pool of at least 2 o's and as many f's and t's as we wish yields 33 possible arrangements of letters:

  1. oooo

  2. ooof

  3. oofo

  4. ofoo

  5. fooo

  6. ooot

  7. ooto

  8. otoo

  9. tooo

  10. ooff

  11. offo

  12. ffoo

  13. fofo

  14. ofof

  15. foof

  16. oott

  17. otto

  18. ttoo

  19. toto

  20. otot

  21. toot

  22. ooft

  23. ofto

  24. ftoo

  25. foto

  26. ofot

  27. foot

  28. ootf

  29. otfo

  30. tfoo

  31. tofo

  32. otof

  33. toof

So we see that the exponential generating function has the ability to generate for us the number of permutations of indistinguishible elements without needing to resort to calculating the arrangements for each specific selection of items. We now have the power to conveniently calculate all the arrangements at once.

Subsubsection 5.1.3.2 Problems

Problem 5.1.21.

How many arrangements of five letters are there if there are at least two o's, and as many f's and t's as desired.

Solution.

This is the exponent on \(\frac{x^5}{5!}\) in generating function given in Problem 5.1.20. We can do a term-by-term expansion of that exponential generating function to find this coefficient. We also reveal a useful fact about such expansions in the process. We begin with the squared term, obtaining

\begin{align*} \amp\left(1+\frac{x}{1!}+\frac{x^2}{2!}+ \frac{x^3}{3!} + \frac{x^4}{4!} + \frac{x^5}{5!}\cdots\right)^2 =\\ \amp \quad \quad \quad \left(1+\frac{x}{1!}+\frac{x^2}{2!}+ \frac{x^3}{3!} + \frac{x^4}{4!} + \frac{x^5}{5!}+ \cdots \right) + \\ \amp \quad \quad \quad \left(\frac{x}{1!} + \frac{x^2}{1!} + \frac{x^3}{2!} + \frac{x^4}{3!} + \frac{x^5}{4!} + \cdots\right) + \\ \amp \quad \quad \quad \left(\frac{x^2}{2!} + \frac{x^3}{2!} + \frac{x^4}{2!2!} + \frac{x^5}{3!2!} + \cdots\right) + \\ \amp \quad \quad \quad \left(\frac{x^3}{3!} + \frac{x^4}{3!1!} + \frac{x^5}{3!2!} + \cdots \right) \end{align*}

When we gather the like terms here, we will multiply by the appropriate factors to obtain terms of the form \(x^k/k!\text{.}\) Note the resulting pattern:

\begin{align*} \left(1+\frac{x}{1!}+\frac{x^2}{2!}+ \frac{x^3}{3!} + \frac{x^4}{4!} + \frac{x^5}{5!}\cdots\right)^2 \\ = 1 + (1+1)\frac{x}{1!} + (1+2+1)\frac{x^2}{2!} \\ \amp\quad \quad + (1+3+3+1)\frac{x^3}{3!} \\ \amp\quad \quad+ (1+4+6+4+1)\frac{x^4}{4!} \\ \amp\quad \quad + (1+5+10+10+5+1)\frac{x^5}{5!} + \cdots \end{align*}

Each coefficient is the sum of the terms in a single row in Pascal's triangle. These rows sum to the powers of 2, so we finally obtain

\begin{equation*} \left(1+\frac{x}{1!}+\frac{x^2}{2!}+ \frac{x^3}{3!} + \frac{x^4}{4!} + \frac{x^5}{5!}\cdots\right)^2 = 1 + 2\frac{x}{1!} + 4\frac{x^2}{2!} + 8\frac{x^3}{3!} + 16\frac{x^4}{4!} + 32\frac{x^5}{5!} + \cdots \end{equation*}

We are now finally in a position to find the coefficient of \(x^5/5!\) in the original generating functions since it can now be written as the product:

\begin{equation*} \left(\frac{x^2}{2!}+\frac{x^3}{3!} + \frac{x^4}{4!} + \frac{x^5}{5!} + \cdots\right) \left(1 + 2\frac{x}{1!} + 4\frac{x^2}{2!} + 8\frac{x^3}{3!} + 16\frac{x^4}{4!} + 32\frac{x^5}{5!} + \cdots\right) \end{equation*}

We use the usual formula for finding a particular coefficient in the product of two polynomials. We obtain thereby that the coefficient on \(x^5\) is

\begin{equation*} 0 + 0 + \frac{8}{3!2!} + \frac{4}{2!3!} + \frac{2}{1!4!} + \frac{1}{5!1!} = \frac{80}{5!} + \frac{40}{5!} + \frac{10}{5!} + \frac{1}{5!} = \frac{131}{5!}. \end{equation*}

Therefore, the coefficient on \(x^5/5!\) is 131.

Problem 5.1.22.

Set up an exponential generating function to count the number of arrangements of \(k\) bicycles under the condition there must be at least 2 Specialized, at least 3 Canondale, and there are an unrestricted number of Bianchi and Trek bikes.

Solution.
\begin{equation*} (\frac{x^2}{2!}+\frac{x^3}{3!}+\frac{x^4}{4!}+\ldots)(\frac{x^3}{3!}+\frac{x^4}{4!}+\frac{x^5}{5!}+\ldots)(\frac{x^0}{0!}+\frac{x}{1!}+\frac{x^2}{2!}+\ldots)^2 \end{equation*}
Problem 5.1.23.

Set up an exponential generating function to count the number of arrangements of \(k\) pieces of art if there must be at least one metal sculpture, at least two paintings, at least two ceramic works, and an unrestricted number of digital works.

Problem 5.1.24.

Find the specified coefficients of the generating function below which counts arrangements of the letters “abcd” with restrictions.

\(\displaystyle (1+\frac{x}{1!}+\frac{x^2}{2!}) \\ (1+\frac{x^2}{2!}+\frac{x^4}{4!}) \\ (\frac{x}{1!}+\frac{x^3}{3!}) \\ (1+\frac{x}{1!}+\frac{x^2}{2!}+\frac{x^3}{3!}+\frac{x^4}{4!}) = \\ x+2x^2+\frac{8}{3}x^3+\frac{5}{2}x^4+\frac{23}{12}x^5+\frac{83}{72}x^6+\frac{7}{12}x^7+\frac{35}{144}x^8+\frac{49}{576}x^9+\frac{41}{1728}x^{10}+\frac{5}{864}x^{11}+\frac{1}{1152}x^{12}+\frac{1}{6912}x^{13}\text{.}\)

  1. Coefficient of \(x^2/2!\)

  2. Coefficient of \(x^3/3!\)

  3. Coefficient of \(x^5/5!\)

  4. Coefficient of \(x^8/8!\)

  5. What are the restrictions on the letters? You can suppose the exponential generating function was constructed in the order a,b,c,d.

Solution.
\begin{equation*} 2x^2 =\frac{2}{2} \cdot 2x^2=\frac{4x^2}{2!} \end{equation*}

so the ccoeffient is 4.

\begin{equation*} \frac{8x^3}{3} =\frac{8x^3}{3} \cdot \frac{2}{2}=\frac{16x^3}{3!} \end{equation*}

so the ccoeffient is 16.

\begin{equation*} \frac{23x^5}{12}= \frac{23x^5}{4 \cdot 3} \cdot \frac{10}{5 \cdot 2}=\frac{230x^5}{5!} \end{equation*}

so the ccoeffient is 230.

\begin{equation*} \frac{35x^8}{144}=\frac{35x^8}{8 \cdot 6 \cdot 3} \cdot \frac{420}{7 \cdot 5 \cdot 4 \cdot 2}=\frac{2100x^8}{8!} \end{equation*}

so the ccoeffient is 2100.

We may pick between zero, one, or two a's, zero, two, or 4 b's, one or three c's and between zero and four d's.