Lecture 13

Part 13
Generating Functions
Printed version of the lecture Discrete Mathematics on 12. October 2009
Tommy R. Jensen, Department of Mathematics, KNU
13.1
Contents
1
Number Sequences
1
2
Special Number Sequences
2
3
Generating Functions
4
4
Formula for the Fibonacci Numbers
5
5
Conclusion
6
13.2
1
Number Sequences
Number sequences
The numbers
The nonnegative numbers form a natural number sequence
0, 1, 2, 3, . . . , n, . . .
• The sequence does not end; it is infinite,
• but we know precisely which number is in each place.
The number of permutations
The number of permutations of {1, 2, . . . , n} :
0!, 1!, 2!, 3!, . . . , n!, . . .
or if we write the same sequence in a different way:
1, 1, 2, 6, 24, 120, 720, 5040, 40320, . . .
is another number sequence.
13.3
1
The number of solutions to equations
The number of nonnegative solutions x1 , x2 , x3 , x4 , x5 to
x1 + x2 + x3 + x4 + x5 = n
is equal to
n+4
,
4
and we get a number sequence
1, 5, 15, 35, 70, 126, . . .
that we could not guess quickly without the formula.
13.4
Fibonacci numbers
We construct a sequence by
• first write a 0,
• then write a 1,
• from thereon, always write the sum of the two preceding numbers.
And we get
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, . . .
But how do we know what is going to be in place number 100 of the sequence, or 1000, without writing
out the sequence of all the 100 or 1000 first numbers?
13.5
2
Special Number Sequences
Arithmetic sequences
Definition
Let
a0 , a1 , a2 , . . . , an , . . .
be a sequence such that there is a number q for which
ai = q + ai−1 for all i = 1, 2, . . .
Then a0 , a1 , a2 , . . . is called an arithmetic sequence.
We can also write it as
a0 , a0 + q, a0 + 2q, . . . , a0 + nq, . . .
Examples of arithmetic sequences
2, 4, 6, . . . , 2n, . . . (the sequence of positive even numbers).
3, 3, 3, . . . , 3, . . . (the constant sequence of the number 3).
13.6
Geometric sequences
Definition
If
g0 , g1 , g2 , . . . , gn , . . .
is a sequence such that there is a number q for which
gi = q · gi−1 for all i = 1, 2, . . .
Then g0 , g1 , g2 , . . . is called a geometric sequence.
We can also write it as
g0 , g0 q, g0 q2 , . . . , g0 qn , . . .
Examples of geometric sequences
1, 2, 4, . . . , 2n , . . . (the sequence of powers of 2).
3, 3, 3, . . . , 3, . . . (the constant sequence of the number 3).
13.7
2
Partial sums
Definition
The partial sums of a sequence
h0 , h1 , h2 , . . . , hn , . . .
form another sequence s0 , s1 , s2 , . . . , sn , . . . such that
s0
=
h0
s1
=
h0 + h1
s2
=
..
.
h0 + h1 + h2
sn
=
∑ hi
n
i=0
..
.
13.8
Partial sums of an arithmetic sequence
If
a0 , a1 , a2 , . . . , an , . . .
is an arithmetic sequence with ai = q + ai−1 for all i = 1, 2, . . . , then its partial sums are
n
sn =
∑ (a0 + qi) = (n + 1)(a0 + qn/2).
i=0
Partial sums of a geometric sequence
If
g0 , g1 , g2 , . . . , gn , . . .
is a geometric sequence with gi = qgi−1 for all i = 1, 2, . . . , and q 6= 1, then its partial sums are
n
sn =
∑ g0 qi = g0
i=0
qn+1 − 1
.
q−1
13.9
Fibonacci sequence
These are not Fibonacci’s rabbits
13.10
3
Fibonacci sequence
Definition
We define the Fibonacci sequence by
f0 = 0, f1 = 1, and fi = fi−1 + fi−2 for all i = 2, 3, 4, . . .
We have already calculated the first terms of the Fibonacci sequence:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, . . .
and we calculate some partial sums:
0, 1, 2, 4, 7, 12, 20, 33, 54, 88, . . .
a partial sum looks like it is 1 less than a Fibonacci number?!
13.11
The partial sums of the Fibonacci sequence
The partial sum sn of the Fibonacci sequence is equal to
sn = fn+2 − 1 for all n = 0, 1, 2, . . .
Proof. By induction on n.
For n = 0 we have sn = 0 and fn+2 − 1 = f2 − 1 = 1 − 1 = 0. The statement is true.
Let n > 0 and assume sn−1 = f(n−1)+2 − 1 = fn+1 − 1.
Then
sn
=
sn−1 + fn
=
( fn+1 − 1) + fn
=
( fn+1 + fn ) − 1
=
fn+2 − 1
13.12
3
Generating Functions
The generating function for a sequence
Definition
The generating function for the sequence
a0 , a1 , a2 , . . . , an , . . .
is the infinite series
a0 + a1 x + a2 x2 + · · · + an xn + · · · =
∞
∑ an xn
n=0
Example
The sequence
1, 1, 1, . . . , 1, . . .
has generating function
1 + x + x2 + · · · + xn + · · · =
1
.
1−x
13.13
4
Examples
Binomial coefficients
Let m be a nonnegative integer.
The sequence of binomial coefficients
m
m
m
m
,
,
,...,
,...
0
1
2
n
has generating function
m
m
m 2
m n
+
x+
x +···+
x +···
0
1
2
n
But because
m
k =0
for all k > m, this is the same as
m
m
m 2
m m
+
x+
x +···+
x = (1 + x)m ,
0
1
2
m
by the binomial theorem.
13.14
4
Formula for the Fibonacci Numbers
Formula for the Fibonacci numbers
Theorem 7.1.1
For every n ≥ 0 the Fibonacci number fn is equal to
√ !n
1+ 5
1
1
fn = √
−√
2
5
5
√ !n
1− 5
.
2
13.15
Proof of Theorem 7.1.1
Calculating the generating function
n
Let F(x) = f0 + f1 x + f2 x2 + · · · + fn xn + · · · = ∑∞
n=0 f n x .
We know f0 = 0, f1 = 1, and fn = fn−2 + fn−1 for all n ≥ 2.
Therefore:
∞
F(x)
=
∑
f n xn = x +
n=0
x+
∑
fn−2 xn +
n=2
=
=
x + x2
x + x2
∑
∞
∑ ( fn−2 + fn−1 )xn
n=2
fn−1 xn
n=2
∞
∑
n=2
∞
∞
fn−2 xn−2 + x ∑ fn−1 xn−1
n=2
∞
∑ f k xk + x ∑ f k xk
k=0
=
f n xn = x +
n=2
∞
∞
=
∞
∑
k=1
x + x2 F(x) + x(F(x) − f0 x0 ) = x + x2 F(x) + xF(x).
So we have calculated (1 − x − x2 )F(x) = x.
13.16
5
Calculating the Fibonacci numbers
We found
(1 − x − x2 )F(x) = x ⇒ F(x) =
x
.
1 − x − x2
Then we can write F(x) in the form
F(x) =
a
b
+
1 − αx 1 − β x
if we can find numbers a, b, α, β such that
(1 − αx)(1 − β x) = 1 − x − x2 and a(1 − β x) + b(1 − αx) = x.
Then we will have
F(x)
=
∞
∞
a
b
+
= a ∑ (αx)n + b ∑ (β x)n
1 − αx 1 − β x
n=0
n=0
=
∑ (aα n + bβ n )xn ⇒ fn = aα n + bβ n .
∞
n=0
13.17
Calculating the constants a, b, α, β
We saw that if
(1 − αx)(1 − β x) = 1 − x − x2 and a(1 − β x) + b(1 − αx) = x,
then fn = aα n + bβ n .
So we solve α + β = 1, αβ = −1, a + b = 0, and aβ + bα = −1.
First β = 1 − α, and α(1 − α) = −1 ⇔ −α 2 + α + 1 = 0 with solutions
√
1± 5
α=
.
2
We can choose α =
√
1+ 5
2
and β = 1 − α =
√
1− 5
2 .
√
√Finally b = −a and
√ aβ +bα = a(1−α)−aα = a(1−2α) = −1 imply a = −1/(1−2α) = −1/(− 5) =
1/ 5 and b = −1/ 5.
We have proved the formula
1
fn = aα n + bβ n = √
5
√ !n
1+ 5
1
−√
2
5
√ !n
1− 5
.
2
13.18
5
Conclusion
Conclusion
This ends the lecture!
6
13.19
Next time:
Exponential Generating Functions
More Examples
13.20
7