Advanced Counting Methods
Advanced Counting Methods
Definition. A recurrence relation for the sequence fang is an equation that expresses an in
terms of one or more of the previous terms 𝑎1 , 𝑎2 , 𝑎3 … 𝑎𝑛−1 , for all integers n with 𝑛 ≥ 0.
𝑎𝑛 = 𝐹(𝑎1 , 𝑎2 , 𝑎3 … 𝑎𝑛−1 , 𝑛)
Let 𝑎𝑛 = 𝑐1 𝑎𝑛−1 + 𝑐2 𝑎𝑛−2 + _ _ _ + 𝑐𝑘 𝑎𝑛−𝑘 + 𝑓(𝑛) be a linear non-homogeneous
recurrence.
If 𝑓(𝑛) = 0 it is linear and homogeneous
The following recurrence relations are linear non homogeneous recurrence relations.
i) 𝑎𝑛 = 𝑎𝑛−1 + 2𝑛
ii) 𝑎𝑛 = 𝑎𝑛−1 + 𝑎𝑛−2 + 𝑛2 + 𝑛 + 1
iii) 𝑎𝑛 = 𝑎𝑛−1 + 𝑎𝑛−4 + 𝑛!
iv) 𝑎𝑛 = 𝑎𝑛−6 + 𝑛2𝑛
Many natural functions are easily expressed as recurrences
𝑎𝑛 = 𝑎𝑛−1 + 1 𝑎1 = 1, 𝑎𝑛 = 𝑛 Polynomial
𝑎𝑛 = 2𝑎𝑛−1 , 𝑎1 = 1, 𝑎𝑛 = 2𝑛−1 Exponential
𝑎𝑛 = 𝑛𝑎𝑛−1 , 𝑎1 = 1, 𝑎𝑛 = 𝑛! Weird function
𝑎𝑛 = 𝑐1 𝑎𝑛−1 + 𝑐2 𝑎𝑛−2 + _ _ _ + 𝑐𝑘 𝑎𝑛−𝑘 where 𝑐1 , 𝑐2 , _ _ _ , 𝑐𝑘 are real numbers and 𝑐𝑘 ≠ 0.
Linear = previous terms appear with exponent 1 (not squares, cubes, etc),
Homogeneous = no term other than the multiples of 𝑎𝑖 ′𝑠, degree k= expressed in terms of
previous k terms constant coefficients = coefficients in front of the terms are constants,
instead of general functions. This recurrence relation plus k initial conditions uniquely
determines the sequence.
Example: Which of the following are linear homogeneous recurrence relations of degree k with
constant coefficients? If yes, determine k; if no, explain why not.
𝑃𝑛 = (1.11)𝑃𝑛−1 𝑎𝑛 = 𝑎𝑛−5
𝑓𝑛 = 𝑓𝑛−1 + 𝑓𝑛−2 𝑎𝑛 = 𝑎𝑛−1 + 𝑎2 𝑛−2
𝐻𝑛 = 2𝐻𝑛−1 + 1 𝐵𝑛 = 𝑛𝐵𝑛−1
Assume the sequence 𝑏𝑛 satisfies the recurrence. Another sequence 𝑎𝑛 satisfies the non
homogeneous recurrence if and only if ℎ𝑛 = 𝑎𝑛 – 𝑏𝑛 is also a sequence that satisfies
homogeneous recurrence.
1.2. Methods of solving recurrence relations
It is often easy to find a recurrence as the solution of a counting problem. Solving the recurrence
can be done for many special cases as we will see although it is somewhat of an art
Many sequences can be a solution for the same recurrence relation.
𝑎𝑛 = 2𝑎𝑛−1 − 𝑎𝑛−2 , 𝑓𝑜𝑟 𝑛 ≥ 2
The following sequences are solutions of this recurrence relation:
𝑎𝑛 = 3𝑛, 𝑓𝑜𝑟 𝑎𝑙𝑙 𝑛 ≥ 0
𝑎𝑛 = 5, 𝑓𝑜𝑟 𝑎𝑙𝑙 𝑛 ≥ 0.
The initial conditions for a sequence specify the terms before 𝑛0 (before the recurrence relation
takes effect). The recurrence relation together with the initial conditions uniquely determines the
sequence. For the example above, the initial conditions are 𝑎0 = 0, 𝑎1 = 3; and 𝑎0 = 5, 𝑎1 = 5
respectively.
Consider a homogeneous second-order recurrence relation with constant coefficients which has
the form
𝑎𝑛 = 𝑠𝑎𝑛−1 + 𝑡𝑎𝑛−2
where s and t are constants with 𝑡 ≠ 0.We associate the following quadratic polynomial with the
above recurrence relation:
∆(𝑥) = 𝑥 2 − 𝑠𝑥 − 𝑡
This polynomial ∆(𝑥)is called the characteristic polynomial of the recurrence relation, and the
roots of ∆(𝑥) are called its characteristic roots.
Theorem (1) Let 𝑐1 and 𝑐2 be real numbers. Suppose that 𝑟 2 + 𝑐1 𝑟 + 𝑐2 = 0 has two distinct
roots 𝑟1 and 𝑟2 . Then, the sequence fang is a solution of the recurrence relation 𝑎𝑛 = 𝑐1 𝑎𝑛−1 +
𝑐2 𝑎𝑛−2 if and only if 𝑎𝑛 = 𝑏1 𝑟 𝑛1 + 𝑏2 𝑟 𝑛 2 for 𝑛 = 0, 1, 2, …, where 𝑏1 and 𝑏2 are constants.
Example Consider the following homogeneous recurrence relation:
𝑎𝑛 = 2𝑎𝑛−1 + 3𝑎𝑛−2
The general solution is obtained by first finding its characteristic polynomial ∆(𝑥) and its roots
𝑟1 𝑎𝑛𝑑 𝑟2:
∆(𝑥) = 𝑥 2 − 2𝑥 − 3 = (𝑥 − 3)(𝑥 + 1); roots 𝑟1 = 3, 𝑟2 = −1
Since the roots are distinct, we can use Theorem 6.8 to obtain the general solution:
𝑎𝑛 = 𝑐1 3𝑛 + 𝑐2 (−1)𝑛
Thus any values for 𝑐1 and 𝑐2 will give a solution to the recurrence relation.
Suppose we are also given the initial conditions 𝑎0 = 1, 𝑎1 = 2.
Using the recurrence relation we can compute the next few terms of the sequence:
1, 2, 8, 28, 100, 356, 1268, 3516, . . .
The unique solution is obtained by finding c1 and c2 using the initial conditions. Specifically:
For n = 0 and 𝑎0 = 1, we get: 𝑐1 30 + 𝑐2 (−1)0 = 1 𝑜𝑟 𝑐1 + 𝑐2 = 1
For n = 1 and 𝑎1 = 2, we get: 𝑐1 31 + 𝑐2 (−1)1 = 2 𝑜𝑟 3𝑐1 − 𝑐2 = 2
3 1
Solving the system of the two equations in the unknowns 𝑐1 and 𝑐2 yields: 𝑐1 = 4 and 𝑐2 = 4
Thus the following is the unique solution of the given recurrence relation with the given initial
conditions 𝑎0 = 1, 𝑎 1 = 2:
3 𝑛 1 3𝑛+1 + (−1)𝑛
𝑎𝑛 = 3 + (−1)𝑛 =
4 4 4
Example Consider the celebrated Fibonacci sequence:
𝑎𝑛 = 𝑎𝑛−1 + 𝑎𝑛−2 , 𝑤𝑖𝑡ℎ 𝑎0 = 0, 𝑎1 = 1
The first 10 terms of the sequence follow:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, . . .
Sometimes the Fibonacci sequence is defined using the initial conditions 𝑎0 = 1, 𝑎 1 = 1 or the
initial conditions 𝑎1 = 1, 𝑎2 = 2. We use 𝑎0 = 0, 𝑎1 = 1 for computational convenience. (All
three initial conditions yield the same sequence after the pair of terms 1, 2.)
Observe that the Fibonacci sequence is a homogeneous linear second-order recurrence relation,
so it can be solved using Theorem 6.8. Its characteristic polynomial follows:
∆(𝑥) = 𝑥 2 − 𝑥 − 1
Using the quadratic formula, we obtain the roots:
1 + √5 1 − √5
𝑟1 = , 𝑟2 =
2 2
By theorem , we obtain the general solution:
𝑛 𝑛
1 + √5 1 − √5
𝑎𝑛 = 𝑐1 ( ) + 𝑐2 ( )
2 2
The initial conditions yield the following system of two linear equations in 𝑐1 and 𝑐2
For n = 0 and 𝑎0 = 0, we get: 0 = 𝑐1 + 𝑐2
1 +√5 1−√5
For n = 1 and 𝑎1 = 1, we get: 1 = 𝑐1 + 𝑐2
2 2
Theorem: If {𝑎𝑛 (𝑝) } is a particular solution for the non-homogeneous linear recurrence relation with
constant coefficients
𝑎𝑛 = 𝑐1 𝑎𝑛−1 + 𝑐2 𝑎𝑛−2 + _ _ _ + 𝑐𝑘 𝑎𝑛−𝑘 + 𝑓(𝑛) then every solution is of the form {𝑎𝑛 (𝑝) + 𝑎𝑛 (ℎ) },
where {𝑎𝑛 (ℎ) } is a solution of the associated homogeneous recurrence relation
𝑎𝑛 = 𝑐1 𝑎𝑛−1 + 𝑐2 𝑎𝑛−2 + _ _ _ + 𝑐𝑘 𝑎𝑛−𝑘