Definition and intuition
The ordinary generating function (OGF) of a sequence a0,a1,a2,… is the formal power series
A(x)=∑n≥0anxn=a0+a1x+a2x2+⋯
Think of xn as a bookmark for "size n": the coefficient an records how many objects have size n. We never plug in a number for x — it is a bookkeeping variable. Writing [xn]A(x) for "the coefficient of xn," the whole game is: build A(x) in closed form, then read off an=[xn]A(x).
Key formulas
Closed forms come from the geometric and binomial series. The two you must know cold:
1−x1=∑n≥0xn,(1−x)k1=∑n≥0(k−1n+k−1)xn.
Replacing x→−x gives the alternating-sign versions, e.g. (1+x)21=∑n≥0(−1)n(n+1)xn. The general negative binomial / Newton rule is [xn](1+x)−k=(−1)n(k−1n+k−1).
Product = convolution
Multiplying two OGFs combines independent choices: if A(x)B(x)=C(x) then
cn=∑i=0naibn−i.
So "pick an A-object of size i and a B-object of size n−i" is exactly a product. This is why (1−x)k1 counts the ways to write n as an ordered sum of k nonnegative integers — it is (1−x1)k.
| Operation on sequence |
Effect on A(x) |
| Shift right by 1 (an−1) |
xA(x) |
| Partial sums ∑i≤nai |
A(x)/(1−x) |
| Convolution / combine choices |
A(x)B(x) |
| Scale an→cnan |
A(cx) |
How to apply it
- Model: write the OGF as a product/sum of simple pieces (one factor per independent choice or item type).
- Simplify: factor and cancel to reach a known closed form. Algebraic simplification before expanding usually saves all the work.
- Extract: expand each factor with the series above, then read off [xn] using convolution.
The same recipe solves linear recurrences: multiply the recurrence by xn, sum, solve for A(x), do partial fractions, and extract coefficients.
Mini-example (konkur 1402, Q111)
Find a9 where f(x)=(1+x)31+x3. Simplify first using 1+x3=(1+x)(1−x+x2):
f(x)=(1+x)3(1+x)(1−x+x2)=(1+x)21−x+x2.
Expand (1+x)21=∑(−1)n(n+1)xn and convolve with 1−x+x2:
an=(−1)n[(n+1)+n+(n−1)]=(−1)n(3n)(n≥2),
so a9=(−1)9⋅27=−27.
Exam trick: Always factor and cancel before expanding. A scary rational function like (1+x)31+x3 usually collapses to a tiny polynomial over a low power of (1±x), so the coefficients grow only polynomially in n — distrust any answer choice that grows like 2n.