Building Generating Functions
The \(e^x\) example is very specific. We have a rather odd sequence, and the only reason we know its generating function is because we happen to know the Taylor series for \(e^x\text{.}\) Our goal now is to gather some tools to build the generating function of a particular given sequence.
Let's see what the generating functions are for some very simple sequences. The simplest of all: 1, 1, 1, 1, 1, …. What does the generating series look like? It is simply \(1 + x + x^2 + x^3 + x^4 + \cdots\text{.}\) Now, can we find a closed formula for this power series? Yes! This particular series is really just a geometric series with common ratio \(x\text{.}\) So if we use our “multiply, shift and subtract” technique from Section 2.2, we have
\begin{align*} S \amp = 1 + x + x^2 + x^3 + \cdots\\ \underline{- xS} \amp \underline{\,\, = ~~~~~~ x + x^2 + x^3 + x^4 + \cdots}\\ (1-x)S \amp = 1 \end{align*}
Therefore we see that
\begin{equation*} 1 + x + x^2 + x^3 \cdots = \dfrac{1}{1-x} \end{equation*}
You might remember from calculus that this is only true on the interval of convergence for the power series, in this case when \(|x| \lt 1\text{.}\) That is true for us, but we don't care. We are never going to plug anything in for \(x\text{,}\) so as long as there is some value of \(x\) for which the generating function and generating series agree, we are happy. And in this case we are happy.
\(1,1,1,\ldots\)
The generating function for \(1,1,1,1,1,1,\ldots\) is \(\dfrac{1}{1-x}\)
Let's use this basic generating function to find generating functions for more sequences. What if we replace \(x\) by \(-x\text{.}\) We get
\begin{equation*} \frac{1}{1+x} = 1 - x + x^2 - x^3 + \cdots \mbox{ which generates } 1, -1, 1, -1, \ldots \end{equation*}
If we replace \(x\) by \(3x\) we get
\begin{equation*} \frac{1}{1-3x} = 1 + 3x + 9x^2 + 27x^3 + \cdots \mbox{ which generates } 1, 3, 9, 27, \ldots \end{equation*}
By replacing the \(x\) in \(\frac{1}{1-x}\) we can get generating functions for a variety of sequences, but not all. For example, you cannot plug in anything for \(x\) to get the generating function for \(2,2,2,2, \ldots\text{.}\) However, we are not lost yet. Notice that each term of \(2, 2, 2, 2, \ldots\) is the result of multiplying the terms of \(1, 1, 1, 1, \ldots\) by the constant 2. So multiply the generating function by 2 as well.
\begin{equation*} \frac{2}{1-x} = 2 + 2x + 2x^2 + 2x^3 + \cdots \mbox{ which generates } 2, 2, 2, 2, \ldots \end{equation*}
Similarly, to find the generating function for the sequence \(3, 9, 27, 81, \ldots\text{,}\) we note that this sequence is the result of multiplying each term of \(1, 3, 9, 27, \ldots\) by 3. Since we have the generating function for \(1, 3, 9, 27, \ldots\) we can say
\begin{equation*} \frac{3}{1-3x} = 3\cdot 1 + 3\cdot 3x + 3\cdot 9x^2 + 3\cdot 27x^3 + \cdots \mbox{ which generates } 3, 9, 27, 81, \ldots \end{equation*}
What about the sequence \(2, 4, 10, 28, 82, \ldots\text{?}\) Here the terms are always 1 more than powers of 3. That is, we have added the sequences \(1,1,1,1,\ldots\) and \(1,3,9, 27,\ldots\) term by term. Therefore we can get a generating function by adding the respective generating functions:
\begin{align*} 2 + 4x + 10x^2 + 28x^3 + \cdots \amp = (1 + 1) + (1 + 3)x + (1 + 9)x^2 + (1 + 27)x^3 + \cdots\\ \amp = 1 + x + x^2 + x^3 + \cdots + 1 + 3x + 9x^2 + 27x^3 + \cdots\\ \amp = \frac{1}{1-x} + \frac{1}{1-3x} \end{align*}
The fun does not stop there: if we replace \(x\) in our original generating function by \(x^2\) we get
\begin{equation*} \frac{1}{1-x^2} = 1 + x^2 + x^4 + x^6\cdots \mbox{ which generates } 1, 0, 1, 0, 1, 0, \ldots. \end{equation*}
How could we get \(0,1,0,1,0,1,\ldots\text{?}\) Start with the previous sequence and shift it over by 1. But how do you do this? To see how shifting works, let's first try to get the generating function for the sequence \(0, 1, 3, 9, 27, \ldots\text{.}\) We know that \(\frac{1}{1-3x} = 1 + 3x + 9x^2 + 27x^3 + \cdots\text{.}\) To get the zero out front, we need the generating series to look like \(x + 3x^2 + 9x^3 + 27x^4+ \cdots\) (so there is no constant term). Multiplying by \(x\) has this effect. So the generating function for \(0, 1, 3, 9, 27, \ldots\) is \(\frac{x}{1-3x}\text{.}\) This will also work to get the generating function for \(0,1,0,1,0,1,\ldots\text{:}\)
\begin{equation*} \frac{x}{1-x^2} = x + x^3 + x^5 + \cdots \mbox{ which generates } 0, 1, 0, 1, 0 , 1 \ldots \end{equation*}
What if we add the sequences \(1,0,1,0,1,0,\ldots\) and \(0,1,0,1,0,1,\ldots\) term by term? We should get \(1,1,1,1,1,1\ldots\text{.}\) What happens when we add the generating functions? It works (try it)!
\begin{equation*} \frac{1}{1-x^2} + \frac{x}{1-x^2} = \frac{1}{1-x}. \end{equation*}
Here's a sneaky one: what happens if you take the derivative of \(\frac{1}{1-x}\text{?}\) We get \(\frac{1}{(1-x)^2}\text{.}\) On the other hand, if we differentiate term by term in the power series, we get \((1 + x + x^2 + x^3 + \cdots)' = 1 + 2x + 3x^2 + 4x^3 + \cdots\) which is the generating series for \(1, 2, 3, 4, \ldots\text{.}\) This says
\(1,2,3,\ldots\)
The generating function for \(1, 2, 3, 4, 5, \ldots\) is \(\d\frac{1}{(1-x)^2}.\)
Take a second derivative: \(\frac{2}{(1-x)^3} = 2 + 6x + 12x^2 + 20x^3 + \cdots\text{.}\) So \(\frac{1}{(1-x)^3} = 1 + 3x + 6x^2 + 10x^3 + \cdots\) is a generating function for the triangular numbers, \(1,3,6,10\ldots\) (although here we have \(a_0 = 1\) while \(T_0 = 0\) usually).