CHAPTER TWO RECURRENCE RELATION

Slides:



Advertisements
Similar presentations
Week 6 - Wednesday CS322.
Advertisements

Chapter Recurrence Relations
Chapter 6 Advanced Counting 6.1 Recurrence Relations.
section 6.2 Solving Recurrence Relations
Recursion, Divide and Conquer Lam Chi Kit (George) HKOI2007.
CS 2210 (22C:19) Discrete Structures Advanced Counting
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:
Recursion.
1 Section 6.1 Recurrence Relations. 2 Recursive definition of a sequence Specify one or more initial terms Specify rule for obtaining subsequent terms.
MATH 310, FALL 2003 (Combinatorial Problem Solving) Lecture 38, Friday, December 5.
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.
Chapter 8 With Question/Answer Animations 1. Chapter Summary Applications of Recurrence Relations Solving Linear Recurrence Relations Homogeneous Recurrence.
Basic Mechanical Engineering Courses
1 Linear Recurrence Relations Part I Jorge Cobb The University of Texas at Dallas.
Applied Discrete Mathematics Week 9: Relations
Advanced Counting Techniques
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.
Chap. 7 (c) , Michael P. Frank1 Chapter 7: Advanced Counting Techniques.
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.
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.
Module #20 - Recurrences 1 Ch. 7 Recurrence Relations Rosen 6 th ed., §§7.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., §
RECURRENCE Sequence Recursively defined sequence
Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 1/18 Module.
Chapter 7 Advance Counting Techniques. Content Recurrence relations Generating function The principle of inclusion-exclusion.
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.
Recurrence Relation Models
after UCI ICS/Math 6A, Summer AdvancedCounting -1 Recurrence Relations (RRs) A “Recurrence Relation”
Advanced Counting Techniques CSC-2259 Discrete Structures Konstantin Busch - LSU1.
Chapter 6.1: Recurrence Relations Discrete Mathematical Structures: Theory and Applications.
Module #20 - Recurrences Solving Recurrences Rosen 6 th ed., §7.2.
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.
Agenda Lecture Content:  Recurrence Relations  Solving Recurrence Relations  Iteration  Linear homogenous recurrence relation of order k with constant.
Recurrence Relations. Outline Recurrence relationsSolving recurrence relationsRecurrence and Divide-and-conquer algorithmsGenerating functions
RECURRENCE Sequence Recursively defined sequence
Mathematical Analysis of Recursive Algorithm CSG3F3 Lecture 7.
Advanced Algorithms Analysis and Design By Dr. Nazir Ahmad Zafar Dr Nazir A. Zafar Advanced Algorithms Analysis and Design.
Advanced Algorithms Analysis and Design By Dr. Nazir Ahmad Zafar Dr Nazir A. Zafar Advanced Algorithms Analysis and Design.
Discrete Math For Computing II. Contact Information B. Prabhakaran Department of Computer Science University of Texas at Dallas Mail Station EC 31, PO.
CSG523/ Desain dan Analisis Algoritma
CSG523/ Desain dan Analisis Algoritma
CMSC Discrete Structures
Recursion and Recurrence Relations
Modeling with Recurrence Relations
A0=0 a1=2 an a2=6 an-1 a3=12 a4=20 a2 a1 a0.
Introduction to Recurrence Relations
UNIT-6 Recurrence Relations
Module #17: Recurrence Relations
Module #17: Recurrence Relations
Recursion and Recurrence Relations
CS 2210 Discrete Structures Advanced Counting
CMSC Discrete Structures
Solving Recurrence Relations
CMSC Discrete Structures
Recurrence Relations Discrete Structures.
Chapter 7 Advanced Counting Techniques
Recurrence Relations (RRs)
Recurrence Relations.
Recurrence Relations Rosen 5th ed., §6.2 5/22/2019
ICS 253: Discrete Structures I
Presentation transcript:

CHAPTER TWO RECURRENCE RELATION BY Dwee

Background Computer programming Given a function to find faktorial n! in Pascal We can make this function in another way, which is defined by recalling itself (recursive function) function faktorial(n:integer):longint; Var i:integer; Begin faktorial:=1; for i:=1 to n do faktorial:=faktorial*i; End;

Background Recursive function This function is more simple but sometimes it use more memory than the function before Some time we can solve a problem easily by recursive function than using iteration function faktorial(n:integer):longint; Begin if n=1 then faktorial:=1 else faktorial:=n*faktorial(n-1); End;

Background After this course, you should be able to Solve a some simple kinds of recurrrence relation Use forward and backward subtition to find the solution of recurrence relation Make recurrence relation model from a problem Solve 1st and 2nd order homogenous linear recurrence relation with constant coeficient Solve 1st and 2nd order non-homogenous linear recurrence relation with constant coeficient

INTRODUCTION Let a geometric series: 5, 15, 45, 135, …. If we write the terms as a1, a2, a3, …, an we have a2/a1=a3/a2=a4/a3=….=an/an-1=3 or we can write the relation between the terms in recurrence relation as an = 3 an-1, n  0 (*) But recurrence relation (*) doesn’t define a unique geometric series, because 1,3,9, 27 ,…. also satisfy the relation. To pinpoint the particular sequence described by an = 3 an-1, n  0, we need to know one of the terms of that sequence

INTRODUCTION Hence:, an = 3 an-1, n  0, a0=5 uniquely define sequence 5, 15, 45, ….

Recurrence Relation Recurence Relation : a relation that describe a function a(n), written as an, n 0, where an is depend on the the prior terms an-1, an-2, an-3, …, a1, a0. Example: Fibonacci Series: 1, 1, 2, 3, 5, 8, …. By recurence relation it is given as a0= 1, a1=1, an=an-1+an-2 (n2)

Recurrence Relation Recurrence Relation consists of two parts A set of initial or boundary condition A rule or recurrence part Example: Fibonacci series an=an-1+an-2 (recurrence part) with a0= 1, a1=1,(n2) (initial condition)

Recurrence Relation Solution of recurrence relation Example: General Solution Iterative procedure computing Forward subtitution Backward subtitution Example: Find the general solution of recurrence relation a. an= 3an-1, a1= 2, n2 b. an = an-1 + n, a0=0, n1 c. an = 2an-1 + 1, a0=0, n1

Recurrence Relation Example: Find a8 from this recurrence relation using Forward and Backward subtitution a0= 1, a1=1, an=an-1+an-2 (n2) Find a6 from this recurrence relation using forward and backward subtitution with a1 =1, a2=1, n n3

Modelling Problems to Recurrence Relation A Bank pay 6% annual interest in savings, compounding the interest monthly. If Bonnie deposits $1000 on the first day on May, how much will this deposit b e worth a year later? Express the problem in the recurrence relation first. Find a recurrence relation for the number of regions into which the plane is divided by n straight lines if every pair of lines intersect, but no three lines, meet the common point Find a Recurrence Relation for the number of n digits binary sequences with no consecutive ones.

Modelling Problems to Recurrence Relation Recurrence Relation with more than one variable Examples: Pascal Identity C(n,r) = C(n-1, r-1) + C(n-1,r) with boundary condition C(n,0)=1 and C(n,n)= 1. Use backward subtition to find C(5,4) by this recurrence relation! Example: Find Recurrence relation for P(n,r) the number of r-permutation from {x1, x2, …, xn}!

Linear Recurrence Relation with Constant Coefficient General linear recurrence relation of degree k an + h1(n) an-1+ h2(n)an-2 + …+ hr(n)an-k=f(n) where h and f are functions and hr  0. If f(n) = 0 then the relation is called homogeneous, otherwise the relation is inhomogenous. And f is called inhomogenous part. If h’s are constant functions then the relation is called linear recurrence relation with constant coefficient.

Linear Recurrence Relation with Constant Coefficient A well defined linear recurrence relation of degree k consist of a recurrence relation part and k initial condition for k consecutive values  define one and only one function (solution) Example : an – 5 an-1 + 6 an-2 = 0 is satisfied by an = C12n + C23n for any coonstant C1 and C2. Let initial condition are a0 = 2 and a1=5, we need a0 = 2 = C120 + C230  2 = C1 + C2 a1 = 5 = C121 + C231  5 = 2C1 + 3C2 this system has the solution C1=1 and C2 = 1. So the solution of the recurrence relation is an = 2n + 3n

Linear Recurrence Relation with Constant Coefficient Given a recurrence part of degree k, the strategy is to find a solution with k arbitrary constant C1, C2, …, Ck such that we can satisfy any set of k consecutive initial condition by solving a system of k simultaneous equation (one for each initial condition) in k unknowns (Ci) Such a solution is called a general solution

Homogenous Linear Recurrence Relation with Constant Coefficient : The Method of Characteristic Root Superposition Principle: If g1(n) is a solution of an + c1 an-1+ c2an-2 + …+ ckan-k=f1(n) and if g2(n) is a solution of an + c1 an-1+ c2an-2 + …+ ckan-k=f2(n) then C1g1(n) +C2 g2(n) is a solution of an + c1 an-1+ c2an-2 + …+ ckan-k=C1 f1(n)+ C2 f2(n) for any constant C1 and C2

Its follow immediately if g1 (n), g2(n), …, gk(n) are solutions of an + c1 an-1+ c2an-2 + …+ ckan-k=0 then so is C1g1 (n)+ C2g2(n)+ …+Ck gk(n) How do we find different solution gi(n)? One of the choice is to look for solution in form rn for some number r

Homogenous Linear Recurrence Relation with Constant Coefficient : The Method of Characteristic Root Given Recurrence relation: an + c1 an-1+ c2an-2 + …+ ckan-k=0 Let an = rn , subtituting to the recurrence relation yields rn + c1rn-1+ c2rn-2 + …+ ckrn-k=0 rn-k(rk + c1rk-1+ c2rk-2 + …+ ck)=0 rk + c1rk-1+ c2rk-2 + …+ ck=0 The last equation is called by characteristic equation. Its roots are called characteristic roots. Base on the characteristic roots, we have two case of the solutions Case 1 : All the roots are distinct Case 2 :There are some multiplicity roots

Homogenous Linear Recurrence Relation with Constant Coefficient : The Method of Characteristic Root Case 1: All of characteristic roots are distinct If r1, r2, …, rk is distinct characteristic root, so by using superposition principle, the general solution of the recurrence relation is an = C1r1n + C2r2n+…+Ckrkn Example: Solve the recurrence relation 1) an + an-1 – 6 an-2 = 0, a0=1, a1=2, n2 2) an = an-1 + an-2, a0=0, a1=1, n2 (Fibonacci series) 3) an=2an-1+an-2-2an-3 , a0 =0, a1=1, a2=1, n3

Homogenous Linear Recurrence Relation with Constant Coefficient : The Method of Characteristic Root If the charactristic roots are complex numbers Recall De Moivre’s Theorem: (cos  + i sin )n = cos n+ i sin (n). If z = x + iy, we can write z = r (cos + i sin ) where r = sqrt(x2+ y2) and (y/x) = tan  then zn = (r (cos + i sin ) )n= rn (cos n+ i sin n). Example: Solve the recurrence relation an = 2an-1-2an-2 , a0=1, a1=2, n2

Homogenous Linear Recurrence Relation with Constant Coefficient : The Method of Characteristic Root Case 2: The characteristic equation has multiplicity roots Example: Solve the recurrence relation an = 4an-1-4an-2 , a0 =1, a1=3, n2

If r is a characteristic root of multiplicity m, then it contributes m solution: rn, nrn, n2rn, …, nm-1rn. Examples: Solve The recurrence relation a0=1, a1=1, a2=2, an = 4an-1-5an-2+2an-3

Inhomogeneous Recurrence Relation Towers of Hanoi. Consider n circular disks (having different diameters) with holes in their centers. These disks can be stacked on any of the pegs shown in Fig. 10.11. In the figure, n = 5 and the disks are stacked on peg 1 with no disk resting upon a smaller one. The objective is to transfer the disks one at a time so that we end up with the original stack on peg 3. Each of pegs 1, 2, and 3 may be used as a temporary location for any disk(s), but at no time are we allowed to have a larger disk on top of a smaller one on any peg. What is the minimum number of moves needed to do this for n disks?

Inhomogeneous Linear Recurrence Relation with Constant Coefficient Recurrence relation: an + c1 an-1+ c2an-2 + …+ ckan-k= f(n) with r consecutive initial conditions Our strategy is the same as that used in the homogeneous case. Find the general solution to the recurrene part, and use the initial condition to set up a system of simultaneous equation By superposition principle: If anh is the solution of an + c1 an-1+ c2an-2 + …+ ckan-k= 0 and if anp is the solution of an + c1 an-1+ c2an-2 + …+ ckan-k= f(n) then anh + anp is also the solution of the recurence relation

Inhomogeneous Linear Recurrence Relation with Constant Coefficient anh is homogeneous part solution and anp is particular solution How to find anh ? Using characteristic equation How to find anp? No general method, but some techniques are available for certain special case (method of undetermined coefficient). Example: Solve the recurrence relation: an- 3an-1=5 (7)n, a0=2, n1 Solve the recurrence relation: an+3an-1=4n2-2n, a1=-4, n2 Solve the recurrence relation: an- 4an-1+4an-2= 2n, a0=0 a1=1, n2

Inhomogeneous Linear Recurrence Relation with Constant Coefficient Solve the recurrence relation :an- 3an-1=5 (7)n, a0=2, n1 Answer: Homogenous part: an- 3an-1=0 Characteristic equation: r-3=0, charactristic root :r=3 Homogenous part solution: G(n)=c3n Inhomogenous part: an- 3an-1=5(7)n We are “guessing” that the particular solution p(n)=A(7n) Subtituting p(n) into RR: A(7n)-3 A(7n-1)=5 (7n) 7n-1 (7A-3A)=7n-1(5.7) 4A = 35 A=35/4 General solution: an = G(n)+p(n) = c 3n + 35/4 (7)n with a0 = 2, we get c= … so the solution is an = …..

Inhomogeneous Linear Recurrence Relation with Constant Coefficient Solve the recurrence relation: an+3an-1=4n2-2n, a1=-4, n2 Answer: Homogenous part: an+3an-1=0 Homogenous part solution: G(n)=c1(-3)n Inhomogenous part: an+3an-1=4n2-2n Particular solution is polunomial of degree 2 or higher Guess that p(n) is polynomial of degree 2, p(n) = An2+Bn+C. Subtituting p(n) the RR: An2+Bn+C + 3(A(n-1)2+B(n-1)+C)= 4n2-2n 4An2+(4B-6A)n+(3A-3B+4C)=4n2-2n Solving the equation ,we have: A=1, B=1, C=0. The particular solution is p(n) = n2+n General solution is an=G(n)+p(n)= c1(-3)n + n2+n Find the solution based on the initial condition

Answer: Solve the recurrence relation an-an-1=n, a0=1, n1 Homogenous part: an-an-1= 0 Homogenous part splution part: anh = c(1)n=c Inhomogenous part: an-an-1=n Because f(n) =n so the particular solution is polynomial of degree 1 or higher. Find the particular solution using guess p(n) = An +B p(n)= An2 +Bn +C which one give the solution? Why?

Inhomogeneous Linear Recurrence Relation with Constant Coefficient How to determine the degree of the polynomial guess? The degree of anp is the degree of f(n) plus the multilicity of 1 in the characteristic equation If 1 is not a root of characteristic equation, the degree of anp is the degree of f Similarly if f(n) is of the form rn, then the particular solution will be Ankrn, where k is the multiplicity of r in the characteristic equation

Inhomogeneous Linear Recurrence Relation with Constant Coefficient Solve the recurrence relation an- 4an-1+4an-2= 2n, a0=0 a1=1, n2 Answer: Homogenous part: an- 4an-1+4an-2= 0 Characteristic equation: r2 – 4r + 4 = 0 Characteristic root: r = 2 (multiplicity of degree 2) Homogenous part solution: G(n) = …… Inhomogeneous part: an- 4an-1+4an-2= 2n Particular solution is p(n)= … The general solution is an = ….

Given a linear nonhomogeneous recurrence relation (with constant coefficients) of the form C0an + C1an- 1 + C2an-2 + • • • + Ckan-k = f(n) Let Gn denote the homogeneous part of the solution an.

EXERCISE. a0=1, an-an-1= n2 a0=1,a1=2, an-5an-1+6an-2 = 2n+1, n>=2 a0=4, an-an-1=2n2-n-1, n>=1 a0=1, a1=0, an-2an-1+an-2=2, n>=2 a0=1, an+3an-1 =2n, n>=1 a0=1, an+2an-1=2n-n2 , n>=1