3. To solve the recurrence relation by
generating functions, we have numeric
function for the closed form expression of
generating function
A(z) = a0 + a1z + a2z2 + a3z3 + …
5. Example 1:
Solve recurrence relation by generating function
1. Multiply both sides by zr
Steps to follow
ar - 2ar-1 - 3ar-2 = 0, for r 2, a0 = 3; a1 = 1
a r - 2 1
r
- 3
2
r
= 0r
z ar-
z ar-
z
6. Solving Recurrence relation using Generating Functions
ar - 2ar-1 - 3ar-2 = 0, for r 2, a0 = 3; a1 = 1
2. Since r 2, summing for all r, we get
arzr – 2 ar-1zr – 3 ar-2zr = 0
r = 2
r = 2
r = 2
Solving individually
For the 1st term:
arzr = a2z2 + a3z3 + a4z4 + r = 2
A(z) = a0 + a1z + a2z2 + a3z3 + …
arzr = A(z) - a0 - a1zr = 2
7. Solving Recurrence relation using Generating Functions
ar - 2ar-1 - 3ar-2 = 0, for r 2, a0 = 3; a1 = 1
For the 2nd term:
ar-1zr = a1z2 + a2z3 + a3z4 +
r = 2
Factoring out z:
ar-1zr = z[A(z) – a0 ]r = 2
A(z) = a0 + a1z + a2z2 + a3z3 + …
Z(a1z + a2z2 + a3z3 + )
8. Solving Recurrence relation using Generating Functions
ar - 2ar-1 - 3ar-2 = 0, for r 2, a0 = 3; a1 = 1
For the 3rd term:
ar-2zr = a0z2 + a1z3 + a2z4 +
r = 2
Factoring out z2:
ar-2zr = z2[A(z)]r = 2
A(z) = a0 + a1z + a2z2 + a3z3 + …
z2( a0 + a1z + a2z2 + )
9. Solving Recurrence relation using Generating Functions
ar - 2ar-1 - 3ar-2 = 0, for r 2, a0 = 3; a1 = 1
Substitute
ar-2zr = z2[A(z)]r = 2
arzr – 2 ar-1zr – 3 ar-2zr = 0
r = 2
r = 2
r = 2
by
arzr = A(z) - a0 - a1zr = 2
ar-1zr = z[A(z) – a0 ]r = 2
10. Solving Recurrence relation using Generating Functions
ar - 2ar-1 - 3ar-2 = 0, for r 2, a0 = 3; a1 = 1
We get
z2[A(z)]A(z) - a0 - a1z z[A(z) – a0 ]– 2 – 3
Substitute the value of a0 = 3; a1 = 1
A(z) – 3 - (1)z z[A(z) – 3 ]– 2 – 3z2[A(z)]
simplify
A(z) =
𝟑 −𝟓𝒛
𝟏 −𝟐𝒛 −𝟑𝒛 𝟐
12. Solving Recurrence relation using Generating Functions
ar - 2ar-1 - 3ar-2 = 0, for r 2, a0 = 3; a1 = 1
𝟑 −𝟓𝒛
(𝟏 −𝟑𝒛)(𝟏+𝒛)
=
𝟏
(𝟏 −𝟑𝒛)
𝟏
(𝟏 + 𝒛)
+
From the table previously presented:
A(z) =
𝟏
𝟏−𝒂𝒛
𝒂 𝒓
ar = 1 3r + 2 (-1)r
13. Example 2
G(x) = a0 + a1x + a2x2 + = anxn:
Let a0 = 1; a1 = 5, and an = an-1 - 6an-2 for n 2.
Let G(x) be the generating function for the sequence
a0; a1; a2; : : :. That is,
We will use generating functions to obtain a formula
for an.
n=0
14. Solving Recurrences using Generating Functions
Let a0 = 1; a1 = 5, and an = an-1 - 6an-2 for n 2.
The first step in the process is to use the
recurrence relation to replace
This can only be done when n 2,
an by an-1 - 6an-2.
so the first two terms (arising form the initial
conditions) need to be separated from the
sigma notation to obtain:
15. G(x) = a0 + a1x + anxn
= a0 + a1x + (an-1 - 6an-1)xn
= a0 + a1x + an-1xn- 6an-1xn
n=2
n=2
n=2
n=2
= a0 + a1x + x an-1xn-1- 6x2an-2xn-2
n=2
n=2
In the last line above, constants and powers of x have
been factored out
Solving Recurrences using Generating Functions
Let a0 = 1; a1 = 5, and an = an-1 - 6an-2 for n 2.
16. so that the power to which x is raised “inside"
each sum exactly matches the subscript on the
coefficient ai.
which will make it easy to recognize each
summation as being G(x), with a few terms
possibly missing.
The reason for doing this is that the next step is
to make a change of index (on the subscripts),
Solving Recurrences using Generating Functions
Let a0 = 1; a1 = 5, and an = an-1 - 6an-2 for n 2.
17. In the first sum
When n = 2, k = 1
n=2
Put k = n - 1
an-1xn-1
As n goes to infinity, so does k.
Solving Recurrences using Generating Functions
Let a0 = 1; a1 = 5, and an = an-1 - 6an-2 for n 2.
18.
k=2
akxk = G(x) - ao
the sum becomes
With this change of index,
Solving Recurrences using Generating Functions
Let a0 = 1; a1 = 5, and an = an-1 - 6an-2 for n 2.
19. In the next sum
n=2
an-2xn-2
When n = 2, k = 0
Put k = n - 2
As n goes to infinity, so does k.
Solving Recurrences using Generating Functions
Let a0 = 1; a1 = 5, and an = an-1 - 6an-2 for n 2.
20.
k=0
akxk = G(x)
the sum becomes
With this change of index,
Solving Recurrences using Generating Functions
Let a0 = 1; a1 = 5, and an = an-1 - 6an-2 for n 2.
21. Combining these steps,
we arrive at
G(x) = a0 + a1x + x(G(x) - a0) - 6x2G(x).
After plugging in the known values for
a0 and a1,
then rearranging
Solving Recurrences using Generating Functions
Let a0 = 1; a1 = 5, and an = an-1 - 6an-2 for n 2.
22. G(x) =
𝟏 + 𝟒𝒙
𝟏 − 𝒙 + 𝟔𝒙 𝟐
this becomes
(1 - x + 6x2)G(x) = 1 + 4x.
Hence, we obtain the closed form
Solving Recurrences using Generating Functions
Let a0 = 1; a1 = 5, and an = an-1 - 6an-2 for n 2.
23. Notice the similarity of the coefficients in
1 - x + 6x2 and an – an-1 + 6an-2.
The next step is to use partial fractions to
determine the power series representation
of
1
1 − 𝑥 + 6𝑥2
Solving Recurrences using Generating Functions
Let a0 = 1; a1 = 5, and an = an-1 - 6an-2 for n 2.
24. We will eventually want the
sum of coefficient of xn and
four times the coefficient of xn-1
in this series.
Solving Recurrences using Generating Functions
Let a0 = 1; a1 = 5, and an = an-1 - 6an-2 for n 2.
25. Next, we want to write
1- x + 6x2
If and are integers,
they are positive among the
divisors of 6 and their negatives.
(1- x)(1- x).=
Solving Recurrences using Generating Functions
Let a0 = 1; a1 = 5, and an = an-1 - 6an-2 for n 2.
26. Multiplying
(1- x)(1- x).
we have,
1 - x - x + x2
= 6
= 1-
lead to
- - = -1 or
1- x + 6x2
Solving Recurrences using Generating Functions
Let a0 = 1; a1 = 5, and an = an-1 - 6an-2 for n 2.
27. = 6
Therefore,
(1- ) = 6
- 2 = 6
and the quadratic formula gives
∝ =
1 ± 𝑖 23
2
Solving Recurrences using Generating Functions
Let a0 = 1; a1 = 5, and an = an-1 - 6an-2 for n 2.
28. Let,
𝛼 =
1 − 𝑖 23
2
𝛽 =
1 + 𝑖 23
2
So that
If, 1
1 − 𝑥 + 6𝑥2
=
𝐴
1 − 𝛼𝑥
+
𝐵
1 − 𝛽𝑥
=
𝐴 1 − 𝛽𝑥 + 𝐵(1 − 𝛼𝑥)
(1 − 𝛼𝑥)(1 − 𝛽𝑥)
Solving Recurrences using Generating Functions
Let a0 = 1; a1 = 5, and an = an-1 - 6an-2 for n 2.
29. -A - B = 0
then, equating coefficients of like powers of x
from the leftmost and rightmost expressions
gives the two equations in the two
unknowns A and B:
A + B = 1
Solving Recurrences using Generating Functions
Let a0 = 1; a1 = 5, and an = an-1 - 6an-2 for n 2.
30. so that ( - )A = .
Since - = -i 23,
the quantity
𝐴 =
𝛼
−i 23
=
1 − 𝑖 23
−2i 23
𝑖 23
i 23
=
23 + 𝑖 23
46
B = 1 - A =
and, therefore,
23 − 𝑖 23
46
Solving Recurrences using Generating Functions
Let a0 = 1; a1 = 5, and an = an-1 - 6an-2 for n 2.
31. Hence,
1
1 − 𝑥 + 6𝑥2
=
𝐴
1 − 𝛼𝑥
+
𝐵
1 − 𝛽𝑥
n=0
A 𝛼nxn= +
n=0
B 𝛽nxn
Solving Recurrences using Generating Functions
Let a0 = 1; a1 = 5, and an = an-1 - 6an-2 for n 2.
32. The coefficient of xn is
A𝛼 + 𝐵𝛽 = +
23 + 𝑖 23
46
1 − 𝑖 23
2
𝑛
23 − 𝑖 23
46
1 + 𝑖 23
2
𝑛
Solving Recurrences using Generating Functions
Let a0 = 1; a1 = 5, and an = an-1 - 6an-2 for n 2.
33. The coefficient of xn in
G(x) =(1+𝟒𝐱)
and 4 times the coefficient of xn-1 in,
is the sum of the coefficient of xn in
1
1 − 𝑥 + 6𝑥2
𝟏
𝟏 − 𝒙 + 𝟔𝒙 𝟐
1
1 − 𝑥 + 6𝑥2
Solving Recurrences using Generating Functions
Let a0 = 1; a1 = 5, and an = an-1 - 6an-2 for n 2.