Generating functions, Fibonacci numbers and Pascal's triangle
Three operations — disjoint union, size-additive product, and sequences — translate combinatorial structures into generating functions. From dot-and-dash messages we get the Fibonacci recurrence, solve it by partial fractions to obtain Binet's formula and an information rate, then verify the same identity along Pascal's diagonals and by double counting.
The previous lecture counted Catalan numbers with generating functions. This one turns the method into a translation machine: on one side sit combinatorial objects, on the other formal power series. Union, size-additive concatenation and sequences become addition, multiplication and 1/(1−A).
With the machine in hand we attack a classical question: how many dot-and-dash messages of length n are there? The answer is a Fibonacci number. Then we push one step further — how large is the n-th Fibonacci number? The generating function yields a closed formula, and the formula yields an information rate.
If C is the disjoint union of A and B, then cn=an+bn and
C(x)=A(x)+B(x).
Product: multiply
If an object of C is a pair consisting of one A-object and one B-object whose sizes add, then
cn=i=0∑naibn−i,C(x)=A(x)B(x).
Size additivity is what makes the convolution index i+(n−i)=n line up.
Sequences: invert
Suppose every object in A has size at least 1. Finite sequences of A-objects, including the empty one, have generating function
S(x)=1+A(x)+A(x)2+A(x)3+⋯=1−A(x)1.
The leading 1 is the empty sequence; A(x)k counts sequences of exactly k objects. Why exclude size 0? Because a size-zero object could be inserted any number of times without changing the size, so every size would have infinitely many sequences and the coefficients would be meaningless.
For example, with A={0,1} we have A(x)=2x (two strings of length one), so binary strings have generating function
S(x)=1−2x1=1+2x+4x2+8x3+⋯,
whose coefficient 2n is the number of binary strings of length n.
Dot-and-dash messages: Fibonacci appears
Send messages over a telegraph channel using a dot (one time unit) and a dash (two time units). How many messages last exactly n units?
Enumerating:
n=1: only a dot, f1=1.
n=2: dot-dot or dash, f2=2.
n=3: dot-dot-dot, dot-dash, dash-dot, f3=3.
n=4: five messages; n=5: eight.
These are the Fibonacci numbers, and the reason is a single observation: look at the final symbol.
fn=fn−1+fn−2.
If the message ends in a dot, the first n−1 units form any message; if it ends in a dash, the first n−2 units do.
The course uses the convention
f0=1,f1=1,f2=2,f3=3,f4=5,…
Here f0=1 is the empty message — sending nothing is one way to send — and this choice keeps later formulas clean. It is shifted by one from the Wikipedia convention F0=0,F1=1: here fn=Fn+1.
Solving the recurrence with generating functions
Setting up the equation
Let F(x)=∑n≥0fnxn. Multiply the recurrence by xn and sum over n≥2:
n≥2∑fnxn=n≥2∑fn−1xn+n≥2∑fn−2xn.
The left side is F(x)−f0−f1x=F(x)−1−x. The first term on the right is x(F(x)−f0)=x(F(x)−1), the second is x2F(x). Hence
F−1−x=x(F−1)+x2F,
so
F(x)(1−x−x2)=1,F(x)=1−x−x21.
Partial fractions
Factor the denominator by writing
1−x−x2=(1−ϕ+x)(1−ϕ−x).
Comparing coefficients gives ϕ++ϕ−=1 and ϕ+ϕ−=−1, so
ϕ+=21+5,ϕ−=21−5.
Now set
1−x−x21=1−ϕ+xA+1−ϕ−xB.
The numerator after clearing denominators is A(1−ϕ−x)+B(1−ϕ+x), which must equal 1 identically. Comparing the constant and linear terms:
The lecture states the sign of B incorrectly on the board; testing n=0 shows the negative sign is required.
Binet's formula
Using
1−ϕx1=n≥0∑ϕnxn,
we get
F(x)=51n≥0∑(ϕ+n+1−ϕ−n+1)xn,
that is,
fn=5ϕ+n+1−ϕ−n+1.
Check n=0: (ϕ+−ϕ−)/5=1. Check n=1: using ϕ±2=ϕ±+1, the numerator is ϕ+−ϕ−=5, so f1=1.
Growth rate and information rate
Since ∣ϕ−∣<1, the second term decays exponentially and can be ignored:
fn≈5ϕ+n+1.
With ϕ+=(1+5)/2≈1.618, the number of messages of length n grows like ϕ+n. Hence the information carried per unit time is
nlog2fn→log2ϕ+≈0.694bits per time unit.
The constant factor 1/5 and the shift n+1 affect only lower-order terms. This is the seed of the later information-theory unit: channel capacity is governed by the logarithm of the growth rate.
A tiling problem: the sequence formula at work
Tile a 2×n strip with two shapes of tiles that may be reflected. Following the lecture, first count indecomposable pieces an: tilings that cannot be split by a vertical line into two separately tileable strips.
Checking small cases gives
a3=2,a5=2,a7=2,a2k=0,
so indecomposable pieces occur only at odd lengths 3,5,7,…, with exactly two at each length (mirror images). Therefore
A(x)=2x3+2x5+2x7+⋯=1−x22x3.
Every tiling is a sequence of indecomposable pieces, so
B(x)=1−A(x)1=1−1−x22x31=1−x2−2x31−x2.
Expanding:
B(x)=1+2x3+2x5+4x6+2x7+8x8+⋯
A strip of length 6, for instance, is two length-3 pieces side by side, with 2×2=4 choices.
Reading the recurrence off the generating function
The denominator 1−x2−2x3 encodes the recurrence; the numerator encodes initial conditions. Comparing coefficients in B(x)(1−x2−2x3)=1−x2 gives
bn−bn−2−2bn−3=⎩⎨⎧1,−1,0,n=0,n=2,otherwise.
After the initial terms,
bn=bn−2+2bn−3.
This also explains the curious value b2=0. Applied at n=2, the recurrence would give b2=b0+2b−1=1, but the numerator contributes a −1 at x2 that corrects it. Combinatorially, the empty tiling cannot be extended to length 2 by adding an indecomposable piece, since the shortest such piece has length 3.
The recurrence is also visible directly: any nonempty tiling either ends with a vertical piece of length 2 (bn−2 ways) or with a length-3 indecomposable piece in one of its two orientations (2bn−3 ways).
Pascal's triangle and Fibonacci numbers
Consider the two-variable generating function
P(x,y)=a,b≥0∑(aa+b)xayb.
Sum first along a row: for fixed n=a+b,
a=0∑n(an)xayn−a=(x+y)n.
Summing over rows,
P(x,y)=n≥0∑(x+y)n=1−x−y1.
Diagonals
Shallow diagonal sums give Fibonacci numbers:
1+1=2,1+3+1=5,1+6+5+1=13,…
The reason: substitute x=z2,y=z. Then xayb=z2a+b, so
P(z2,z)=1−z−z21=F(z).
In words, restricting the Pascal generating function to this parabola produces the Fibonacci generating function; the coefficient of zn is fn. Expanding yields
fn=k≥0∑(kn−k).
Check n=5: (05)+(14)+(23)=1+4+3=8=f5.
A double-counting proof
The same identity can be proved without generating functions.
A dot-and-dash message of length n is one of fn objects. Count them by the number of dashesk. Each dash occupies two time units, so with k dashes the remaining n−2k units are dots, and the number of symbols is
k+(n−2k)=n−k.
Choose the k positions of the dashes among n−k slots; the rest are dots. This gives (kn−k) messages, and summing over k:
fn=k=0∑⌊n/2⌋(kn−k).
Two independent routes meet at the same identity — a typical sanity check in combinatorics.
What this lecture establishes
Three operations: disjoint union → add; size-additive product → multiply; sequences →1/(1−A(x)), with no size-zero objects.
Dot-and-dash counts satisfy fn=fn−1+fn−2 with f0=1, and F(x)=1/(1−x−x2).
Partial fractions give Binet: fn=(ϕ+n+1−ϕ−n+1)/5.
The growth rate is ϕ+, giving log2ϕ+≈0.694 bits per time unit.
The tiling generating function is (1−x2)/(1−x2−2x3), i.e. bn=bn−2+2bn−3.
Pascal's triangle has generating function 1/(1−x−y); setting x=z2,y=z gives Fibonacci.
The identity fn=∑k(kn−k) has both a generating-function proof and a double-counting proof.
Comprehension check
1. Why is the generating function for finite sequences 1/(1−A(x))? Why must A contain no object of size zero?
Reference answer: A sequence (α1,…,αk) has size equal to the sum of its parts. If all objects have size at least 1, a sequence of size n has length at most n, and the coefficient of xn in A(x)k counts the ways to choose k objects whose sizes sum to n. Summing over k gives ∑k≥0A(x)k=1/(1−A(x)). If a size-zero object existed, it could be inserted arbitrarily often without changing the size, so every size would have infinitely many sequences and the coefficients would diverge.
2. Why does the lecture take f0=1? What happens with the convention F0=0,F1=1?
Reference answer: f0=1 counts the empty message — sending nothing is one way to send — and it makes the recurrence hold from n=2 with the clean equation F(x)(1−x−x2)=1. With F0=0,F1=1 we have Fn=fn−1, so the generating function becomes xF(x)=x/(1−x−x2): same denominator, numerator multiplied by x.
3. Solve for A and B in the partial fractions, and explain why B carries a negative sign.
Reference answer: From A+B=1 and Aϕ−+Bϕ+=0, eliminate B:
Aϕ−+(1−A)ϕ+=0⟹A(ϕ−−ϕ+)=−ϕ+⟹A=5ϕ+.
Then B=1−A=(5−ϕ+)/5, and since 5=ϕ+−ϕ−, B=−ϕ−/5. The sign must be negative: ϕ−<0, and with a plus sign A+B=(ϕ++ϕ−)/5=1/5=1, contradicting f0=1.
4. Why is the growth rate ϕ+ rather than ϕ−? What does it say about bits per time unit?
Reference answer: fn=(ϕ+n+1−ϕ−n+1)/5 and ∣ϕ−∣≈0.618<1, so ϕ−n+1→0 and the dominant term is ϕ+n+1/5. The number of messages of length n is about ϕ+n; the logarithm of the number of distinguishable messages is the information carried, so per unit time it is log2fn/n→log2ϕ+≈0.694 bits. The ϕ− term only corrects lower-order behaviour.
5. Prove fn=∑k(kn−k) by counting the same set two ways.
Reference answer: On one hand, the number of dot-and-dash messages of length n is fn by definition. On the other hand, classify by the number of dashes k: the dashes occupy 2k units, the remaining n−2k units are dots, so there are n−k symbols; choosing which k of them are dashes gives (kn−k) messages. Summing over 0≤k≤⌊n/2⌋ counts the same set, so the two expressions are equal.
6. Read off the recurrence and initial values from B(x)=(1−x2)/(1−x2−2x3), and explain why b2=0 while b0=1.
Reference answer: Comparing coefficients in B(x)(1−x2−2x3)=1−x2 gives bn−bn−2−2bn−3=0 for n=0,2, i.e. bn=bn−2+2bn−3; at n=0, b0=1; at n=2, b2−b0=−1, so b2=0. Combinatorially b0=1 is the empty tiling, while a strip of length 2 cannot be tiled by pieces of length at least 3, hence b2=0; the numerator term −x2 records exactly this correction.
Relation to neighbouring lectures
The previous lecture obtained C(x)=1+xC(x)2 twice for Catalan numbers, once by decomposing full binary trees and once by decomposing Dyck paths. This lecture pushes the same language to linear recurrences, extracting closed formulas and growth rates.
The next lecture applies generating functions to Catalan numbers: solving the recurrence gives C(x)=(1−1−4x)/(2x), and the binomial theorem turns it into Cn=n+11(n2n). After that the course turns to probability, where generating functions reappear as moment-generating functions.