Dice Problems With Generating Function Solutions
Dice Problems With Generating Function Solutions
Preliminaries
Generating functions for dice games are usually rational functions
(ratios of polynomials). To deal with rational functions, only a handful of
skills are necessary. The first is polynomial arithmetic. The addition of
polynomials goes term by term so, for instance,
(4 + z2) + (8 − 8z + 2z2 − 2z3) + (2z − 4z2 + 2z3) = 12 − 6z − z2.
The multiplication of polynomials coincides with the so-called discrete
convolution of sequences: the coefficient of each term in the product is the
sum of the products of coefficients whose powers add up to the power of the
given term. For instance,
(1 − z)2 × (4 + z2) = 4 − 8z + 5z2 − 2z3 + z4.
132 THE MATHEMATICAL GAZETTE
z z2 z3 1
1 + + + + …= .
2 4 8 1 − 2z
1 z z2 z3
More generally, = 1 + + + + …. One easy-but-useful
1 − rz r r2 r3
observation about this geometric series is that if |r| > 1, then the
coefficients of the terms in this series go to zero exponentially fast. For
example, the rational function
4 − z 3 1
= −
2 − 3z + z2 1 − z 1 − 12 z
has the series expansion
∑ (3 − 2−n) zn,
n≥0
but the coefficients of this series approach 3 since 2−n goes to 0
exponentially fast. The main observation that we use in first-order
approximations here is the following. If a root of the denominator of a term
of the decomposition of a rational function in partial fractions is greater than
1 in absolute value, then we can ignore this term completely since, like 2−n
in the previous example, the coefficients go to 0 (see, for instance, Theorem
IV.9 of [1] for an exact expansion of rational functions).
1
A series related to the geometric series is . This series can be
(1 − z)2
thought of as either the square of the geometric series (with the product
following the discrete convolution) or as the derivative of the geometric
series. In any case, the coefficient of the zn term is n + 1, so that
1
(1 − z)2
= ∑ (n + 1) zn, for |z| < 1.
n≥0
Landing on Mayfair
Getting an exact expression for the probability of rolling dice and
obtaining a particular sum is a thorny problem. Exact expressions for this
probability exist, but they are so complicated that they cloud the big picture.
NOTES 133
roots of the quintic Q (z) are difficult to obtain exactly, but they are easy to
approximate with the following proposition, which is a corollary of the so-
called Eneström-Kakeya theorem (see exercises 1 and 2 following theorem
(30,2) in [2]).
Proof: Consider a path in the complex plane consisting of the line segments
joining successively a0, a1z, … , anzn and suppose |
ak + 1zk + 1
ak zk |> 1 for each
k . Then the exterior angles at all vertices are congruent (to arg z) and the
path must spiral out. So, z cannot be a root. Therefore, if z is a root, this
ak ak
inequality must fail for some k , in which case |z| ≤ ≤ max .
ak + 1 ak + 1
ak
Similarly, min ≤ |z| for any root z.
ak + 1
intuitive sense since the probability coincides with the reciprocal of the
average value of a roll (which also coincides with Roll ′ (1)). The exact
636548506161891666510055438417
probability of landing on Mayfair is ,
2227915756473955677973140996096
which is less than 10−6 off the approximation.
Of course, most people play Monopoly with a pair of dice, rather than a
single die. This has a minimal effect on our calculations. Instead of the
generating function Roll (z) = 16 z + 16 z2 + 16 z3 + 16 z4 + 16 z5 + 16 z6 for a
single die, the generating function for a pair of dice is the same as the
generating function for the sum of two dice (Roll (z))2, as calculated above.
Therefore, the probability of landing on Mayfair when rolling a pair of dice
1
is the coefficient of z39 in . A partial fractions decomposition
1 − (Roll (z))2
NOTES 135
Passing Go
In the game of Monopoly, players collect a salary of £200 as they pass
Go, which is forty sites from the start. A similar problem is calculating the
expected number of rolls to pass Go and collect the salary. Let en denote the
expected number of rolls needed to land on or first pass the n th site on the
game board. This is equivalent to the expected number of rolls to obtain or
first exceed sum n. As a first guess, one would suspect en would be close to
n divided by the average value of a roll. The initial values are en = 0 for
n ≤ 0, and by taking conditions on the first roll
Let E1 (z) denote the generating function of this sequence ∑ enzn when
rolling a single die. The generating function equivalent of this recurrence
relation involves a geometric series with unit ratio and unit initial term, as
z
well as the discrete convolution. So, E1 (z) = + E1 (z) Roll (z) and it
1 − z
z
follows that E1 (z) = . Again, the generating
(1 − z) (1 − Roll (z))
function is rational, and it has a partial fractions decomposition of the form
2 4
?
E1 (z) = 7
+ 21
+ .
(1 − z)2 1 − z Q (z)
The expected number of rolls to pass Go is the coefficient of z40 in E1 (z). As
1
noted in the preliminaries, the coefficient of the n th term of is
(1 − z)2
1
n + 1, the coefficient of the n th term of is 1, and the coefficients of
1 − z
?
go to zero. Therefore, en ≈ 27 (n + 1) + 21 4
. In other words, the
Q (z)
expected number of rolls to reach sum n with a single die exceeds n divided
by the average roll by about 10 21 . For passing Go with n = 40, the
136 THE MATHEMATICAL GAZETTE
−6
approximation of 250 21 turns out to be within 10 of the exact expected
number of rolls.
If a player rolls a pair of dice, the generating function for the sequence
of expected number of rolls to pass a sum would be
z
E2 (z) = .
(1 − z) (1 − (Roll (z))2)
This has a partial fractions decomposition of the form
1 29
? ?
E2 (z) = 7
+ 84
+ + .
(1 − z)2 1 − z Q (z) 1 + Roll (z)
As before, we can ignore the terms with Q (z) and 1 + Roll (z) which go to
zero, and so the expected number of rolls to reach sum n with a pair of dice
is en ≈ 17 (n + 1) + 29 521
84 . This time, the approximation of 84 turns out to be
−4
within 10 of the exact expected number of rolls to pass Go with a pair of
dice.
Further problems
There are many variations of these dice problems. For an example of a
generalisation, you can show that if Roll (z) is the generating function for a
weighted die (as opposed to a fair die), then the probability of obtaining the
1
sum n is approximately . Actually, this approximation is a finite
Roll ′ (1)
version of a theorem of Erdös, Feller and Pollard; see [3]. Likewise, the
expected number of rolls needed to obtain or exceed sum n is approximately
n Roll ″ (1)
+ .
Roll ′ (1) 2 (Roll ′ (1))2
In truth, the collection of dice problems is seemingly endless. (For an
example of a large compilation with solutions, see [4].) Almost all of these
problems can be solved, almost mechanically, with generating functions. If
you find these generating functions intriguing, please read [5] and [6] for
wonderful accounts.
References
1. P. Flajolet and R. Sedgewick, Analytic combinatorics, Cambridge
University Press (2009).
2. M. Marden, Geometry of polynomials, Amer. Math. Soc. (1949).
3. P. Erdös, W. Feller and H. Pollard, A property of power series with
positive coefficients, Bull. of the Amer. Math. Soc., 55(2) (1949)
pp. 201-204.
4. Matthew M. Conroy, A collection of dice problems, available at:
http://www.madandmoonly.com/doctormatt/mathematics/dice1.pdf