Chapter 8a
Chapter 8a
Discrete Mathematics
Advanced Counting Techniques
Example
A popular puzzle of the late ninetheen century invented by the
French mathematician Édouard Lucas, called the Tower of Hanoi,
consists of three pegs mounted on a board together with disks of
different sizes. Initially these disks are placed ont he first peg in
order of size, with the largest on the bottom. The rules of the
puzzle allow disks to be moved on eat a time from one peg to
another as long as a disk is never placed on top of a smaller disk.
The goal of the puzzle is to have all the disks on the second peg in
order of size, with the largest on the bottom.
Tower of Hanoi
1
2
3
4
5
6
Tower of Hanoi
1
2
3
4
6 5
Example
Let Hn denote the number of moves needed to solve the Tower of
Hanoi problems with n disks. Set up a recurrence relation for the
sequence {Hn }.
Codeword enumeration
Example
A computer system considers a string of decimal digits a valid
codeword if it contains an even number of 0 digits. For instance,
1230407869 is valid, whereas 120987045608 is not valid. Let an be
the number of valid n-digit codewords. Find a recurrence relation
for an .
Codeword enumeration
Example
A computer system considers a string of decimal digits a valid
codeword if it contains an even number of 0 digits. For instance,
1230407869 is valid, whereas 120987045608 is not valid. Let an be
the number of valid n-digit codewords. Find a recurrence relation
for an .
Note that a1 = 9 because there are 10 one-digit strings, and only
one, namely, the string 0, which is not valid. Then, a valid string
of n digits can be obstained by appending a valid string of n − 1
digits with a digit other than 0. Also, a valid string of n digits can
be obstained by appending a 0 to a string of length n − 1 that is
not valid. Summing these two cases, we find:
Associations
Example
Find a recurrence relation for Cn , the number of ways to
parenthesize the product of n + 1 numbers x0 , . . . , xn to specify
the order of multiplication. For example, C3 = 5:
Associations
Example
Find a recurrence relation for Cn , the number of ways to
parenthesize the product of n + 1 numbers x0 , . . . , xn to specify
the order of multiplication. For example, C3 = 5:
Definition
A linear homogeneous recurrence relation of degree k with
constant coefficients is a recurrence relation of the form
an = c1 an−1 + · · · + ck an−k ,
Definition
A linear homogeneous recurrence relation of degree k with
constant coefficients is a recurrence relation of the form
an = c1 an−1 + · · · + ck an−k ,
Example
The recurrence relation Pn = (1.11)Pn−1 is a linear homogeneous
recurrence relation of degree one. The recurrence relation
fn = fn−1 + fn−2 is a linear homogeneous recurrence relation of
degree two. The recurrence relation an = an−5 is a linear
homogeneous recurrence relation of degree five.
Solving L.H.R.R.w.C.C.
r n = c1 r n−1 + · · · + ck r n−k .
Solving L.H.R.R.w.C.C.
r n = c1 r n−1 + · · · + ck r n−k .
When both sides of this equation are divided by r n−k and the
right-hand side is subtracted from the left, we obtain the equation
r k − c1 r k−1 − · · · − ck−1 r − ck = 0.
Solving L.H.R.R.w.C.C.
r k − c1 r k−1 − · · · − ck−1 r − ck = 0.
Consequently, the sequence {an } with an = r n is a solution if and
only if r is a solution of this last equation. We call this the
characteristic equation of the recurrence relation. The solutions of
this equation are called the characteristic roots of the recurrence
relation. As we will see, these characteristic roots can be used to
give an explicit formula for all the solutions of the currence relation.
Solving L.H.R.R.w.C.C.
Theorem
Let c1 and c2 be real numbers. Suppose that r 2 − c1 r − c2 = 0 has
two distinct roots r1 and r2 . Then, the sequence {an } is a solution
of the recurrence relation an = c1 an−1 + c2 an−2 if and only if
an = α1 r1n + α2 r2n for n = 0, 1, 2, . . . where α1 and α2 are
constants.
Solving L.H.R.R.w.C.C.
Theorem
Let c1 and c2 be real numbers. Suppose that r 2 − c1 r − c2 = 0 has
two distinct roots r1 and r2 . Then, the sequence {an } is a solution
of the recurrence relation an = c1 an−1 + c2 an−2 if and only if
an = α1 r1n + α2 r2n for n = 0, 1, 2, . . . where α1 and α2 are
constants.
Solving L.H.R.R.w.C.C.
Proof, continued
First we will show that equations of this form are solutions to the
recurrence. Because r1 and r2 satisfy r 2 − c1 r − c2 = 0, it follows
that r12 = c1 r2 + c2 and r22 = c1 r2 + c2 . From these equations, we
see
Solving L.H.R.R.w.C.C.
Proof, continued
First we will show that equations of this form are solutions to the
recurrence. Because r1 and r2 satisfy r 2 − c1 r − c2 = 0, it follows
that r12 = c1 r2 + c2 and r22 = c1 r2 + c2 . From these equations, we
see
Solving L.H.R.R.w.C.C.
Proof, continued
First we will show that equations of this form are solutions to the
recurrence. Because r1 and r2 satisfy r 2 − c1 r − c2 = 0, it follows
that r12 = c1 r2 + c2 and r22 = c1 r2 + c2 . From these equations, we
see
Solving L.H.R.R.w.C.C.
Proof, continued
First we will show that equations of this form are solutions to the
recurrence. Because r1 and r2 satisfy r 2 − c1 r − c2 = 0, it follows
that r12 = c1 r2 + c2 and r22 = c1 r2 + c2 . From these equations, we
see
Solving L.H.R.R.w.C.C.
Proof, continued
Now, suppose that {an } is a solution of the recurrence and that
the initial conditions a0 = C0 and a1 = C1 hold. We can solve for
candidate values for α1 and α2 by substituting into the equation
an = α1 r1n + α2 r2n :
a0 = C0 = α1 + α2 ,
a1 = C1 = α1 r1 + α2 r2 .
Solving L.H.R.R.w.C.C.
Proof, continued
C1 − C0 r2
α1 = ,
r1 − r2
C0 r1 − C1
α2 = .
r1 − r2
(Note that it is now critical that r1 6= r2 .)
Solving L.H.R.R.w.C.C.
Proof, continued
C1 − C0 r2
α1 = ,
r1 − r2
C0 r1 − C1
α2 = .
r1 − r2
(Note that it is now critical that r1 6= r2 .) Hence, we have
produced the formula α1 r1n + α2 r2n which solves the recurrence and
satisfies the two initial condiitons. By uniqueness of solutions to
LHRRwCC with full initial conditions, it follows that this formula
expresses the sequence {an }.
L.H.R.R.w.C.C.s
Example
Find an explicit formula for the Fibonacci numbers.
L.H.R.R.w.C.C.s
Example
Find an explicit formula for the Fibonacci numbers.
L.H.R.R.w.C.C.s
√ !n √ !n
1+ 5 1− 5
fn = α1 + α2 .
2 2
To solve for the constants, we substitute the known values f0 = 0
and f1 = 1 to get. . .
L.H.R.R.w.C.C.s
√ !n √ !n
1+ 5 1− 5
fn = α1 + α2 .
2 2
To solve for the constants, we substitute the known values f0 = 0
and f1 = 1 to get. . .
√ √
α1 = 1/ 5, α2 = −1/ 5.
L.H.R.R.w.C.C.s
√ !n √ !n
1+ 5 1− 5
fn = α1 + α2 .
2 2
To solve for the constants, we substitute the known values f0 = 0
and f1 = 1 to get. . .
√ √
α1 = 1/ 5, α2 = −1/ 5.
Consequently:
√ !n √ !n
1 1+ 5 −1 1− 5
fn = √ +√ .
5 2 5 2
L.H.R.R.w.C.C.s
Theorem
Let c1 and c2 be real numbers with c2 6= 0. Suppose that
r 2 − c1 r − c2 = 0 has only one root r0 . A sequence an is a solution
of the recurrence relation an = c1 an−1 + c2 an−2 if and only if
an = α1 r0n + α2 nr0n , where α1 and α2 are constants.
L.H.R.R.w.C.C.s
Theorem
Let c1 and c2 be real numbers with c2 6= 0. Suppose that
r 2 − c1 r − c2 = 0 has only one root r0 . A sequence an is a solution
of the recurrence relation an = c1 an−1 + c2 an−2 if and only if
an = α1 r0n + α2 nr0n , where α1 and α2 are constants.
Example
What is the solution of the recurrence relation an = 6an−1 − 9an−2
with initial conditions a0 = 1 and a1 = 6?
L.H.R.R.w.C.C.s
Theorem
Let c1 and c2 be real numbers with c2 6= 0. Suppose that
r 2 − c1 r − c2 = 0 has only one root r0 . A sequence an is a solution
of the recurrence relation an = c1 an−1 + c2 an−2 if and only if
an = α1 r0n + α2 nr0n , where α1 and α2 are constants.
Example
What is the solution of the recurrence relation an = 6an−1 − 9an−2
with initial conditions a0 = 1 and a1 = 6?
L.H.R.R.w.C.C.s
Theorem
Let c1 and c2 be real numbers with c2 6= 0. Suppose that
r 2 − c1 r − c2 = 0 has only one root r0 . A sequence an is a solution
of the recurrence relation an = c1 an−1 + c2 an−2 if and only if
an = α1 r0n + α2 nr0n , where α1 and α2 are constants.
Example
What is the solution of the recurrence relation an = 6an−1 − 9an−2
with initial conditions a0 = 1 and a1 = 6?
L.H.R.R.w.C.C.s
Theorem
Let c1 , . . . , ck be real numbers. Suppose that the characteristic
equation
r k − c1 r k−1 − · · · − ck = 0
has k distinct roots r1 , . . . , rk . Then, a sequence {an } is a solution
of the recurrence
an = c1 an−1 + · · · + ck an−k
if and only if
an = α1 r1n + α2 r2n + · · · + αk rkn ,
where α1 , . . . , αk are constants.
L.H.R.R.w.C.C.s
Theorem
Let c1 , . . . , ck ∈ R, and suppose that the equation
r k − c1 r k−1 − · · · − ck = 0
an = c1 an−1 + · · · + ck an−k
an = αi,j nj rin ,
i=1 j=0
L.N.R.R.w.C.C.s
Definition
The recurrence relation an = 3an−1 + 2n is an example of a linear
nonhomogeneous recurrence relation with constant coefficients,
that is, a recurrence relation of the form
L.N.R.R.w.C.C.s
Definition
The recurrence relation an = 3an−1 + 2n is an example of a linear
nonhomogeneous recurrence relation with constant coefficients,
that is, a recurrence relation of the form
L.N.R.R.w.C.C.s
Theorem
(p)
If {an } is a particular solution of the nonhomogeneous linear
recurrence relation with constant coefficients
L.N.R.R.w.C.C.s
Proof
Suppose that {bn } is a solution of the nonhomogeneous recurrence
(p)
relation. Substituting both it and {an } into the recurrence
relation formula and subtracting, one finds
(p) (p) (p)
bn − an = c1 (bn−1 an−1 ) + · · · + ck (bn−k − an−k ) + (F (n) − F (n)).
(p)
It follows that {bn − an } is a solution of the associated
(p) (h)
homogeneous linear recurrence, and hence bn = an + an .
L.N.R.R.w.C.C.s
Example
Find all solutions of the recurrence relation an = 3an−1 + 2n.
What is the solution with a1 = 3?
L.N.R.R.w.C.C.s
Example
Find all solutions of the recurrence relation an = 3an−1 + 2n.
What is the solution with a1 = 3?
L.N.R.R.w.C.C.s
Example
Find all solutions of the recurrence relation an = 3an−1 + 2n.
What is the solution with a1 = 3?
an = 3an−1 + 2n
cn + d = 3(c(n − 1) + d) + 2n
0n + 0 = (2c + 2)n + (2d − 3c).
L.N.R.R.w.C.C.s
Solution, continued
It follows that c = −1 and d = −3/2, and hence all solutions take
the form
(p) (h) 3
an = an + an = −n − + α3n .
2
To satisfy the initial condition, we set α = 11/6.
L.N.R.R.w.C.C.s
Example
Find all solutions of the recurrence relation
an = 5an−1 − 6an−2 + 7n .
L.N.R.R.w.C.C.s
Example
Find all solutions of the recurrence relation
an = 5an−1 − 6an−2 + 7n .
L.N.R.R.w.C.C.s
Example
Find all solutions of the recurrence relation
an = 5an−1 − 6an−2 + 7n .
L.N.R.R.w.C.C.s
Example
Find all solutions of the recurrence relation
an = 5an−1 − 6an−2 + 7n .
an = α1 · 3n + α2 · 2n + (49/20) · 7n .
Prof. Steven Evans Discrete Mathematics
Applications of Recurrence Relations
Solving Linear Recurrence Relations
L.N.R.R.w.C.C.s
Theorem
Suppose that {an } satisfies the linear nonhomogeneous recurrence
relation
an = c1 an−1 + · · · + ck an−k + F (n),
where c1 , . . . , ck are real numbers and
F (n) = (bt nt + · · · + b1 n + b0 )s n ,
L.N.R.R.w.C.C.s
Example
What form does a particular solution of the linear
nonhomogeneous recurrence
L.N.R.R.w.C.C.s
Example
What form does a particular solution of the linear
nonhomogeneous recurrence
L.N.R.R.w.C.C.s
Example
What form does a particular solution of the linear
nonhomogeneous recurrence
L.N.R.R.w.C.C.s
Example
What form does a particular solution of the linear
nonhomogeneous recurrence
L.N.R.R.w.C.C.s
Example
What form does a particular solution of the linear
nonhomogeneous recurrence