+ All Categories
Home > Documents > Recurrence Relations

Recurrence Relations

Date post: 01-Jan-2016
Category:
Upload: josiah-hester
View: 37 times
Download: 0 times
Share this document with a friend
Description:
Recurrence Relations. Chapter 6. Recursion. Defining an object in terms of itself. To recursively define a function:. Specify initial value(s) of function Give a rule for finding a function’s value for one input (n) from its values at previous inputs (n-1). - PowerPoint PPT Presentation
22
Recurrence Relations Chapter 6 Chapter 6
Transcript
Page 1: Recurrence Relations

Recurrence RelationsRecurrence Relations

Chapter 6Chapter 6

Page 2: Recurrence Relations

Recursion

Defining an object in terms of itselfDefining an object in terms of itself

Page 3: Recurrence Relations

To recursively define a function:

Specify initial value(s) of functionSpecify initial value(s) of function

Give a rule for Give a rule for finding a function’s value for one input (n)finding a function’s value for one input (n) from its values at previous inputs (n-1)from its values at previous inputs (n-1)

Page 4: Recurrence Relations

{1, 2, 4, 8, 16, … } a{1, 2, 4, 8, 16, … } ann = 2 = 2nn for n=0,1,2,… for n=0,1,2,…

The sequence may be defined by giving first term:The sequence may be defined by giving first term:

aa00 = 1 = 1

And a rule for finding a term of a sequence from a And a rule for finding a term of a sequence from a previous one:previous one:

aan n = 2a= 2an-1n-1 for n=1, 2, 3, ….for n=1, 2, 3, ….

Page 5: Recurrence Relations

Recurrence Relation

The second part of recursive definitionThe second part of recursive definition

A rule for A rule for finding a function’s value for one input (n)finding a function’s value for one input (n) from its values at previous inputs (n-1)from its values at previous inputs (n-1)

Page 6: Recurrence Relations

Recurrence Relation for sequence {an}

A formula that expresses aA formula that expresses ann

in terms of in terms of one or more previous terms one or more previous terms of sequence, aof sequence, a00, a, a11, … a, … an-1n-1

The inductive part of a recursive definition.The inductive part of a recursive definition.

Page 7: Recurrence Relations

Recurrence Relation Recurrence Relation SolutionSolutionRecurrence Relation Recurrence Relation SolutionSolution

A A sequencesequence whose terms satisfy a whose terms satisfy a recurrence relationrecurrence relation

{a{a00, a, a11, a, a22, a, a33, … }, … }

NOTE:NOTE: If we don't restrict values for the first term If we don't restrict values for the first term

of a sequence, there may be many of a sequence, there may be many solutions to a given RR. solutions to a given RR.

Page 8: Recurrence Relations

Find a R.R. Solution (sequence satisfying a recurrence relation)

Let {aLet {ann} be a solution that satisfies the recurrence } be a solution that satisfies the recurrence

relation relation

aann = a = an-1n-1 - a - an-2n-2

Let aLet a00 = 3, a = 3, a11 = 5 = 5

What are aWhat are a22 and a and a33??

aa22 = a = a11 - a - a00 = 5 - 3 = 2 = 5 - 3 = 2

aa33 = a = a22 - a - a11 = 2 - 5 = -3 = 2 - 5 = -3

Page 9: Recurrence Relations

Is the sequence a valid solution for a Recurrence Relation?

Is sequenceIs sequence {a {ann} = { 6, 9, 12, 15, … } OR } = { 6, 9, 12, 15, … } OR a ann = 3n = 3n ((for n>=2)for n>=2)

a solution for the following recurrence rel? a solution for the following recurrence rel? aann = 2a = 2an-1n-1 - a - an-2 n-2 for n=2,3,4,… for n=2,3,4,…

{a{ann} = { 6, 9, 12, 15, 18, … }} = { 6, 9, 12, 15, 18, … } aann = 3n, a = 3n, an-1n-1 = 3n - 3 = 3n - 3 aan-2n-2 = 3n - 6 = 3n - 6

aann = 2a = 2an-1n-1 - a - an-2n-2

3n = 2(3n - 3) - (3n - 6) 3n = 2(3n - 3) - (3n - 6) = 6n – 6 – 3n + 6 = 3n = 6n – 6 – 3n + 6 = 3n YESYES

Page 10: Recurrence Relations

Is the sequence a valid solution for a Recurrence Relation?

Is the sequenceIs the sequence {a {ann}, where a}, where ann = n = n

a solution for the following recurr. rel? a solution for the following recurr. rel? aann = 2a = 2an-1n-1 - a - an-2 n-2 for n=3,4,… for n=3,4,…

{a{ann} = {3, 4, 5, … } } = {3, 4, 5, … }

aann = n, a = n, an-1n-1 = n - 1 = n - 1

aan-2n-2 = n - 2 = n - 2 aann = 2a = 2an-1n-1 - a - an-2n-2

aann = 2(n - 1) - (n - 2) = n = 2(n - 1) - (n - 2) = n YESYES

Page 11: Recurrence Relations

Recurrence Relation Example

Is the sequenceIs the sequence {a {ann} where a} where ann = 2 = 2nn a solution for the recurrence relation a solution for the recurrence relation aann = 2a = 2an-1n-1 - a - an-2 n-2 for n=0,1,2,3,4,… ?for n=0,1,2,3,4,… ?

{a{ann} = { 1, 2, 4, 8, 16, 32, … }} = { 1, 2, 4, 8, 16, 32, … } aann = 2 = 2nn, a, an-1n-1 = 2 = 2n-1n-1 = 2 = 2nn22-1 =-1 = 2 2nn / 2 / 2 aan-2n-2 = 2 = 2n-2n-2 = 2 = 2nn22-2-2 =2 =2nn / 4 / 4

aann = 2a = 2an-1n-1 - a - an-2n-2

22nn = = 22((22nn / 2 / 2) - () - (22nn / 4 / 4) = ) = 3 / 43 / 4 * * 22nn NONO

Page 12: Recurrence Relations

Initial ConditionsInitial Conditions

Specify terms preceding the first term where the Specify terms preceding the first term where the recurrence relation takes effectrecurrence relation takes effect

A sequence is uniquely determined byA sequence is uniquely determined by Initial conditionsInitial conditions recurrence relation recurrence relation

Without initial conditions, many solutions Without initial conditions, many solutions may exist for a given recurrence relation.may exist for a given recurrence relation.

Page 13: Recurrence Relations

Recurrence Relation ModelsRecurrence Relation Models

A person deposits $10K in savings at 11% A person deposits $10K in savings at 11% compounded annually? compounded annually?

What will be in the account after 30 years?What will be in the account after 30 years?

PP00 = 10,000 = 10,000

PPnn = P = P n-1 n-1 + 0.11P + 0.11P n-1n-1

= 1.11 P = 1.11 P n-1n-1

Page 14: Recurrence Relations

Recurrence Relation ModelsRecurrence Relation Models

What will be in the account after 30 years?What will be in the account after 30 years?

PP00 = 10,000 = 10,000

PPnn = 1.11 P = 1.11 Pn-1n-1

PP11 = 1.11 P = 1.11 P00

PP22 = 1.11 P = 1.11 P1 1 = 1.11* 1.11* P= 1.11* 1.11* P0 0 = (1.11)= (1.11)22 P P0 0

PP33 = 1.11 P = 1.11 P2 2 = (1.11)= (1.11)33 P P00

PPnn = 1.11 P = 1.11 Pn-1 n-1 = (1.11)= (1.11)nn P P00

PP3030 = (1.11) = (1.11)3030 P P00 = = (1.11)(1.11)3030 *10000 = $228,922.97 *10000 = $228,922.97

Page 15: Recurrence Relations

Inclusion-ExclusionInclusion-Exclusion

6.56.5

Page 16: Recurrence Relations

Inclusion-Exclusion PrincipleInclusion-Exclusion Principle

The number of ways of doing two tasksThe number of ways of doing two tasks which may be done at the same timewhich may be done at the same time (i.e., sets are not disjoint)(i.e., sets are not disjoint)

Add the number of ways to do the first taskAdd the number of ways to do the first task To the number of ways to do the second taskTo the number of ways to do the second task Subtract number of ways of doing both tasksSubtract number of ways of doing both tasks

Page 17: Recurrence Relations

Inclusion-Exclusion ExampleInclusion-Exclusion Example

Of all CS studentsOf all CS students 25 take C++ programming25 take C++ programming 18 take discrete math18 take discrete math 6 take both6 take both

How many CS students are there?How many CS students are there? 25 + 18 is too many25 + 18 is too many

25 + 18 - 6 = 37 CS students25 + 18 - 6 = 37 CS students

Page 18: Recurrence Relations

Inclusion-ExclusionInclusion-Exclusion

| A | A B | = | A | + | B | - | A B | = | A | + | B | - | A B | B |

25 18

619 12

C++ Discrete

Page 19: Recurrence Relations

I-E ExampleI-E Example

How many positive integers not exceeding How many positive integers not exceeding 1000 are divisible by 7 or 11?1000 are divisible by 7 or 11?

| A | A B | = | A | + | B | - | A B | = | A | + | B | - | A B | B |

= = 1000/71000/7 + + 1000/111000/11 - - 1000/ (7*11) 1000/ (7*11) = 142 + 90 - 12= 142 + 90 - 12 = 220= 220

Page 20: Recurrence Relations

Formula for the # Element in the Union of Three SetsFormula for the # Element in the Union of Three Sets

| A | A B B C | = ? C | = ?

A B

C

Page 21: Recurrence Relations

Formula for the # Element in the Union of Three SetsFormula for the # Element in the Union of Three Sets

| A | A B B C | = | A | + | B | + | C | C | = | A | + | B | + | C | - | A - | A B | - | A B | - | A C | - | B C | - | B C | C | + | A + | A B B C | C |

Page 22: Recurrence Relations

Recommended