Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Recurrence Relations

Similar presentations


Presentation on theme: "Introduction to Recurrence Relations"— Presentation transcript:

1 Introduction to Recurrence Relations
12 Introduction to Recurrence Relations Discrete Mathematics: A Concept-based Approach

2 The concept of recurrence relations deals with recursive definitions of mathematical functions or sequences. Solving a recurrence relation involves, in finding "closed form“ solution of the function. Recurrence relations are a fundamental mathematical tool since they can be used to represent mathematical functions/sequences that cannot be easily represented non-recursively. An example, is the Fibonacci sequence. Recurrence relations are largely employed in the design and analysis of algorithms. Discrete Mathematics: A Concept-based Approach

3 Concept of Recurrence relation :
A recurrence relation relates the nth term of a sequence to some of its preceding terms. Consider a function a(n), which is a sequence of terms a0 , a1, … an-1. The term an depends upon the previous terms a0 , a1, … an-1. This way of study is called recurrence relation or difference equations, which is considered discrete counterpart to what is studied in differential equations. The recurrence relations can be adapted to suit the needs of particular counting problems. Example: The recurrence relation that defines the famous Fibonacci sequence 1, 1, 2, 3, 5, 8, 13, …… is given by f(n) = f(n-1) + f(n-2) with initial conditions f(1) = 1, f(0) = 1. Discrete Mathematics: A Concept-based Approach

4 General Solution: The general solution to the recurrence relation is given as an+1 = d an, where (n  0), d is a constant and a0 = A is unique constant. Given a particular recurrence relation and certain initial conditions, we are supposed to devise a formula for the nth term. Consider the recurrence relation of the form an = r an-1 + s an-2 + f(n) where, r and s are constants and f(n) is some function of n. This type of recurrence relation is called second order linear recurrence relation with constant coefficients. If f(n) = 0, the recurrence relation is called homogeneous. Discrete Mathematics: A Concept-based Approach

5 Consider the homogeneous recurrence relation an - r an-1 - s an-2 = 0
Consider the homogeneous recurrence relation an - r an-1 - s an-2 = 0. We associate the quadratic equation x2 –rx –s = 0 with the above and is called the characteristic polynomial of the recurrence relation. Its roots are called the characteristics roots of the recurrence relation. For example, the recurrence relation an = 5 an an-2 has the characteristic equation x2 -5x + 6 = 0 and the characteristic roots are 2 and 3. If x1 and x2 are the roots of the characteristic polynomial x2 –rx –s = 0, then the solution of the recurrence relation an = r an-1 + s an-2, for (n ≥ 2) is expressed as an = c1x1n + c2x2n if x1 ≠ x2 ( for complex roots also i.e. x = a + ib ) = (c1 + c2 n) xn if x1 = x2 = x . c1 and c2 are arbitrary constants determined by initial conditions.0 Discrete Mathematics: A Concept-based Approach

6 Example: A bank pays 6% interest on savings, compounding the interest monthly. If Shankar deposits Rs 1000 on the first day of May, how much will this deposit be worth after a year later? Solution: The annual interest is 6%, so the monthly interest rate is 6%/12 = 0.5% = For 0 ≤ n ≤ 12, let Pn denote the value of Shankar’s deposit after n months. We can write the relation as under. Pn+1 = Pn + (0.005)Pn . Here the term (0.005)Pn is the interest earned on Pn during the month (n+1), for 0 ≤ n ≤ 11 and P0 = Rs The relation Pn+1 = ( )Pn , Pn = P0 (1.005)n = 1000(1.005)n. The deposit of Shankar at the end of one year is Rs Discrete Mathematics: A Concept-based Approach

7 Example : A particle is moving in the horizontal direction
Example : A particle is moving in the horizontal direction. The distance it travels in each second is equal to 3 times the distance it traveled in the previous second. If an –denotes the position of the particle in the n-th second, determine an ,given that a0 = 3, a3= 10. Solution: Let ar , ar+1 , ar+2 be the positions of the particle in the n-th (n+1)th, and (n+2) th seconds of its motion. Then by the problem ar+2 – ar+1= 3 ( ar+1 - ar). ar+2 –4 ar+1+ 3 ar+1 +3 ar= 0.The characteristic equation is given by m2 - 4m +3 = 0.. m = 1,3.The solution is given by an = c1 (1)n c2 (3)n. Using initial conditions to determine the arbitrary constants, we get c1 = 71/26 , c2 = 7/26. The solution is given by an = 71/26 (1)n + 7/26 (3)n = The distance traveled by a particle in n-th second. Discrete Mathematics: A Concept-based Approach

8 Non-homogeneous Recurrence Relations:
The general form of linear non-homogeneous recurrence relation is given by Where c1,c2, ----ck are constants. The corresponding homogeneous recurrence relation is, The general solution to an inhomogeneous linear recurrence relation takes the form of a particular solution added to an arbitrary linear combination of solutions to the associated homogeneous linear recurrence relation .Once the homogeneous equation has been solved it is relatively easy to find the general solution of the inhomogeneous equation. Discrete Mathematics: A Concept-based Approach

9 Method of undetermined co-efficient:
The following rules helps to find particular solutions in all possible cases. If k– is not a root of the characteristic equation , the particular solution is obtained of the form If and 1- is not a root of homogeneous recurrence relation, the particular solution is obtained in the form Discrete Mathematics: A Concept-based Approach

10 If g(n) = kn and k – is not a root of characteristic equation the particular solution is obtained in the form If where k- is a root of characteristic equation repeated l-times, the particular solution is obtained in the form If and 1- is a root of characteristic equation repeated l-times, the particular solution is obtained in the form If g(n) = kn where k- is a root of characteristic equation repeated l-times then particular solution is given an = d0 nl kn. Discrete Mathematics: A Concept-based Approach

11 Example: Find the general solution of The characteristics equation r (r+5) – 2 (r+5) = 0, r = 2, -5. The solution due to homogeneous equation. anh = c1 (2)n + c2 (-5)n. Let the particular solution be anp = A + B n + Cn2 . Substituting particular solution in the recurrence relation (I). Discrete Mathematics: A Concept-based Approach

12 Rearranging the terms. Equating the coefficients of powers of n we get
A + Bn + C n2 +3 [A + B(n-1) +C(n-1)2] – 10[ A + B (n-2) + C (n-2)2] = n2 +n +1. Rearranging the terms. 6A + 17B - 37C + (-6B +34 C ) n – 6 C n2 = 1 + n + n2 Equating the coefficients of powers of n we get -6A + 17 B-37 C = 1; coefficient of n0 -6B + 34 C = 1 : coefficient of n1 -6C = 1: coefficient of n2 Solving we get The particular solution is given by Discrete Mathematics: A Concept-based Approach

13 The General solution is given by
Discrete Mathematics: A Concept-based Approach

14 Tower of Hanoi: The Tower of Hanoi is a neat little puzzle invented by the French mathematician Édouard Lucas in We are given a tower of r disks, initially stacked in decreasing size on one of three pegs. The objective is to transfer an entire tower to one of the other pegs, moving only one disk at a time and never moving a larger one onto a smaller. What is the minimum number of moves required?. It is shown in below. Discrete Mathematics: A Concept-based Approach

15 Solution: Let Tn be the minimum number of moves that will transfer n disks from one peg to another under Lucas’s rules. It is advantageous to look at small cases first. It is easy to see that T1 = 1 and T2 = 3. Here is one of the methods to transfer n (n ≥ 2) disks: We first transfer the (n – 1) smallest to a different peg (requiring at least Tn − 1 moves), then move the largest (requiring one move), and finally transfer the (n−1) smallest back onto the largest (requiring at least another Tn −1 moves). It follows that Tn ≤ 2Tn − We now show that there can be no shorter way. No matter what method we use to transfer the disks, at some point we must move the largest disk. Discrete Mathematics: A Concept-based Approach

16 When we do, then the other n − 1 smaller disks must be on a single peg, and it must have taken at least Tn − 1 moves to put them there. After moving the largest disk, we must transfer the (n – 1) smaller disks (which must again be on a single peg) back onto the largest; this too requires at least Tn − 1 moves. Hence Tn ≥ 2Tn − 1+1. Thus, we have the recurrence relation Tn = 2Tn − 1+1 with initial condition T1 = 1. We shall show later that Tn = 2n − 1 for n = 1, 2, .... Discrete Mathematics: A Concept-based Approach

17 Summary: The recurrence relations are the extensions of recursive functions and are the useful mathematical concepts in computer science while analyzing the algorithms. Divide and conquer algorithms are analyzed based on recurrence relations. Some of the best-known difference equations have their origins in the attempt to model population dynamics. For example, the Fibonacci numbers were once used as a model for the growth of a rabbit population. In digital signal processing ,recurrence relations can model feedback in a system, where outputs at one time become inputs for future time. These arise in infinite impulse response (IIR) digital filters. Discrete Mathematics: A Concept-based Approach


Download ppt "Introduction to Recurrence Relations"

Similar presentations


Ads by Google