0% found this document useful (0 votes)
110 views22 pages

04 - Recurrence

The document discusses recurrence relations, which define sequences where each term is defined by previous terms. It provides examples of homogeneous and non-homogeneous linear recurrence relations. Homogeneous relations have solutions based on the characteristic roots of the characteristic equation. Non-homogeneous relations add a non-zero function, and solutions are the sum of a particular solution and the general solution to the associated homogeneous relation. The document outlines methods for finding solutions to different types of recurrence relations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
110 views22 pages

04 - Recurrence

The document discusses recurrence relations, which define sequences where each term is defined by previous terms. It provides examples of homogeneous and non-homogeneous linear recurrence relations. Homogeneous relations have solutions based on the characteristic roots of the characteristic equation. Non-homogeneous relations add a non-zero function, and solutions are the sum of a particular solution and the general solution to the associated homogeneous relation. The document outlines methods for finding solutions to different types of recurrence relations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

DM – Recurrence relations

NGUYEN Hoang Thach


[email protected]

06/05/2020
Outline

1 Examples of recurrence relations

2 Homogeneous linear recurrence relations

3 Non-homogeneous linear recurrence relations

H.-T. Nguyen Recurrence relations 06/05/2020 2 / 20


Outline

1 Examples of recurrence relations

2 Homogeneous linear recurrence relations

3 Non-homogeneous linear recurrence relations

H.-T. Nguyen Recurrence relations 06/05/2020 3 / 20


Fibonacci sequence

A young pair of rabbits is placed on an island. A pair of rabbits does not


breed until they are 2 months old. After they are 2 months old, each pair
of rabbits produces another pair each month. Find a recurrence relation
for the number of pairs of rabbits on the island after n months, assuming
that no rabbits ever die.
Let fn (n ≥ 1) denote the number of rabbit pairs after n months. We have
f1 = f2 = 1.
For n ≥ 3, the number of pairs after n months is equal to the sum of:
the number of pairs at the previous month, fn−1 ;
the number of newborn pairs, which is equal to the number of pairs
which are at least two months old, or fn−2 .
Hence fn = fn−1 + fn−2 for n ≥ 3.
This recurrence relation together with the initial conditions f1 = f2 = 1
uniquely define the sequence, which is called the Fibonacci sequence.
H.-T. Nguyen Recurrence relations 06/05/2020 4 / 20
Tower of Hanoi

Figure: Rosen, p. 503

Rules:
One disk moved at each step;
A disk cannot be placed on top of a smaller one.
Goal: Move n disks from peg 1 to peg 3.

H.-T. Nguyen Recurrence relations 06/05/2020 5 / 20


Tower of Hanoi

Let Hn (n ≥ 1) denote the optimal number of steps to move n disks.


Move n − 1 top disks to peg 2: Hn−1 steps;
Move the largest disk to peg 3: 1 step;
Move n − 1 disks from peg 2 to peg 3: Hn−1 steps.

Hn = Hn−1 + 1 + Hn−1 = 2Hn−1 + 1 .


Wth the initial condition H1 = 1, the solution is Hn = 2n − 1 for all n ≥ 1.
For 64 disks, the number of moves is 264 − 1 ≈ 18 × 1018 .

H.-T. Nguyen Recurrence relations 06/05/2020 6 / 20


Valid codewords

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 .

Consider two kinds of codewords of length n:


Those whose last digit is not 0: they are obtained by adding a
non-zero digit to the end of a (n − 1)-digit codeword. There are
9an−1 such codewords.
Those whose last digit is 0: the number of codewords of this type is
equal to the number of words of length n − 1 which are not
codewords. There are 10n−1 − an−1 such codewords.
Hence an = 9an−1 + 10n−1 − an−1 = 8an−1 + 10n−1 .
The initial condition is a1 = 9.

H.-T. Nguyen Recurrence relations 06/05/2020 7 / 20


Outline

1 Examples of recurrence relations

2 Homogeneous linear recurrence relations

3 Non-homogeneous linear recurrence relations

H.-T. Nguyen Recurrence relations 06/05/2020 8 / 20


Homogeneous linear recurrence relations
Definition
A homogeneous linear recurrence relation of degree k (with constant
coefficients) is a recurrence linear relation of the form

an = c1 an−1 + c2 an−2 + · · · + ck an−k (1)

where the ci are real numbers and ck 6= 0.

Remark: A sequence satisfying the relation (1) is uniquely determined by


the initial conditions, ie. the first k terms a0 , a1 , . . . , ak−1 .
Examples:
The recurrence relation of the Fibonacci sequence that we have seen
is linear and homogeneous.
The recurrence relation of the Hanoi tower example is linear but not
homogeneous.

H.-T. Nguyen Recurrence relations 06/05/2020 9 / 20


Characteristic equation

Definition
The characteristic equation of the recurrence relation (1) is

x k − c1 x k−1 − · · · − ck−1 x − ck = 0 (2)

where x is the unknown.


The roots of the equation (2) are called the characteristic roots of the
relation (1).

Example: The characteristic equation of the Fibonacci sequence is

x2 − x − 1 = 0 .

1± 5
This relation has 2 characteristic roots: 2 .

H.-T. Nguyen Recurrence relations 06/05/2020 10 / 20


Case k = 2

Theorem
Suppose that the equation (in x ) x 2 − c1 x − c2 = 0 has two distinct roots
r1 and r2 . Then the solutions to the relation an = c1 an−1 + c2 an−2 all have
the form an = αr1n + βr2n where α, β are constants.

Remark: The constants α, β are determined according to the initial


conditions.

H.-T. Nguyen Recurrence relations 06/05/2020 11 / 20


Example
Consider the Fibonacci sequence. The characteristic
√ equation
x 2 − x − 1 = 0 has two roots r1,2 = 1±2 5 .
The general term of the sequence will have the form
√ !n √ !n
1+ 5 1− 5
fn = α +β
2 2

In order to obtain α, β, let n = 0, 1 and solve the following system:



α + β = f0 = 0
 √   √ 
 1+ 5 α + 1− 5 β = f1 = 1
2 2

We get α = √1 , β = − √15 , and


5
√ !n √ !n
1 1+ 5 1 1− 5
fn = √ −√ .
5 2 5 2

H.-T. Nguyen Recurrence relations 06/05/2020 12 / 20


Case k = 2
Theorem
Suppose that the characteristic equation has only one root r0 . Then the
solutions to the relation have the form an = αr0n + βnr0n .

Example: Solve an = 6an−1 − 9an−2 with a0 = 1, a1 = 6.


The characteristic equation x 2 − 6x + 9 = 0 has only one root r = 3, hence

an = α3n + βn3n .

Using the initial conditions, we get


(
α = a0 = 1
3α + 3β = a1 = 6

which yield α = β = 1.
Hence an = 3n + n3n .
H.-T. Nguyen Recurrence relations 06/05/2020 13 / 20
General case

Theorem
Suppose that the equation (2) has k distinct roots r1 , r2 , . . . , rk . Then the
solution to the relation (1) has the form

an = α1 r1n + · · · + αk rkn ,

where the constants αi are determined by the initial conditions.

H.-T. Nguyen Recurrence relations 06/05/2020 14 / 20


General case

Theorem
Suppose that the equation (2) has t roots r1 , r2 , . . . , rt with multiplicities
m1 , . . . , mt (mi ≥ 1 and m1 + · · · + mt = k) Then the solution to the
relation (1) has the form

an = p1 (n)r1n + · · · + pt (n)rtn

where each pi is a polynomial of degree not exceeding mi − 1 and whose


coefficients are determined by the initial conditions.

H.-T. Nguyen Recurrence relations 06/05/2020 15 / 20


Outline

1 Examples of recurrence relations

2 Homogeneous linear recurrence relations

3 Non-homogeneous linear recurrence relations

H.-T. Nguyen Recurrence relations 06/05/2020 16 / 20


Non-homogeneous linear recurrence relations
Definition
A non-homogeneous linear recurrence relation of degree k (with constant
coefficients) is a recurrence linear relation of the form

an = c1 an−1 + c2 an−2 + · · · + ck an−k + F (n) (3)

where the ci are real numbers, ck 6= 0 and F (n) is a non-zero function in n.


The recurrence relation (1) is calleds the associated homogeneous
recurrence relation of (3).

Theorem
(p)
If (an ) is a particular solution to the non-homogeneous relation (3), then
(p) (h) (h)
every solution of (3) has the form (an + an ), where (an ) is a solution
to the associated homogeneous relation.

H.-T. Nguyen Recurrence relations 06/05/2020 17 / 20


Example

Consider the relation an = 3an−1 + 2n with a1 = 3.


(h)
The associated homogeneous relation an = 3an−1 has solutions an = α3n
where α is a constant.
(p) 3
One can verify that an = −n − 2 is a particular solution.
Hence the general solutions have the form
3
an = −n − + α3n .
2
3
Let n = 1 and use the initial condition a1 = 3, we get −1 − 2 + 3α = 1,
whence α = 116 .
3 11 n
The solution is an = −n − 2 + 6 3 .

H.-T. Nguyen Recurrence relations 06/05/2020 18 / 20


Particular solution

Theorem
Suppose that F (n) has the form F (n) = Q(n)s n , where Q is a polynomial
of degree t and s is a real number.
1 If s is not a root of the characteristic equation of the associated
homogeneous relation, then there is a particular solution of the form
p(n)s n , where p is a polynomial of degree not exceeding t.

H.-T. Nguyen Recurrence relations 06/05/2020 19 / 20


Particular solution

Theorem
Suppose that F (n) has the form F (n) = Q(n)s n , where Q is a polynomial
of degree t and s is a real number.
1 If s is not a root of the characteristic equation of the associated
homogeneous relation, then there is a particular solution of the form
p(n)s n , where p is a polynomial of degree not exceeding t.
2 If s is a root of multiplicity m of the characteristic equation of the
associated omogeneous relation, then there is a particular solution of
the form nm p(n)s n , where p is a polynomial of degree not exceeding t.

H.-T. Nguyen Recurrence relations 06/05/2020 19 / 20


Example
Consider an = 1 + 2 + · · · + n. This sequence satisfies the relation

an = an−1 + n , a1 = 1 .

The associated homogeneous relation is an = an−1 , whose solution is


an = c (constant).
We have F (n) = n 1n , and s = 1 is a single root of the characteristic
equation of the associated relation, so we look for a particular solution of
(p)
the form an = n1 (p0 + p1 n) 1n = p0 n + p1 n2 .
Plugging this into the relation:

np0 + n2 p1 = (n − 1)p0 + (n − 1)2 p1 + n ,

hence (2p1 − 1)n + (p0 − p1 ) = 0, hence 2p1 − 1 = p0 − p1 = 0, and


(p)
p0 = p1 = 12 . We have found a particular solution an = n(n+1)
2 .
n(n+1)
Thus, an = 2 + c. Using a1 = 1, we get c = 0.

H.-T. Nguyen Recurrence relations 06/05/2020 20 / 20


Example
Consider an = 1 + 2 + · · · + n. This sequence satisfies the relation

an = an−1 + n , a1 = 1 .

The associated homogeneous relation is an = an−1 , whose solution is


an = c (constant).
We have F (n) = n 1n , and s = 1 is a single root of the characteristic
equation of the associated relation, so we look for a particular solution of
(p)
the form an = n1 (p0 + p1 n) 1n = p0 n + p1 n2 .
Plugging this into the relation:

np0 + n2 p1 = (n − 1)p0 + (n − 1)2 p1 + n ,

hence (2p1 − 1)n + (p0 − p1 ) = 0, hence 2p1 − 1 = p0 − p1 = 0, and


(p)
p0 = p1 = 12 . We have found a particular solution an = n(n+1)
2 .
n(n+1)
Thus, an = 2 + c. Using a1 = 1, we get c = 0.
The final solution is an = n(n+1)
2 .
H.-T. Nguyen Recurrence relations 06/05/2020 20 / 20

You might also like