\documentclass[11pt]{article}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{multicol}
\usepackage{latexsym}
\usepackage{verbatim}
\usepackage[pdftex]{graphicx}
\usepackage{wasysym}
\usepackage{url}
\usepackage{mathrsfs}
\usepackage{hyperref}

\hypersetup{colorlinks=true}
\setlength{\oddsidemargin}{.25in}
\setlength{\evensidemargin}{.25in}
\setlength{\textwidth}{6in}
\setlength{\topmargin}{-0.4in}
\setlength{\textheight}{8.5in}

\usepackage{tikz}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
            \node[shape=circle,draw,inner sep=2pt] (char) {#1};}}

\input{preamble.tex}

\begin{document}

\lecture{10: Generating Functions}{Week 10}


\section{Generating Functions}

\subsection{Power series: a crash course/refresher.}
If you've taken Calculus BC or an equivalent class in high school, you've probably ran into \textbf{power series} before.  In case you haven't, here's a quick definition:

\begin{defn}
Suppose we have a sequence $\{a_n\}_{n=0}^\infty = (a_0, a_1, a_2, \ldots)$ of numbers.  We can form the \textbf{formal power series} associated to this sequence as follows:
\begin{align*}
A(x) = \sum_{n=0}^\infty a_n x^n.
\end{align*}

By a formal power series, we simply mean that we are considering this object above not as something that is a function of $x$, but rather as a collection of convenient placeholders to index our values $a_1, a_2, a_3, \ldots $ with.  In other words, we're usually not going to worry about ``plugging in values for $x$;'' instead, we're going to take this object and just pretend that all of the $x^i$'s are placeholders that allow us to tell $a_1$ and $a_2$ and $a_3$ and so on apart.

Given a formal power series, we can manipulate it in various ways!  For example, we can scale it by a number:
\begin{align*}
c \cdot A(x) = \sum_{n=0}^\infty c \cdot a_n x^n.
\end{align*}
We can add two formal power series:
\begin{align*}
A(x) &= \sum_{n=0}^\infty a_n x^n, B(x) = \sum_{n=0}^\infty b_n x^n\\
\Rightarrow \quad A(x) + B(x) &= \sum_{n=0}^\infty (a_n+ b_n) x^n.
\end{align*}
We can define a formal notion of ``derivative,'' where we replace each $x^n$ with $nx^{n-1}$:
\begin{align*}
\frac{d}{dx} A(x) = \sum_{n=1}^\infty a_n \cdot n x^{n-1} = \sum_{n=0}^\infty (n+1)a_{n+1} x^n. 
\end{align*}
We can also take the product of two formal power series!  This is a little more involved: to calculate the power series that is equal to
\begin{align*}
\left(\sum_{n=0}^\infty a_n x^n \right)\cdot \left(\sum_{n=0}^\infty b_n x^n\right),\\
\end{align*}
we basically need to do the same process that we used to FOIL polynomials when we were younger!  In other words, we need to take every term on the left, and multiply each one of those by every term on the right.  Because there are infinitely many, this might seem awful to write down; so, to help, let's try to restrict ourselves to a somewhat easier problem.  Suppose we want to calculate our product, but we are just trying to figure out how many $x^m$'s we get on the right-hand side, for some fixed value $m$.  How does this work?

Well: let's go through the product $\left(\sum_{n=0}^\infty a_n x^n \right)\cdot \left(\sum_{n=0}^\infty b_n x^n\right)$ term-by-term.  If we just look at the $a_0 x^0$ term from the left part, we can see that we'll have to multiply this by the $b_mx^m$ term from the right part to get a $x^m$.  Similarly, if we look at $a_1 x^1$, we'll need to multiply this by $b_{m-1} x^{m-1}$ from the right to get to $x^m$; in general, if we're looking at the $a_k x^k$ term on the left, we need to multiply it by $b_{m-k}x^{m-k}$ to have the result be a multiple of $x^m$.

Therefore, if we're trying to find \textbf{all} of the $x^m$'s, we're actually just calculating the sum
\begin{align*}
\left(\sum_{k=0}^m a_k b_{m-k}\right) x^m.
\end{align*}

But if we know the coefficients of each $x^m$ for every $m$, that gives us all of the terms in our product!  In other words, we've shown the following:

\begin{align*}
\left(\sum_{n=0}^\infty a_n x^n \right)\cdot \left(\sum_{n=0}^\infty b_n x^n\right) = \sum_{n=0}^\infty \left( \sum_{k=0}^n a_k b_{n-k} \right)x^n 
\end{align*}
So we can multiply power series as well!

In general, we say that two formal power series are equal if and only if each term is equal: i.e. $\left(\sum_{n=0}^\infty a_n x^n \right) =  \left(\sum_{n=0}^\infty b_n x^n\right)$ if and only if $a_n = b_n$ for all $n$.
\end{defn}


So: if you've seen power series before, you may remember that most of the times where they come up, they've been objects where you've used your knowledge about how \textbf{sequences} work to study them!  In other words, your proofs have probably looked like the following:
\begin{align*}
\Bigg(\textrm{knowledge of }\{a_n\}_{n=1}^\infty \Bigg) \Rightarrow \left(\textrm{knowledge of } \sum_{n=1}^\infty a_nx^n\right).
\end{align*}
We typically do this in calculus classes because, usually, we understand sequences \textit{better} than we understood power series.  However, this is not necessarily true!  Given enough time in calculus/analysis classes, you will develop a lot of intuition for power series and Taylor series.  Given this,  it is perhaps natural to ask if we can \textbf{reverse} the method described above.  In other words: suppose that we have a sequence that we want to study.  What if we turned it into a power series, and used our knowledge of how that power series works to answer questions about the original series?  I.e. can we make proofs that look like
\begin{align*}
 \left(\textrm{knowledge of } \sum_{n=1}^\infty a_nx^n\right) \Rightarrow\Bigg(\textrm{knowledge of }\{a_n\}_{n=1}^\infty \Bigg)  ?
\end{align*}

The answer to this question is a resounding \textbf{yes}!  In mathematics, this process is called the method of \textbf{generating functions}.  This works as follows:
\begin{itemize}
\item Take some sequence $\{a_n\}_{n=1}^\infty$ that you want to study.
\item Look at the associated power series $\sum_{n=1}^\infty a_nx^n$.
\item Find a nice closed form (i.e. like $\sum_{n=0}^\infty x^n = \frac{1}{1-x}$) for this power series, using algebra/our operations on power series / clever identities from calculus /etc.
\item Use this closed form somehow to regain information about your original sequence.  I.e. your closed form may have a different expansion that you can figure out, via Taylor series: therefore, because power series are unique, you know that the terms in this different expansion have to be equal to the terms  $\sum_{n=1}^\infty a_nx^n$ in your original expansion!  In other words, you've found new information about your sequence $\{a_n\}_{n=1}^\infty$!
\end{itemize}

We illustrate this with an example that you may have seen before:
\subsection{Fibonacci numbers.}

\begin{defn}
The \textbf{Fibonacci sequence} is the following sequence of numbers, defined as follows:
\begin{itemize}
\item Base cases: $f_0 = 0$ and $f_1 = 1$.
\item Recursive definition: for any $n \geq 2$, we define $f_n = f_{n-1} + f_{n-2}$.
\end{itemize}
\begin{align*}
\end{align*}
So, for example, the first nine entries of the  Fibonacci sequence are the following:
\begin{align*}
0,1,1,2,3,5,8,13,21,34,55, 89, \ldots
\end{align*}
We let $f_n$, the $n$-th Fibonacci number, be the $n$-th element of this sequence.
\end{defn}

As defined, it is reasonably difficult to calculate these numbers.  I.e. to find $f_{1000}$, we need to find the Fibonacci numbers $f_{999}, f_{998}$, for which we also need the Fibonacci number $f_{997}$, for which we need the next Fibonacci number $f_{996}$\ldots all the way down to $f_1, f_0$.  In other words, we have to find \textbf{all} of the Fibonacci numbers from 1 to 999 to find $f_{1000}$. 

This seems\ldots wasteful!  I.e.\ if all we care about is $f_{1000}$, it seems somewhat silly to have to calculate every number along the way to get to $f_{1000}$.  This is certainly not how we work with other arithmetical operations; that is, to calculate $1000\cdot x$, we don't need to calculate $n \cdot x$ for every value of $n$ between 1 and 999 first!

Therefore, a natural question to ask here is the following:\ can we find a \textbf{closed form} for these numbers $f_n$?  In other words, can we a way of calculating $f_n$ without having to find $f_{n-1}$ and $f_{n-2}$?


\noindent\textbf{Answer:}  Yes!  Specifically, we can do this with \textbf{generating functions}!  

To start, let's look at the power series
\begin{align*}
\sum_{n=0}^\infty f_nx^n.
\end{align*}

The only thing we know about the constants $f_n$, at first, is their recurrence relation $f_{n} = f_{n-1} + f_{n-2}.$  So: let's plug that in to our power series!  Specifically, let's plug that into all of the terms $f_n$ with $n \geq 2$, as those are the terms where this recurrence relation holds:
\begin{align*}
\sum_{n=0}^\infty f_nx^n &= f_0 \cdot x^0 + f_1 \cdot x^2 + \sum_{n=2}^\infty f_n x^n\\
&= 0 + x + \sum_{n=2}^\infty (f_{n-1} + f_{n-2}) x^n \\
&= x + \sum_{n=2}^\infty f_{n-1}x^n + \sum_{n=2}^\infty f_{n-2}x^n\\
&= x + x\sum_{n=2}^\infty f_{n-1}x^{n-1} + x^2\sum_{n=2}^\infty f_{n-2}x^{n-2}\\
&= x + x\sum_{n=1}^\infty f_{n}x^{n} + x^2\sum_{n=0}^\infty f_{n}x^{n}\\
\end{align*}
where we justfied this last step by just shifting our indices (i.e. the sum starting at 2 of $f_{n-1}x^{n-1}$ is just the sum starting at 1 of $f_nx^n$.)  Finally, if we notice that because $f_0 = 0$, we have $x\sum_{n=1}^\infty f_{n}x^{n} = x\sum_{n=0}^\infty f_{n}x^{n}$, we finally have
\begin{align*}
\sum_{n=0}^\infty f_nx^n &= x + x\sum_{n=0}^\infty f_{n}x^{n} + x^2\sum_{n=0}^\infty f_{n}x^{n}\\
\Rightarrow \sum_{n=0}^\infty f_nx^n - x\sum_{n=0}^\infty f_nx^n - x^2\sum_{n=0}^\infty f_nx^n &= x\\
\Rightarrow (1-x-x^2)\sum_{n=0}^\infty f_nx^n &= x\\
\Rightarrow \sum_{n=0}^\infty f_nx^n &= \frac{x}{1-x-x^2}.\\
\end{align*}

Sweet!   A closed form.  So: according to our blueprint, we want to use this closed form to find information about our original series, possibly by finding another way to expand it.  

To start this, we first notice that with the quadratic formula, we can see that $1-x-x^2$ has roots $-\frac{ 1 \pm \sqrt{5}}{2}$, and therefore that we can factor $1-x-x^2$ as follows:
\begin{align*}
1-x-x^2 = -\left(x + \frac{1 + \sqrt{5}}{2}\right)\left(x + \frac{1 - \sqrt{5}}{2}\right).
\end{align*}
You may recognize the fraction $\frac{1+\sqrt{5}}{2}$ as the \textbf{golden ratio} $\varphi$, a famous mathematical constant that shows up in all sorts of odd places!  This has a few useful properties, especially in relation to the other root $\frac{1-\sqrt{5}}{2}$, which we list here for convenience's sake:
\begin{align*}
-\frac{1}{\varphi} &= -\frac{2}{1+\sqrt{5}} = -\frac{2(1-\sqrt{5}}{(1+\sqrt{5})(1-\sqrt{5})} = -\frac{2(1-\sqrt{5})}{-4} = \frac{1-\sqrt{5}}{2},\\
1 - \varphi &= 1 - \frac{1 + \sqrt{5}}{2} = \frac{1 - \sqrt{5}}{2} = -\frac{1}{\varphi},\\
1 - \varphi - \varphi^2 &= 0 \Rightarrow \varphi^2 = 1-\varphi = -\frac{1}{\varphi}
\end{align*}

We use these observations to further modify our polynomial:
\begin{align*}
1-x-x^2 &= -\left(x - \frac{1 + \sqrt{5}}{2}\right)\left(x - \frac{1 - \sqrt{5}}{2}\right)\\
&= -( x + \varphi)(x + (-1/\varphi))\\
&= -(x + \varphi) \cdot \frac{1}{\varphi} \cdot \varphi \cdot (x + (-1/\varphi))\\
&= -((1/\varphi)x + 1)(\varphi x - 1)\\
\end{align*}

We can use this observation to cleverly split our expression for the Fibonacci series' power series, using the technique of \textbf{partial fractions}\footnote{If you haven't seen this before: this is just the mathematical technique where we replace a fraction of the form $\frac{1}{A(x)B(x)}$ with some clever expression $\frac{C(x)}{A(x)} + \frac{D(x)}{B(x)}$, by ``undoing'' the common-denominator step in adding two fractions.}:
\begin{align*}
\frac{x}{1-x-x^2} &= \frac{x}{(1-x\varphi) \cdot (1 - x(-1/\varphi))} \\
&= \frac{1}{\varphi - (-1/\varphi)} \cdot \left(\frac{1}{1-x\varphi} - \frac{1}{1-x(-1/\varphi)} \right)\\
&= \frac{1}{\sqrt{5}} \cdot  \left(\frac{1}{1-x\varphi} - \frac{1}{1-x(-1/\varphi)} \right)\\
\end{align*} 


To deal with these two fractions, we now notice the following power series identity: for any $y$, we have as a formal power series the equation
\begin{align*}
\sum_{n=0}^\infty y^n = \frac{1}{1-y}.
\end{align*}
This is not hard to check; if we multiply the LHS by $(1-y)$, we can see that we get
\begin{align*}
(1-y) \sum_{n=0}^\infty y^n &= \sum_{n=0}^\infty y^n - \sum_{n=0}^\infty y^{n+1} \\
&= \sum_{n=0}^\infty y^n - \sum_{n=1}^\infty y^{n}\\
&= 1 + \sum_{n=1}^\infty y^n - \sum_{n=1}^\infty y^{n}\\
&= 1.\\
\Rightarrow\qquad \qquad \sum_{n=0}^\infty y^n &= \frac{1}{1-y}.\\
\end{align*}

In particular, if we let $y = \varphi x$ or $y = (-1/\varphi)x$, we get
\begin{align*}
\frac{1}{1-x\varphi} = \sum_{n=0}^\infty (x\varphi)^n, \quad \frac{1}{1-x(-1/\varphi)} = \sum_{n=0}^\infty (x(-1/\varphi))^n.
\end{align*}

Plugging this into our work earlier gives us
\begin{align*}
\frac{x}{1-x-x^2} &= \frac{1}{\sqrt{5}} \cdot \left( \sum_{n=0}^\infty (x\varphi)^n - \sum_{n=0}^\infty (x(-1/\varphi))^n \right) \\
&= \frac{1}{\sqrt{5}} \cdot \left( \sum_{n=0}^\infty (\varphi^n - (-1/\varphi)^n)x^n \right) \\
\end{align*}



So: we found a new way to expand our series!  In particular, because power series are unique, we know that the coefficients of this different way to expand our series must be the same as the coefficients of our original power series $\sum f_nx^n$:
\begin{align*}
\sum_{n=0}^\infty f_nx^n &= \frac{1}{\sqrt{5}} \cdot \left( \sum_{n=0}^\infty (\varphi^n - (-1/\varphi)^n)x^n \right) \\
\Rightarrow f_n &= \frac{\varphi^n - (-1/\varphi)^n}{\sqrt{5}}.
\end{align*}
So we have a closed form for the $f_n$'s.  In other words, it worked!


The las part of this lecture is devoted to studying a specific and particularly beautiful example of this method: the study of \textbf{nonstandard dice}!
\subsection{Nonstandard dice.}

\begin{definition}
Define a $k$-sided die as a $k$-sided shape on which symbols $s_1, \ldots s_k \in \mathbb{N}^+$ are drawn.  Analogously, we can define a $k$-die to be a bucket with $k$ balls in it, each stamped with a symbol $s_i \in \mathbb{N}^+$.  In this sense, ``rolling'' our die corresponds to picking a ball out of our bucket; for intuitive purposes, pick whichever model makes more sense and feel free to use it throughout this lecture.

For our lecture, we restrict all of our symbols to be positive integers: i.e. elements from the set $\{1,2,3,4,\ldots\}$.

A \textbf{standard} k-sided die $D$ is just a $k$-sided die with faces $\{1,2,3\ldots k\}$.  For example, a standard 6-die is just the normal 6-sided dice that you play most board games with.
\end{definition}

The motivating question of this section is the following:
\begin{question}
Can you find two $6$-sided dice $B,C$ with the following property: for any $n$, the probability that rolling $B$ and $C$ together and summing them yields $n$ is the same as the probability that rolling two standard 6-sided dice together and summing them yields $n$? 

For example, the probability that $(B+C = 7)$ would have to be $\frac{6}{36}$,  because there are 36 different ways for a pair of two 6-sided dice to be rolled, and there are precisely 6 different ways for a pair of standard 6-sided dice to sum to 7.  Similarly, the probablity for $(B+C= 2)$ would have to be $\frac{1}{36}$, because there's only one way for a pair of standard 6-sided dice to sum to 2.
\end{question}

To answer this, surprisingly, we can use the language of generating functions!  To do this, let's use the following method of turning dice into sequences:

\begin{definition}
Given a $k$-sided die $D$, let $d_n$ denote the number of ways in which rolling $D$ yields a $n$.  In this sense, the die $D$ and the sequence $\{d_n\}_{n=1}^\infty$ are equivalent.

For a standard $k$-die $D$, the associated sequence $\{d_n\}_{n=1}^\infty$ is just
\begin{align*}
\underbrace{1,1,1\ldots 1}_\text{k 1's}, 0,0,\ldots
\end{align*}
\end{definition}

\begin{question}
Take two dice $B = \{b_n\}_{n=1}^\infty, C = \{c_n\}_{n=1}^\infty$, and let 
\begin{align*}
d_n = \textrm{the number of ways that rolling }B,C\textrm{ and summing yields } n.
\end{align*}
What is $\{d_n\}_{n=1}^\infty$ in terms of the coefficients $b_n, c_n$?
\end{question}
\noindent\textbf{Answer:} How many ways can rolling $B,C$ and summing give you $n$?  Well: suppose you've already rolled $B$ and gotten a $k$.  Then you need to roll a $n-k$ on $C$ to get a sum of $n$!  In other words,
\begin{align*}
d_n &= \textrm{the number of ways that rolling }B,C\textrm{ and summing yields } n\\
&=\sum_{k=1}^n(\textrm{ways to roll }B\textrm{ and get }k) \cdot (\textrm{ways to roll }C\textrm{ and get }n-k)\\
&=\sum_{k=1}^n b_kc_{n-k}. 
\end{align*}\\


So: let $A = \{a_n\}_{n=1}^\infty =  \{1,1,1,1,1,1,0,0\ldots\}$ be a standard 6-sided die.  In the language of sequences, then, we're trying to find a pair of dice-sequences $\{b_n\}_{n=1}^\infty, \{c_n\}_{n=1}^\infty$ such that for every $n$, we have
\begin{align*}
\sum_{k=1}^n b_kc_{n-k}  = \sum_{k=1}^n a_ka_{n-k}.
\end{align*}

This looks\ldots awful, right?  In other words, we have a problem, and in the language of sequences, it's terrible.  So: let's use the method of generating functions to study these sequences!  After all, they can't get much worse \ldots

\begin{question}
If $A = \{a_n\}_{n=1}^\infty$ is a standard $k$-die, what is the power series $\sum_{n=1}^\infty a_n x^n$ associated to $A$?
\end{question}
\noindent\textbf{Answer:} As mentioned earlier, we have
\begin{align*}
\{a_n\}_{n=1}^\infty = \{\underbrace{1,1,1\ldots 1}_\text{k 1's}, 0,0,\ldots\}.
\end{align*}
Therefore, the associated power series to this sequence is just the polynomial
\begin{align*}
x + x^2  + x^3 + \ldots + x^k.
\end{align*}

Notice that any power series associated to a $k$-sided dice $D$ is just a polynomial, as any $k$-sided dice has only finitely many faces, and therefore finitely many nonzero elements in its associated sequence $\{d_n\}_{n=1}^\infty$.

\begin{question}
Let  $B = \{b_n\}_{n=1}^\infty, C = \{c_n\}_{n=1}^\infty$, be a pair of dice, and let $B(x) = \sum b_n x^n, C(x) = \sum c_nx^n$ be their associated power series.

Let $\{d_n\}$ be the sequence associated to rolling both $B,C$ and summing the result, as discussed before.  What is the power series associated to $\{d_n\}$?
\end{question}
\noindent\textbf{Answer:} If we use our earlier observation about how we can formulate the $d_n$'s in terms of the $b_n, c_n$'s, we have
\begin{align*}
\sum_{n=1}^\infty d_nx^n = \sum^\infty_{n=0} \left( \sum_{k=0}^n b_kc_{n-k} \right) x^n.
\end{align*}
But this is just the product of the two polynomials $B(x), C(x)$!  Specifically, you can check by multiplying terms out via FOIL that
\begin{align*}
\left(  \sum_{n=1}^\infty b_n x^n \right) \cdot \left(  \sum_{n=1}^\infty c_n x^n \right) =  \sum_{n=1}^\infty \left( \sum_{k=0}^n b_kc_{n-k} \right) x^n,
\end{align*}
and therefore that
\begin{align*}
\sum_{n=1}^\infty d_nx^n &= \left(  \sum_{n=1}^\infty b_n x^n \right) \cdot \left(  \sum_{n=1}^\infty c_n x^n \right)\\
&= B(x) \cdot C(x).\\
\end{align*}

In other words, to get the generating function for the sum of two dice, we can simply take the product of their individual generating functions! 

So, in the language of generating functions, our question is now the following:
\begin{quest}
Find a pair of polynomials with integer coefficients $B(x), C(x)$ such that 
\begin{itemize}
\item $B(x), C(x)$ both correspond to $6$-sided dice: i.e. $B(0) = C(0) = 0$ [no 0-faces], $B(1) = \sum b_i = 6, C(1) = \sum c_i = 6$ [they're 6-sided], and all of the coefficients of $B(x), C(x)$ are positive [you can't have a negative number of ways to roll a certain result.]
\item Rolling $B, C$ and summing is equivalent to rolling two standard 6-sided dice and summing: i.e. via our earlier work
\begin{align*}
B(x) \cdot C(x) &= (\textrm{rolling }B,C\textrm{ and summing, interpreted as a polynomial})\\
 &= (\textrm{rolling 2 standard 6-dice and summing, interpreted as a polynomial})\\
&= (x + x^2 + x^3 + x^4 + x^5 + x^6)^2.\\
\end{align*}
\item Neither $B$ or $C$ are standard dice: i.e. neither $B(x)$ or $C(x)$ are equal to $x + x^2 + x^3 + x^4 + x^5 + x^6$.
\end{itemize}
\end{quest}

Now our question is just one about algebra!  I.e. we're just looking for a pair of polynomials whose product is some specific polynomial, whose coefficients are all positive, and that when you plug in 0 yield 0 and when you plug in 1 yield 6.  This is \textbf{doable}!

Specifically: after playing around with the above polynomial, or talking to an algebraicist, you'll realize that
\begin{align*}
(x + x^2 + x^3 + x^4 + x^5 + x^6)^2 &= (x)^2 (x+1)^2 (x^2+x+1)^2 (x^2-x+1)^2.\\
\end{align*}
More specifically, none of the terms $(x), (x+1), (x^2+ x + 1), (x^2 -x + 1)$ can be broken up into smaller polynomials, and there is no way to break up this polynomial into different integer polynomials.  (In this sense, these polynomials $(x), (x+1), (x^2+ x + 1), (x^2 -x + 1)$  are thought of as \textbf{irreducible} polynomials: you cannot break them into smaller parts, and you cannot break anything made of these polynomials into different parts that does not use them.  A good analogy here is to the role of \textbf{prime numbers} in the integers: just like any number can be broken up into a bunch of prime factors, any integer polynomial can be broken up into a bunch of irreducible factors.)


So: the only thing for us to do now is find out if we can split these factors $(x), (x+1), (x^2+ x + 1), (x^2 -x + 1)$  into two polynomials, so that they both correspond to 6-sided nonstandard dice.  

Because $x+1$ is 2 at $x=1$, $x^2+x+1$ is 3 at $x=1$, and $x^2-x+1$ is 1 at $x=1$, we know that each $A_i(x)$ has to have exactly one copy of both $x+1$ and $x^2+x+1$ in it in order for $A_i(1)$ to be 6.  As well, because they both need to be 0 at $x=0$, we need to give each polynomial a copy of $x$.  Consequently, the only way we can have both of these dice not be standard is if
\begin{align*}
B(x) &= x (x+1)(x^2+x+1)(x^2-x+1)^2 = x^8 + x^6+x^5+x^4+x^3+x,\\
C(x) &= x (x+1)(x^2+x+1) = x^4 + 2x^3 + 2x^2 + x;\\
\end{align*}
i.e. we have one die with faces $\{8,6,5,4,3,1\}$ and one die with faces $\{4,3,3,2,2,1\}$.

Check this: they actually work!  For example, there are precisely 6 ways in which rolling these two dice yields 7, just like for a pair of standard 6-sided dice. 



\end{document}