Form of Recurrence - Discrete Mathematics - Lecture Slides, Slides of Discrete Mathematics

During the study of discrete mathematics, I found this course very informative and applicable.The main points in these lecture slides are:Form of Recurrence, Recurrence Relation, Linear Recurrences, Constant Coefficients, Linear Homogeneous Recurrence Relations, Roots of Characteristic Equation, Unique Solution, Non-Distinct Root, Termwise Addition

Typology: Slides

2012/2013

Uploaded on 04/27/2013

aslesha
aslesha 🇮🇳

4.4

(14)

160 documents

1 / 19

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 173:
Discrete Mathematical Structures
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13

Partial preview of the text

Download Form of Recurrence - Discrete Mathematics - Lecture Slides and more Slides Discrete Mathematics in PDF only on Docsity!

CS 173:

Discrete Mathematical Structures

Recurrences

A train is defined to be an engine, followed by cars of two different kinds…long and short. Long cars are 2 units long, and short ones are 1.

Examples:

How many trains of length n are there?

tn = tn-1 + tn- t 0 = 1 t 1 = 1

We still don’t really know.

Recurrences

A computer system considers a string of decimal digits a valid codeword if it contains an even number of 0s. Find a recurrence relation for an , the number of valid n-digit codewords.

Total # of codewords is sum of those starting with 0 and those starting with something else.

How many start with 0?

How many start with something else?

10 n-1^ - an-

9an-

an = 10 n-1^ - an-1 + 9an-1 = 10 n-1^ - 8an- a 1 = 9

Recurrences

We’ve seen a variety. Techniques for solving depend on the particular form of the recurrence.

Linear Recurrences with Constant Coefficients

an = c 1 an-1 + c 2 an-2 + … + c (^) k an-k + f(n)

Ex. an = 5an-1 - 6an-2 , a 0 = 0, a 1 = 1

“order k”

Given any k consecutive values, a unique solution exists.

a 2 = 5 a 3 = 5(5) - 6(1) = 19 a 4 = …

Recurrences

Example continued: T(n) = 7T(n-1) - 10T(n-2) T(0) = 2, T(1) = 1

Now what? … think about what we know!

General solution is T(n) = A2 n^ + B5 n

A2 0 + B5^0 = 2

A2^1 + B5^1 = 1

A + B = 2

2A + 5B = 1

A = 3, B = -

Unique solution is T(n) = 3·2n^ - 5 n

Recurrences

You try a tricky one: T(n) = T(n-2)/ T(0) = 1, T(1) = 0

Rewrite: Find characteristic eqn: Find roots of char eqn: General solution is Set up system of eqn to get unique soln.

Recurrences

Here’s one for you to try:

an = 4an-1 - 5an-2 + 2an-3, n ≥ 3

a 0 = 0, a 1 = 1, a 2 = 2

Recurrences

Linear NONhomogeneous recurrence relations with constant coefficients.

c 0 an + c 1 an-1 + c 2 an-2 + … + c (^) k an-k = f(n),

Where f(n) is constant polynomial in n cn^ for some constant c cn^ · polynomial(n)

This approach is different than the one in your text. Easier and more general.

Recurrences

Sequence operators:

Constant multiplication c·〈an〉 defined to be 〈c·an〉 Ex: 3·〈 2 n〉 = 〈3· 2 n〉 = 3, 6, 12, 24, 48, …

Shift “E” E〈an〉 = 〈an+1〉 shifts sequence to left Ex: E〈 2 n〉 = 〈 2 n+1〉 = 2, 4, 8, 16, … Ex: E〈3n + 1〉 = 〈3(n+1) + 1〉 = 〈3n + 4〉

Recurrences

Combining operators:

If A,B are seq ops, then A+B is a seq op: (A+B)〈an〉 defined to be A〈an〉 + B〈an〉 Ex: (E+2)〈 2 n〉 = E〈 2 n〉 + 2〈 2 n〉 = 〈 2 n+1〉 + 〈2· 2 n〉 = 〈 2 n+1〉 + 〈 2 n+1〉 = 〈 2 n+1^ + 2 n+1〉 = 〈 2 · 2 n+1〉 = 〈 2 n+2〉 If A,B are seq ops, then AB is a seq op: (AB)〈an〉 defined to be A(B〈an〉) Ex: E^3 〈an〉 = E·E·E〈an〉 = E(E(E〈an〉)) = 〈an+3〉

Recurrences

For any constant sequence 〈c〉:

(E-1)〈c〉 = 〈 0 〉

TRICK: to solve a NONhomogeneous linear recurrence with constant coefficients, turn it into a homogeneous recurrence by applying operators to annihilate the right side.

(E-1) “annihilates” 〈c〉

Recurrences

Example: solve an = 5an-1 - 6an-2 + 4

Rewrite: an - 5an-1 + 6an-2 = 4 Rewrite again so n is smallest index: an+2 - 5an+1 + 6an = 4 Rewrite again as a sequence: 〈an+2 - 5an+1 + 6an〉 = 〈 4 〉 Rewrite again using operators: (E 2 - 5E + 6)〈an〉 = 〈 4 〉 (E-1) “annihilates” 〈c〉

Recurrences

Example: solve an - 6an-1 + 11an-2 - 6an-3 = 0

Characteristic equation: (r^3 - 6r^2 + 11r - 6) = 0 (r-1)(r-2)(r-3) = 0

General solution: an = A 1 + A 22 n^ + A 33 n

Homogeneous!!!