Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 RECURRENCE 1. Sequence 2. Recursively defined sequence 3. Finding an explicit formula for recurrence relation.

Similar presentations


Presentation on theme: "1 RECURRENCE 1. Sequence 2. Recursively defined sequence 3. Finding an explicit formula for recurrence relation."— Presentation transcript:

1 1 RECURRENCE 1. Sequence 2. Recursively defined sequence 3. Finding an explicit formula for recurrence relation

2 2 Learning Outcomes You should be able to solve first-order and second-order linear homogeneous recurrence relation with constant coefficients

3 3 Preamble What is recurrence and how does it relate to a sequence?

4 4 Sequences A sequence is an ordered list of objects (or events). Like a set, it contains members (also called terms)setmembers Sequences can be finite or infinite.finiteinfinite 2,4,6,8, … for i ≥ 1 a i = 2 i (explicit formula) infinite sequence with infinite distinct values -1,1,-1,1, … for i ≥ 1 b i = (-1) i infinite sequence with finite distinct values For 1<= i <=6 c i = i +5 finite sequence (with finite distinct values) 6,7,8,9,10,11

5 5 Ways to define sequence Write the first few terms: 3,5,7,… Use explicit formula for its nth term a n = 2n for n ≥ 1 Use recursion How to define a sequence using a recursion?

6 6 Recursively defined sequences Recursion can be used to defined a sequence. This requires: A recurrence relation: a formula that relates each term a k to some previous terms a k-1, a k-2, … ak = a k-1 + 2a k-2 The initial conditions: the values of the first few terms a 0, a 1, … Example: For all integers k ≥ 2, find the terms b 2, b 3 and b 4 : b k = b k-1 + b k-2 (recurrence relation) b 0 = 1 and b 1 = 3 (initial conditions) Solution: b 2 = b 1 + b 0 = 3 + 1 = 4 b 3 = b 2 + b 1 = 4 + 3 = 7 b 4 = b 3 + b 2 = 7 + 4 = 11

7 7 Explicit formula and recurrence relation Show that the sequence 1,-1!,2!,-3!,4!,…,(-1) n n!,… for n≥0, satisfies the recurrence relation s k = (-k)s k-1 for all integers k≥1. The general term of the sequence: s n =(-1) n n! substitute k and k-1 for n to get s k =(-1) k k! s k-1 =(-1) k-1 (k-1)! Substitute s k-1 into recurrence relation: (-k)s k-1 = (-k)(-1) k-1 (k-1)! = (-1)k(-1) k-1 (k-1)! = (-1)(-1) k-1 k(k-1)! = (-1) k k! = s k

8 8 Examples of recursively sequence Famous recurrences Arithmetic sequences: e.g. 1,4,7,10,13,… geometric sequences: e.g. 1,3,9,27,… Factorial: f(n) = n. f(n-1) Fibonacci numbers: 1,1,2,3,5,8,… Tower of Hanoi problem

9 9 Application of recurrence Analysis of algorithm containing recursive function such as factorial function. Algorithm f(n) /input: A nonnegative integer /output: The value of n! If n = 0 return 1 else return f(n-1)*n No. of operations (multiplication) determines the efficiency of algo. Recurrence relation is used to express the no. of operation in the algorithm.

10 10 Solving Recurrence relation by Iteration It is helpful to know an explicit formula for a sequence. An explicit formula is called a solution to the recurrence relation Most basic method is iteration - start from the initial condition - calculate successive terms until a pattern can be seen - guess an explicit formula

11 11 Some examples Let a 0,a 1,a 2,… be the sequence defined recursively as follows: For all integers k≥1, (1) a k = a k-1 +2 (2) a 0 = 1 Use iteration to guess an explicit formula for the sequence. a 0 =1 a 1 =a 0 +2 a 2 =a 1 +2=(1+2)+2 = 1+2.2 a 3 =a 2 +2=(1+2.2)+2 = 1+3.2 a 4 =a 3 +2=(1+3.2)+2 = 1+4.3 …. Guess: a n =1+n.2=1+2n The above sequence is an arithmetic sequence.

12 12

13 13 Geometric Sequence Let r be a fixed nonzero constant, and suppose a sequence a 0,a 1,a 2,… is defined as follows: a k = ra k-1 for all integers k ≥ 1 a 0 = a Use iteration to guess an explicit formula for the sequence a 0 =a a 1 =ra 0 =ra a 2 =ra 1 =r(ra)=r 2 a a 3 =ra 2 =r(r 2 a)=r 3 a Guess: a n =r n a = ar n for all integers n≥0 The above sequence is geometric sequence and r is a common ratio.

14 14 Second-Order Linear Homogeneous with constant coefficients A second-order linear homogeneous recur. relation with c.c. is a recur. relation of the form a k = Aa k-1 + Ba k-2 for all integers k ≥ some fixed integer, where A and B are fixed real numbers with B ≠ 0.

15 15 Terminology a k = Aa k-1 + Ba k-2 Second order: a k contains the two previous terms Linear: a k-1 and a k-2 appear in separate terms and to the first power Homogeneous: total degree of each term is the same (no constant term) Constant coefficients: A and B are fixed real numbers

16 16 Examples Second-Order Linear Homogeneous with constant coefficients a k = 3a k-1 + 2a k-2 - yes. b k = b k-1 + b k-2 + b k-3 - no d k = (d k-1 ) 2 + d k-1 d k-2 - no; not linear e k = 2e k-2 - yes; A = 0, B = 2. f k = 2f k-1 + 1 - no; not homogeneous

17 17 Distinct-Roots Case


Download ppt "1 RECURRENCE 1. Sequence 2. Recursively defined sequence 3. Finding an explicit formula for recurrence relation."

Similar presentations


Ads by Google