Combinatorics & Counting Methods

generating functions as counting bookkeeping

Suppose you have a whole sequence of counts — say a0, a1, a2, ... where ak is the number of ways to do something using k of a resource. Keeping track of an entire sequence is awkward. A generating function is a clever bookkeeping trick: hang the whole sequence onto the powers of a placeholder symbol x, writing a0 + a1 x + a2 x^2 + a3 x^3 + ... as a single object. The variable x is just a tag — it never gets a numerical value — and the coefficient of x^k stores the k-th count.

The magic is that combinatorial operations on the objects turn into ALGEBRA on the series. 'Choosing items from several independent groups' becomes MULTIPLYING the groups' generating functions, because when you multiply two series the coefficient of x^k automatically sums all the ways to split k between the two groups — exactly the multiplication and addition rules working together. For example, a single coin you may either take (contributing x) or not take (contributing 1) has generating function (1 + x); n such independent coins give (1 + x)^n, whose coefficient of x^k is C(n,k) — the binomial coefficients fall out as the bookkeeping of all the subsets. Stars-and-bars counts likewise emerge from products of geometric series like 1 + x + x^2 + ... = 1/(1-x).

Treated this way the series is FORMAL: you manipulate it as a symbolic ledger and read off coefficients; you do not plug in numbers or worry about whether it converges. That is the whole point here — it is a counting device, a way to let algebra do your bookkeeping. (This is different from a probability-generating function of a random variable, where you really do substitute values and ask about probabilities; that lives in a separate corner of the subject.)

How many ways to make 6 cents from pennies, nickels (5), with any number of each? Track pennies by (1 + x + x^2 + ...) and nickels by (1 + x^5 + x^10 + ...); multiply, and the coefficient of x^6 is the answer (here 2: six pennies, or one nickel plus a penny). The bookkeeping does the casework for you.

Pack a count sequence into coefficients of x; products perform the counting.

Here the series is FORMAL — x is a bookkeeping tag, not a number, and convergence is irrelevant. Do not confuse this counting use with a random variable's probability-generating function, where the variable really is substituted.

Also called
ordinary generating functioncounting series生成函數母函數生成函式