Agenda Lecture Content:  Recurrence Relations  Solving Recurrence Relations  Iteration  Linear homogenous recurrence relation of order k with constant.

Slides:



Advertisements
Similar presentations
Week 6 - Wednesday CS322.
Advertisements

Chapter Recurrence Relations
Fall 2002CMSC Discrete Structures1 Now it’s Time for… RecurrenceRelations.
BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS
Week #10 – 28/30 October and 1 November 2002 Prof. Marie desJardins
CS 2210 (22C:19) Discrete Structures Advanced Counting
Part 5. Computational Complexity (3)
CSE115/ENGR160 Discrete Mathematics 04/19/12 Ming-Hsuan Yang UC Merced 1.
CSE115/ENGR160 Discrete Mathematics 04/21/11 Ming-Hsuan Yang UC Merced 1.
Recursion Sections 7.1 and 7.2 of Rosen Fall 2008 CSCE 235 Introduction to Discrete Structures Course web-page: cse.unl.edu/~cse235 Questions:
Discrete Structures Chapter 6 Recurrence Relations
1 Section 6.1 Recurrence Relations. 2 Recursive definition of a sequence Specify one or more initial terms Specify rule for obtaining subsequent terms.
Recursion Lecture 17: Nov 11. Quiz int hello(int n) { if (n==0) return 0; else printf(“Hello World %d\n”,n); hello(n-1); } 1.What would the program do.
6.Advanced Counting Techniques 1 Copyright M.R.K. Krishna Rao 2003 Ch 6. Recurrence Relations A recurrence relation for the sequence {a n } is an equation.
Induction and recursion
Chapter 8 With Question/Answer Animations 1. Chapter Summary Applications of Recurrence Relations Solving Linear Recurrence Relations Homogeneous Recurrence.
Analysis of Recursive Algorithms October 29, 2014
Applied Discrete Mathematics Week 9: Relations
Advanced Counting Techniques
Induction and recursion
Jessie Zhao Course page: 1.
Chapter 8. Section 8. 1 Section Summary Introduction Modeling with Recurrence Relations Fibonacci Numbers The Tower of Hanoi Counting Problems Algorithms.
Copyright © Cengage Learning. All rights reserved. CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION.
Advanced Counting Techniques CSC-2259 Discrete Structures Konstantin Busch - LSU1.
4.6.2 Exponential generating functions
Chapter 8 With Question/Answer Animations 1. Chapter Summary Applications of Recurrence Relations Solving Linear Recurrence Relations Homogeneous Recurrence.
Lecture#16 Discrete Mathematics. Recursion Now, 1 is an odd positive integer by the definition base. With k = 1, = 3, so 3 is an odd positive integer.
14.1 CompSci 102© Michael Frank Today’s topics Recurrence relationsRecurrence relations –Stating recurrences –LiHoReCoCo –Divide & conquer –Master’s method.
Recurrence Relation. Outline  What is a recurrence relation ?  Solving linear recurrence relations  Divide-and-conquer algorithms and recurrence relations.
CSE 2813 Discrete Structures Recurrence Relations Section 6.1.
R. Johnsonbaugh Discrete Mathematics 7 th edition, 2009 Chapter 7 Recurrence Relations Instructor Tianping Shuai.
15.1 CompSci 102© Michael Frank Today’s topics Recurrence relationsRecurrence relations –Stating recurrences –LiHoReCoCo Reading: Sections Reading:
Module #17: Recurrence Relations Rosen 5 th ed., §
Solving Second-Order Recursive Relations Lecture 36 ½ Section 8.3 Wed, Apr 19, 2006.
RECURRENCE Sequence Recursively defined sequence
Sequences and Summations
Chapter 7 Advance Counting Techniques. Content Recurrence relations Generating function The principle of inclusion-exclusion.
Section 2.4. Section Summary Sequences. Examples: Geometric Progression, Arithmetic Progression Recurrence Relations Example: Fibonacci Sequence Summations.
Module #1 - Logic 1 Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c) , Michael P. Frank and Modified By Mingwu Chen Recurrence.
Chapter 8 With Question/Answer Animations. Chapter Summary Applications of Recurrence Relations Solving Linear Recurrence Relations Homogeneous Recurrence.
after UCI ICS/Math 6A, Summer AdvancedCounting -1 Recurrence Relations (RRs) A “Recurrence Relation”
Sequences and Summations Section 2.4. Section Summary Sequences. – Examples: Geometric Progression, Arithmetic Progression Recurrence Relations – Example:
Fall 2015 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1.
Advanced Counting Techniques CSC-2259 Discrete Structures Konstantin Busch - LSU1.
Discrete Mathematics Recurrence Relations Chapter 5 R. Johnsonbaugh
Week 6 - Friday.  What did we talk about last time?  Solving recurrence relations.
Chapter 8 Recursion. 8.3 More Recurrence Second-Order Recurrence Definition – A second-order linear homogeneous recurrence relation with constant coefficients.
CS 103 Discrete Structures Lecture 13 Induction and Recursion (1)
7.2 Solving Linear Recurrence Relations Some of these recurrence relations can be solved using iteration or some other ad hoc technique. However, one important.
CSE 2813 Discrete Structures Solving Recurrence Relations Section 6.2.
ADVANCED ALGORITHMS REVIEW OF ANALYSIS TECHNIQUES (UNIT-1)
Recurrence Relations. Outline Recurrence relationsSolving recurrence relationsRecurrence and Divide-and-conquer algorithmsGenerating functions
Mathematical Induction Section 5.1. Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If.
RECURRENCE Sequence Recursively defined sequence
1 RECURRENCE 1. Sequence 2. Recursively defined sequence 3. Finding an explicit formula for recurrence relation.
Section Recursion 2  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
Section Recursion  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
Discrete Math For Computing II. Contact Information B. Prabhakaran Department of Computer Science University of Texas at Dallas Mail Station EC 31, PO.
CMSC Discrete Structures
Advanced Counting Techniques
Modeling with Recurrence Relations
Applied Discrete Mathematics Week 11: Relations
Introduction to Recurrence Relations
CS 2210 Discrete Structures Advanced Counting
CMSC Discrete Structures
Solving Recurrence Relations
Applied Discrete Mathematics Week 7: Computation
CMSC Discrete Structures
Recurrence Relations Discrete Structures.
ICS 253: Discrete Structures I
Presentation transcript:

Agenda Lecture Content:  Recurrence Relations  Solving Recurrence Relations  Iteration  Linear homogenous recurrence relation of order k with constant coefficients Exercise

Recurrence Relations

 Relates the n-th element of a sequence to its predecessors. Example: a n = 9 * a n-1  Closely related to recursive algorithms.  Suited for analysis of algorithm

Recurrence Relations  Generate a sequence : 1.Start with 5 2.Given any term, add 3 to get the next term  5, 8, 11, 14, …  Sequence {a n } = a 0, a 1, …, a n-1, a n 1.a 0 = 5  initial condition 2.a n = a n-1 + 3, n ≥ 1  recurrence relation

Recurrence Relations for the sequence {a n }  is an equation that expresses a n in terms of one or more of the previous terms of the sequence, namely, a 0, a 1, …, a n-1 for all integers n with n ≥ n 0, where n 0 is a nonnegative integer.  A sequence {a n } is called a solution of a recurrence relation if its terms a n satisfy the recurrence relation.

Motivation One of the main reason for using recurrence relation is that sometimes it is easier to determine the n-th term of a sequence in terms of its predecessors than it is to find an explicit formula for the n-th term in terms of n.

Example  Let {a n } be a sequence that satisfies the recurrence relation a n = a n-1 – a n-2 for n = 2, 3, 4, … and suppose that a 0 = 3 and a 1 = 5. What are a 2 and a 3 ?  a 2 = a 1 – a 0 = 5 – 3 = 2  a 3 = a 2 – a 1 = 2 – 5 = -3  Also a 4, a 5, …

Exercises  Find the first six terms of the sequence defined by the following recurrence relations: a n = a n-1 + a n-3 a 0 = 1, a 1 = 2, a 2 = 0 a n = n. a n-1 + (a n-2 ) 2 a 0 = -1, a 1 = 0

Example  Find the recurrence relation of: -{a n } = (0, 1, 2, 3, …) -{a n } = (5, 10, 15, 20, …)  Find the first three terms of the sequence defined by the following recurrence relations: -a n = 3 * a n-1 – a n-2 a 0 = 3 and a 1 = 5 -a n = a n-1 – a n-2 + a n-3 a 0 = 3, a 1 = 5 and a 2 = 5

Modelling with Recurrence Relations (1)  The number of bacteria in a colony doubles every hour. If a colony begins with five bacteria, how many will be present in n hours? -a 0 = 5 -a 1 = 10 -a 2 = 20 -…  The number of bacteria at the end of n hours: a n = 2 * a n-1

Modelling with Recurrence Relations (2)  Suppose that a person deposits $ 10,000 in a saving account at a bank yielding 11% per year with interest compounded annually. How much will be in the account after 30 years? P n : the amount in the account after n years P n = P n P n-1 = 1.11 P n-1 P 0 = 10,000 P 1 = 1.11 P 0 P 2 = 1.11 P 1 = 1.11 * 1.11 P 0 = (1.11) 2 P 0 P n = (1.11) n P 0  P n = (1.11) n P 0  Deriving explicit formula from the recurrence relation and its initial condition (Section 7.2)

Converting to a Recursive Algorithm  A recursive function is a function that invokes itself.  A recursive algorithm is an algorithm that contains a recursive function Input: n, the number of years Output: the amount of money at the end of n years 1.compound_interest (n){ 2. if (n == 0) 3. return 10, return 1.11 * compound_interest (n-1) 5.}

Modeling with Recurrence Relation (3)  A young pair of rabbits is placed on an island. A pair of rabbit 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 rabbit on the island after n months, assuming that no rabbits ever die.  f n : the number of pairs of rabbits after n months

Modeling with Recurrence Relation (3) Month reproducing pairs young pairs total pairs

Modeling with Recurrence Relation (3)  f n : the number of pairs of rabbits after n months  f 1 = 1  f 2 = 1  f 3 = 2  f n = the number on the island for the previous month + the number of newborn pairs  f n = f n-1 + f n-2  Fibonacci Numbers

Modelling with Recurrence Relation (4)  Find a recurrence relation and give initial conditions for the number of bit strings of length n that do not have two consecutives 0s.  a n : the number of bit strings of length n that do not have two consecutive 0s.

The Tree Diagrams How many bit strings of length four do not have two consecutive 0s? bit ke-1bit ke-2 bit ke-3bit ke There are eight bit strings

Modelling with Recurrence Relation (4) a n = a n-1 + a n-2 for n ≥ 3  a 1 = 2  0, 1  a 2 = 3  (01, 10, 11)  a 3 = 5  (011, 010, 101, 110, 111)  a 4 = 8

Solving Recurrence Relations

-Given recurrence relations with sequence: a 0, a 1, … -Find an explicit formula for the general term: a n -Two methods: -Iteration -Recurrence relations with constant coefficients

Iteration Steps: -Use the recurrence relation to write the n-th term a n in terms of certain of its predecessors a n-1, …, a 0 -Use the recurrence relation to replace each of a n-1, … by certain of their predecessors. -Continue until an explicit formula is obtained.

Iteration: Example 1 a n = a n-1 + 3n ≥ 1 a 0 = 5 Solution: -a n-1 = a n a n = a n = (a n-2 + 3) + 3 = a n = (a n-3 + 3) +2.3 = a n = a n-k + k.3 … k = n = a 0 + n. 3 = 5 + n. 3

Iteration: Example 2(1)  The number of bacteria in a colony doubles every hour. If a colony begins with five bacteria, how many will be present in n hours?  a 0 = 5  a 1 = 10  a 2 = 20  …  The number of bacteria at the end of n hours: a n = 2 * a n-1

Iteration: Example 2(2) a n = 2 * a n-1 = 2 * (2 * a n-2 ) = 2 * 2 ( a n-2 ) = 2 * 2 * (2 * a n-3 ) = 2 3 ( a n-3 ) … = 2 n * a 0 = 2 n * 5

Iteration: Example 3  The deer population is 1000 at time n = 0  The increase from time n-1 to time n is 10 percent.  Find the recurrence relation, initial condition and solve the recurrence relation at time n  a 0 = 1000  a n = 1.1 * a n-1  a n = 1.1 * (1.1 * a n-2 ) = * a n-2  a n = 1.1 n * a 0  a n = 1.1 n * 1000

Recurrence Relations with Constant Coefficients

Definition  A linear homogeneous recurrence relation of order k with constant coefficients is a recurrence relation of the form: a n = c 1 a n–1 + c 2 a n–2 + … + c k a n–k, c k ≠ 0  Example: S n = 2S n–1 f n = f n–1 + f n–2

Not linear homogenous recurrence relations  Example: a n = 3a n–1 a n–2 a n – a n–1 = 2n a n = 3na n–1 Why?

Solving Recurrence Relations  Example: Solve the linear homogeneous recurrence relations with constant coefficients a n = 5a n–1 – 6a n–2 a 0 = 7, a 1 = 16  Solution: Often in mathematics, when trying to solve a more difficult instance of some problem, we begin with an expression that solved a simpler version.

Solving Recurrence Relations  For the first-order recurrence relation, the solution was of the form V n = t n ; thus for our first attempt at finding a solution of the second- order recurrence relation, we will search for a solution of the form V n = t n.  If V n = t n is to solve the recurrence relation, we must have V n = 5V n–1 –6V n–2 or t n = 5t n–1 – 6t n–2 or t n – 5t n–1 + 6t n–2 = 0. Dividing by t n–2, we obtain the equivalent equation t 2 – 5t = 0. Solving this, we find the solutions t= 2, t= 3. Characteristic polynomial Characteristic roots

Solving Recurrence Relations  We thus have two solutions, S n = 2 n and T n = 3 n. We can verify that if S and T are solutions of the preceding recurrence relation, then bS + dT, where b and d are any numbers, is also a solution of that relation. In our case, if we define the sequence U by the equation U n = bS n + dT n = b2 n + d3 n,  U is a solution of the given relation.

Solving Recurrence Relations  To satisfy the initial conditions, we must have: 7 = U 0 = b2 0 + d3 0 = b + d, 16 = U 1 = b2 1 + d3 1 = 2b + 3d. Solving these equations for b and d, we obtain b = 5, d = 2.  Therefore, the sequence U defined by U n = 5∙2 n + 2∙3 n satisfies the recurrence relation and the initial conditions.  We conclude that a n = U n = 5∙2 n + 2∙3 n, for n = 0, 1, ….

Theorem  Let a n = c 1 a n–1 + c 2 a n–2 be a second-order, linear homogeneous recurrence relation with constant coefficients. If S and T are solutions of the recurrence relation, then U = bS+ dT is also a solution of the relation. If r is a root of t 2 –c 1 t–c 2 = 0, then the sequence r n, n = 0, 1, …, is a solution of the recurrence relation. If a is the sequence defined by the recurrence relation, a 0 = C 0, a 1 = C 1, and r 1 and r 2 are roots of the preceding equation with r 1 ≠ r 2, then there exist constants b and d such that a n = br 1 n + dr 2 n, n = 0, 1, ….

Example (1)  More Population Growth Assume that the deer population of Rustic County is 200 at time n = 0 and 220 at time n = 1 and that the increase from time n–1 to time n is twice the increase from time n–2 to time n–1. Write a recurrence relation and an initial condition that define the deer population at time n and then solve the recurrence relation.

Example (1)  Solution: Let d n denote the deer population at time n. d 0 = 200, d 1 = 220 d n – d n-1 = 2(d n-1 – d n-2 ) d n = 3d n-1 – 2d n-2 Solving t 2 – 3t + 2 = 0, we have roots 1 and 2. Then the sequence d is of the form d n = b∙1 n + c∙2 n = b + c2 n. To meet the initial conditions, we must have 200 = d 0 = b + c, 220 = d 1 = b + 2c. Solving for b and c, we find b= 180, and c= 20. Thus, d n is given by d n = ∙2 n.

Example (2)  Find an explicit formula for the Fibonacci sequence: f n – f n–1 – f n–2 = 0, n≥ 3 f 1 = 1, f 2 = 1  Solution: We begin by using the quadratic formula to solve t 2 –t – 1 = 0. The solutions are t = (1 ±√5)/2. Thus the solution is of the form f n = b((1+√5)/2) n + c((1–√5)/2) n. –To satisfy the initial conditions, we must have b((1+√5)/2) + c((1–√5)/2)= 1, b((1+√5)/2) 2 + c((1–√5)/2) 2 = 1. Solving these equations for b and d, we obtain b = 1/√5, d = -1/√5. Therefore, f n = 1/√5∙((1+√5)/2) n – 1/√5((1–√5)/2) n.

Theorem  Let a n = c 1 a n–1 + c 2 a n–2 be a second-order, linear homogeneous recurrence relation with constant coefficients. Let a be the sequence satisfying the relation and a 0 = C 0, a 1 = C 1. If both roots of t 2 – c 1 t – c2 = 0 are equal to r, then there exist constants b and d such that a n = br n + dnr n, n = 0, 1, ….

Example  Solve the recurrence relation d n = 4(d n-1 – d n-2 ) subject to the initial conditions d 0 = 1 = d 1. –According to the theorem, S n = r n is a solution, where r is a solution of t 2 – 4t + 4 = 0. Thus we obtain the solution S n = 2 n. –Since 2 is the only solution of the equation, T n = n2 n is also a solution of the recurrence relation. –Thus the general solution is of the form U = aS+ bT. –We must have U 0 = 1 = U 1. The last equations become aS 0 + bT 0 = a+ 0b= 1, aS 1 + bT 1 = 2a+ 2b = 1. –Solving for a and b, we obtain a = 1, b = -1/2. –Therefore, the solution is d n = 2 n – 1/2n2 n = 2 n – n2 n-1.

Note  For the general linear homogeneous recurrence relation of order k with constant coefficients c 1, c 2, …, c k, if r is a root of t k – c 1 t k-1 – c 2 t k-2 – … – c k = 0 of multiplicity m, it can be shown that r n, nr n, …, n m-1 r n are solutions of the equation.