The basic generating function has the form:
![Rendered by QuickLaTeX.com \[ \boxed{G(z) = g_0+g_1 z+g_2 z^2 +g_3 z^3 +g_4 z^4 + \dotsb = \sumzn{g_n}} \]](https://www.adamponting.com/wp-content/ql-cache/quicklatex.com-9ae84570d2248db283c9478266bc8b98_l3.png)
, or
for short, is the generating function for the sequence
, also called
. The coefficient
of
in
is denoted
.
There are two kinds of “closed form” in generatingfunctionology.
- a closed form for
, expressed in terms of
, and - a closed form for
, expressed in terms of
.
e.g. the generating function for Fibonacci numbers has the closed form
; the Fibonacci numbers themselves have the closed form
.
Solving recurrences – THE METHOD
Given a sequence
that satisfies a given recurrence, we seek a closed form for
in terms of
. A solution to this problem via generating functions proceeds in four steps:
- Write down a single equation that expresses
in terms of other elements of the sequence. This equation should be valid for all integers
, assuming that
. - Multiply both sides of the equation by
and sum over all
. This gives, on the left, the sum
, which is the generating function
. The right-hand side should be manipulated so that it becomes some other expression involving
.
- Solve the resulting equation, getting a closed form for
. - To find an exact formula, a closed form for the sequence:
- Expand
into a power series and read off the coefficient of
. - If G is a rational function (quotient of two polynomials)
- expand in partial fractions and handle the terms separately.
- OR: If the roots of the denominator polynomial are all different, use the rational expansion theorem below.
- Expand
The “routine stunt”
![Rendered by QuickLaTeX.com \[ \boxed{\sumn nx^n = \sumn x (\ddx) x^n = x (\ddx) \sumn x^n = x (\ddx) \fr{1-x}=\frac{x}{(1-x)^2}}\]](https://www.adamponting.com/wp-content/ql-cache/quicklatex.com-a2c34a4eb018f76244dc7f7fe9b92602_l3.png)
Expanding partial fractions
e.g. Expand ![]()
This will be expandable in the form
.
To find
, multiply both sides by
and let
. ![]()
To find
, multiply both sides by
and let
. ![]()
To find
, substitute in
and use the values of
and
to find
. ![]()
So ![]()
Rational expansion theorem for distinct roots
If
, where
and the roots
are distinct, and if
is a polynomial of degree less than
, then
![Rendered by QuickLaTeX.com \[\boxed{[z^n] R(z)=a_1\rho_1^n+\dotsb+a_m\rho_m^n \text{, where } a_k=\frac{-\rho_k P(1/\rho_k)}{Q'(1/\rho_k)}}\]](https://www.adamponting.com/wp-content/ql-cache/quicklatex.com-d2d4a7ea5b1cbfb4e5fd6ab488840273_l3.png)
i.e.
![Rendered by QuickLaTeX.com \[\boxed{[z^n] R(z)=\sum_{k=1}^m \frac{-\rho_k^{n+1} P(1/\rho_k)}{Q'(1/\rho_k)}}\]](https://www.adamponting.com/wp-content/ql-cache/quicklatex.com-ca1aa6d8810223bdcc5f587067f445a9_l3.png)
When
is quadratic, i.e.
, the equation becomes
![Rendered by QuickLaTeX.com \[\boxed{[z^n] R(z) = -\rho_1^{n+1}\frac{P(1/\rho_1)}{Q'(1/\rho_1)}-\rho_2^{n+1}\frac{P(1/\rho_2)}{Q'(1/\rho_2)}}\]](https://www.adamponting.com/wp-content/ql-cache/quicklatex.com-c4468943b0beb1ea474c83c4d62f7c4d_l3.png)
Basic generating function manipulations

The calculus of ordinary power series generating functions
Definition. The symbol
means that the series
is the ordinary power series (‘ops’) generating function for the sequence
, i.e.
.
Shifting the subscript by 1.
the series changes by difference quotient
![Rendered by QuickLaTeX.com \[\sumzn{a_{n+1}} = \fr{z} \sum_{m \ges 1} a_m z^m = \frac{f(z)-f(0)}{z}.\]](https://www.adamponting.com/wp-content/ql-cache/quicklatex.com-f5e8808863f78c8a419680cb6369470a_l3.png)
Therefore ![]()
Shift subscript by 2
Iterate the difference quotient operation.
![]()
e.g. the Fibonacci recurrence relation
translates directly into
.
Rule 1. Shifting subscript. If
, then, for integer
,
![Rendered by QuickLaTeX.com \[ \boxed{\azi{n+h} \ops \frac{f-a_0-a_1z-\dotsb-a_{h-1}z^{h-1}}{z^h}}\]](https://www.adamponting.com/wp-content/ql-cache/quicklatex.com-59205bbc009bb28b632a515456827707_l3.png)
Multiplying terms by
and its powers.
To multiply the
th member of a sequence by
causes its ops generating function to be multiplied by
, which we will write as
. i.e.
![]()
What generates
?
. In general,
![]()
What generates
?
Do the same thing to
that is done to
:
.
Rule 2. If
, and P is a polynomial,
![]()
Examples.
Find
(The terms are
)
The answer is the value at
of the power series (ignoring convergence issues).

Find a closed formula for the sum of the squares of the first N positive integers.
Begin with the fact that
. To obtain the desired series, apply
to both sides, then set
.

Rule 3. Multiplication of two gfs. If
and
, then
![Rendered by QuickLaTeX.com \[\boxed{fg \ops \left\{\sum_{r=0}^n a_r b_{n-r} \right\}_{n=0}^\infty }\]](https://www.adamponting.com/wp-content/ql-cache/quicklatex.com-6013d62ac6004dd639339e940982864c_l3.png)
If
are three series that generate sequences
and
,
![Rendered by QuickLaTeX.com \[fgh \ops \left\{\sum_{r+s+t=n} a_r b_s c_t \right\}_{n=0}^\infty\]](https://www.adamponting.com/wp-content/ql-cache/quicklatex.com-ddb6f6755d29919a146d75bdeb20c634_l3.png)
Rule 4. Powers of a series. If
, then for a positive integer
,
![Rendered by QuickLaTeX.com \[ \boxed{ f^k \ops \left\{ \sum_{n_1+n_2+\dotsb+n_k=n} a_{n_1}a_{n_2}\dotsb a_{n_k} \right\}_{n=0}^\infty }\]](https://www.adamponting.com/wp-content/ql-cache/quicklatex.com-449fa0564467062f76a7774fed09a80e_l3.png)
Example. Find
, the number of ways a nonnegative integer
can be written as an ordered sum of
nonnegative integers.
e.g.
, because
.
Consider the power series
. Since
, by Rule 4 we have
![]()
Since
,
.
If
, what sequence does
generate?

Rule 5. Dividing by
. If
then
![Rendered by QuickLaTeX.com \[ \boxed{\frac{f}{1-x} \ops \left\{ \sum_{j=0}^n a_j\right\}_{n \ges 0}} \]](https://www.adamponting.com/wp-content/ql-cache/quicklatex.com-b495b5ec29c00854e951944abe60e1e3_l3.png)
i.e. dividing by
replaces the generated sequence by the sequence of its partial sums.
bibliography
Concrete Mathematics – Knuth, Graham, Patashnik, 2nd Ed., Ch. 7
generatingfunctionology – Herbert Wilf – read online