Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Agenda Lecture Content:  Recurrence Relations  Solving Recurrence Relations  Iteration  Linear homogenous recurrence relation of order k with constant."— Presentation transcript:

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

2 Recurrence Relations

3  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

4 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

5 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.

6 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.

7 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, …

8 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

9 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

10 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

11 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-1 + 0.11 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)

12 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,000 4. return 1.11 * compound_interest (n-1) 5.}

13 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

14 Modeling with Recurrence Relation (3) Month reproducing pairs young pairs total pairs 1011 2011 3112 4123 5235 6358

15 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

16 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.

17 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-41 1 1 0 1 0 1 0 1 0 1 0 1 1 1 0 0 1 There are eight bit strings

18 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

19 Solving Recurrence Relations

20 -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

21 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.

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

23 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

24 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

25 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 ) = 1.1 2 * a n-2  a n = 1.1 n * a 0  a n = 1.1 n * 1000

26 Recurrence Relations with Constant Coefficients

27 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

28 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?

29 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.

30 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 1 + 6 = 0. Solving this, we find the solutions t= 2, t= 3. Characteristic polynomial Characteristic roots

31 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.

32 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, ….

33 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, ….

34 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.

35 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 = 180 + 20∙2 n.

36 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.

37 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, ….

38 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.

39 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.


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

Similar presentations


Ads by Google