So, our class teacher asked us if we could find the number of cases if a die is thrown 4 times, such that the sum of the four faces appears to be 16. One of my classmates stood and told him that all we had to do was to find the coefficient of $x^{16}$. in the expansion of $(x+x^2+x^3+x^4+x^5+x^6)^4$. The teacher agreed. I cannot see how that person got that result. Can anybody please explain?
-
Just think about it. To make it clearer, suppose the desired total was $4$, not $16$. How can you get $x^4$ out of that expression? Now think about a total of $5$. – lulu Jan 15 '25 at 11:47
-
As another way to gain intuition, try it for $2$ dice. Expand $(x+x^2+x^3+x^4+x^5+x^6)^2$ and convince yourself that the coefficients count the ways to get the various sums. – lulu Jan 15 '25 at 12:05
-
This is an example of a generating function. For more information about generating functions in general, you can find many resources in the answers to this question: https://math.stackexchange.com/questions/3142386/how-can-i-learn-about-generating-functions – awkward Jan 15 '25 at 13:13
-
1Your title is meaningless. Please try to make the titles of your questions more informative. For example, Why does $a<b$ imply $a+c<b+c$? is much more useful for other users than A question about inequality. See also the section on titles in How to ask a good question. (The part entitled "Make your title your question" is especially relevant to this.) – Martin Brandenburg Jan 15 '25 at 13:46
3 Answers
What your teacher and classmate are doing is, in effect, abusing polynomials for profit, also known as a "generating function".
The easiest way to understand why this works is to think about what multiplying a polynomial by a polynomial does. When we multiply two polynomials together, what happens is that we multiply every term in one polynomial by each term in the other polynomial. All these polynomials are powers of $x$, and as such, we can take advantage of a the power law $x^ax^b=x^{a+b}$. This means that, say, $x^2\times x^3=x^5$. As we go through multiplying all these terms, some of the terms will have the same exponent. If we collect like powers together, we end up with each power term having a coefficient that represent the number of ways these term's exponents add together to that specific sum.
Let's start with a simple example, and calculate out $(x+x^2+x^3+x^4+x^5+x^6)^2$:
| Term 1\Term 2 | $x+$ | $x^2+$ | $x^3+$ | $x^4+$ | $x^5+$ | $x^6$ |
|---|---|---|---|---|---|---|
| $x+$ | $x^2$ | $x^3$ | $x^4$ | $x^5$ | $x^6$ | $x^7$ |
| $x^2+$ | $x^3$ | $x^4$ | $x^5$ | $x^6$ | $x^7$ | $x^8$ |
| $x^3+$ | $x^4$ | $x^5$ | $x^6$ | $x^7$ | $x^8$ | $x^9$ |
| $x^4+$ | $x^5$ | $x^6$ | $x^7$ | $x^8$ | $x^9$ | $x^{10}$ |
| $x^5+$ | $x^6$ | $x^7$ | $x^8$ | $x^9$ | $x^{10}$ | $x^{11}$ |
| $x^6$ | $x^7$ | $x^8$ | $x^9$ | $x^{10}$ | $x^{11}$ | $x^{12}$ |
This table, you might note, looks suspiciously like the table of the sum of two dice. If we add all these results together, we get $x^2+2x^3+3x^4+4x^5+5x^6+6x^7+5x^8+4x^9+3x^{10}+2x^{11}+x^{12}$, which ends up with the coefficient of each power of $x$ equalling the number of ways two dice can sum up to that power.
You can keep multiplying this by $(x+x^2+x^3+x^4+x^5+x^6)$, and each time you'll end up with coefficients of each power equalling the number of ways that many dice sum to that power. You might be asking "but what does $x$ equal?" and the answer is that it doesn't equal anything - we're using the structure of polynomials to generate the answers we're looking for. $x$ could be anything because it's the powers and coefficients we care about.
In effect, we are using power laws and the distributivity of multiplication to generate what we're looking for, very simply, without anything more than complex than addition and multiplication. Well, okay, very simple, but very monotonous - you're still doing a lot of calculation to get this. But fortunately, we have computer systems that can do this for us very quickly! Which is why these kinds of generating functions have become so useful in our modern age - we have automated brains that can do the repetitive work for us!
Look at what happens when you expand a formula like: $$(a^1 + a^2 + a^3)(b^1 + b^2 + b^3) = a^1b^1 + a^1b^2 + a^1b^3 + a^2b^1 + a^2b^2 + a^2b^3 + a^3b^1 + a^3b^2 + a^3b^3$$
The expansion shows you every possible combination of $a^1, a^2, a^3$ paired with $b^1, b^2, b^3$, and all the pairs are added together.
So if you had three dice and you wanted to see a list of all the outcomes, you could expand $$(a^1 + a^2+a^3 + a^4 + a^5 + a^6) (b^1 + b^2+b^3 + b^4 + b^5 + b^6)(c^1 + c^2+c^3 + c^4 + c^5 + c^6).$$ You'd get a sum with $6\times 6\times 6 = 216$ terms, one for each possible outcome. For example, one of those terms will be $a^5b^1c^4$, corresponding to rolling 5 on the first die, 1 on the second, and 4 on the third.
What if you just wanted to count how many outcomes had dice that added up to 10? You would search for all the terms where the exponents added up to 10. For example, $a^5b^1c^4$ is one of those outcomes, because 5+1+4=10. This might involve a lot of annoying manual work because you have 216 outcomes to check. Can we do it any easier?
So far, we've been using $a$ for the first die, $b$ for the second die, and $c$ for the third. What if we used the same variable $x$ for all three dice? Like this: $$(x^1 + x^2+x^3 + x^4 + x^5 + x^6) (x^1 + x^2+x^3 + x^4 + x^5 + x^6)(x^1 + x^2+x^3 + x^4 + x^5 + x^6)$$
Then instead of a term like $a^5b^1c^4$, we would have a term $x^5\cdot x^1 \cdot x^4$, which will simplify to $x^{10}$.
And in fact, you can see that each of the 216 outcomes will be a monomial $x^n$ where $n$ is the sum of the numbers on the three dice; and so each outcome where the dice sum to 10 will end up as the monomial $x^{10}$.
Therefore, if we want to count the number of outcomes where the dice sum to 10, we have to see how many times $x^{10}$ occurs in the 216 terms from the expansion: $$(x^1 + x^2+x^3 + x^4 + x^5 + x^6) (x^1 + x^2+x^3 + x^4 + x^5 + x^6)(x^1 + x^2+x^3 + x^4 + x^5 + x^6) \\= \ldots\ldots + x^{10} + \ldots\ldots + x^{10} + \ldots\ldots$$
But of course if $x^{10}$ occurs multiple times, then when we simply this expanded expression, those like terms will combine. Just like when you have $y^2 + y^1 + y^2 + y^7 + y^2$, you can simplify it as $y^1 + 3y^2 + y^7$, and the $3$ tells you that there were three $y^2$ terms in the original expression.
If you expand $$(x^1 + x^2+x^3 + x^4 + x^5 + x^6) (x^1 + x^2+x^3 + x^4 + x^5 + x^6)(x^1 + x^2+x^3 + x^4 + x^5 + x^6)$$ and combine like terms together, the final coefficient on the $x^{10}$ term will count the number of times $x^{10}$ occurs in the expansion, which corresponds to the number of outcomes of throwing the three dice such that their sum is 10.
In your original problem, you're throwing four dice, so the expression you're expanding is $$(x^1 + x^2+x^3 + x^4 + x^5 + x^6)(x^1 + x^2+x^3 + x^4 + x^5 + x^6)(x^1 + x^2+x^3 + x^4 + x^5 + x^6)(x^1 + x^2+x^3 + x^4 + x^5 + x^6)$$ And you want to count how many outcomes have dice that add up to 16, so you'll check the coefficient on the $x^{16}$ term.
- 19,274
Alternative explanation.
You are interested in enumerating the number of solutions to
$y_1 + y_2 + y_3 + y_4 = 16.$
$y_1, ~y_2, ~y_3, ~y_4 \in \{1,2,3,4,5,6\}.$
Now consider the following tableau that represents the multiplication of four factors:
( x + x^2 + x^3 + x^4 + x^5 + x^6 ) :: Factor-1
( x + x^2 + x^3 + x^4 + x^5 + x^6 ) :: Factor-2
( x + x^2 + x^3 + x^4 + x^5 + x^6 ) :: Factor-3
( x + x^2 + x^3 + x^4 + x^5 + x^6 ) :: Factor-4
This multiplication actually represents $~6^4~$ unconsolidated terms, because with each of the $~4~$ factors, you have $~6~$ choices for which term will be used.
For any one of the $~6^4~$ unconsolidated terms, which has $~4~$ factors, let $~y_i~$ denote the term used from Factor-i. For example, if you used $~x^5~$ from Factor-1, $~x^3~$ from Factor-2, $~x^2~$ from Factor-3, and $~x^5~$ from Factor-4, then two things would happen:
The specific term would be $~x^5 \times x^3 \times x^2 \times x^5 = x^{15}.$
$y_1 = 5, ~y_2 = 3, ~y_3 = 2, ~y_4 = 5 \implies y_1 + y_2 + y_3 + y_4 = 15.$
Notice that when the terms are consolidated (i.e. grouped by common final exponent), the coefficient of the (consolidated) term $~x^{16}~$ will equal the number of unconsolidated terms (out of the $~6^4~$ possible terms) that resulted in $~x^{16}.~$
Notice also that an unconsolidated term will result in $~x^{16},~$ if and only if, for that specific unconsolidated term, you have that $~y_1 + y_2 + y_3 + y_4 = 16.$
Therefore, the number of the $~6^4~$ unconsolidated terms that result in the product $~x^{16}~$ will exactly equal the number of satisfying solutions to the enumeration problem given at the start of this answer.
Further, the number of $~6^4~$ unconsolidated terms that result in the product $~x^{16}~$ will exactly equal the coefficient assigned to the consolidated term $~x^{16}.$
- 42,303
- 3
- 21
- 46