I just got asked a question that could be solved by generating function, while I was not familiar with it. So I did some research and found out that generating function is a powerful tool in combinatorics and probability theory. Below are some notes that I jotted after reading openmathbooks.org.
A generating function is a formal power series whose coefficients correspond to a sequence of numbers. It is often used to encode sequences and to manipulate them algebraically. The idea is to represent a infinite sequence with a single function. Let say we have a sequence,
1,2,3,4,…
We can represent it with a infinite series:
f(x)=1+2x+3x2+4x3+…,
where ∣x∣≤1 is a variable, this called the generating series of the sequence. If the series converges, i,e,
g(x)=1+1+1+1+…=1−x1,
such a function is called a generating function. The coefficients of the series are the terms of the sequence, and the variable x encodes the position of the term in the sequence.
Examples
We can make use of the know generating functions to find the generating function of other sequences. Below are some examples:
Switch x→−x in the series, we get:
1+x1=1−x+x2−x3+…which generates1,−1,1,−1,….
If x→3x,
1−3x1=1+3x+9x2+27x3+…which generates1,3,9,27,….
What about a sequence like 2,4,10,28,…? It is just like
(1+0)+(1+3)x+(1+9)x2+(1+27)x3+…=1−3x1+1−x1.
If we replace x with x2 in the series of odd number, we get:
1−x21=1+x2+x4+x6+…which generates1,0,1,0,1,….
Similarly,
1−x1−1−x21=x+x3+x5+x7+…which generates0,1,0,1,0,….
We can also take the derivative of the generating function,
dxd(1−x1)=(1−x)21=1+2x+3x2+4x3+…which generates1,2,3,4,….
What if we are interest as the sequence of the odd number? Assume its generating function as A
AxA(1−x)A⟹A=1+3x+5x2+7x3+…=1x+3x2+5x3+…=1+2x+2x2+2x3+…=1+1−x2x=1−x1+(1−x)22x
Recurrence Relations
Generating functions can also be used to solve recurrence relations. For example, consider the Fibonacci sequence:
Fi=Fi−1+Fi−2,F0=1,F1=1.
The generating function for the Fibonacci sequence can be derived as follows:
TBC.