\section{Dice}

\definition{}
A \textit{die} is a device that randomly selects a positive integer from
a finite list of options. For example, the standard 6-sided die selects a value from
$[1,2,3,4,5,6]$. We may have many sides with the same value, as in $[1, 1, 2, 3]$.

To describe a die with a generating function, let $a_k$ be the number of times
$k$ appears as a side of the die and consider $a_0 + a_1x + x_2x^2 + ... $. \par
A die has a finite number of sides, so this will be a regular polynomial.

\problem{}
What is the generating function of the standard 6-sided die?

\begin{solution}
	$x + x^2 + x^3 + x^4 + x^5 + x^6$
\end{solution}

\vfill

\problem{}
What is the generating function of the die with sides $[1, 2, 3, 5]$?

\begin{solution}
	$2x + x^2 + x^3 + x^5$
\end{solution}

\vfill

\problem{}
Let $A(x)$ and $B(x)$ be the generating functions of two dice. \par
What is the significance of $A(1)$?
\begin{solution}
	$A(1) = $ the number of sides on the die
\end{solution}

\vfill

\problem{}
Using formulas we found earlier, show that the $k^\text{th}$ coefficient
of $A(x)B(x)$ is the number of ways to roll $k$ as the sum of the two dice.
\begin{solution}
	The $k^\text{th}$ coefficient of $A(x)B(x)$ is...

	\begin{align*}
		a_0b_k + a_1b_{k+1} + ... + a_kb_0 \\
		&=~ \text{count}(A = 0; B = k) + ... + \text{count}(A = k; B = 0) \\
		&=~ \text{number of ways} A + B = k
	\end{align*}
\end{solution}


\vfill
\pagebreak

\problem{}
Find a generating function for the sequence $c_0, c_1, ...$, where $c_k$ is
the probability that the sum of the two dice is $k$.
\begin{solution}

	\begin{equation*}
		c_k
		= \frac{\text{number of ways sum} = k}{\text{number of total outcomes}}
		= \frac{\text{number of ways sum} = k}{A(1)B(1)}
	\end{equation*}

	So,

	\begin{equation*}
		c_0 + c_1x + c_2x^2 =
		\frac{A(x)B(x)}{A(1)B(1)}
	\end{equation*}
\end{solution}

\vfill

\problem{}
Using generating functions, find two six-sided dice whose sum has the same
distribution as the sum of two standard six-sided dice? \par

That is, for any integer $k$, the number if ways that the sum of the two
nonstandard dice rolls as $k$ is equal to the number of ways the sum of
two standard dice rolls as $k$.
\hint{factor polynomials.}
\begin{solution}
	We need a different factorization of

	\begin{equation*}
		(x + x^2 + x^3 + x^4 + x^5 + x^6)^2 = A(x)B(x)
	\end{equation*}

	We can use

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


\vfill
\pagebreak