Presentation is loading. Please wait.

Presentation is loading. Please wait.

RECURRENCE Sequence Recursively defined sequence

Similar presentations


Presentation on theme: "RECURRENCE Sequence Recursively defined sequence"— Presentation transcript:

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

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

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

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

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

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

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

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

9 Tower of Hanoi

10

11

12

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

14 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

15 Some examples Let a0,a1,a2,… be the sequence defined recursively as follows: For all integers k≥1, (1) ak = ak-1+2 (2) a0 = 1 Use iteration to guess an explicit formula for the sequence. a0=1 a1=a0+2 a2=a1+2=(1+2)+2 = 1+2.2 a3=a2+2=(1+2.2)+2 = 1+3.2 a4=a3+2=(1+3.2)+2 = 1+4.3 …. Guess: an=1+n.2=1+2n The above sequence is an arithmetic sequence.

16 Geometric Sequence Let r be a fixed nonzero constant, and suppose a sequence a0,a1,a2,… is defined as follows: ak = rak-1 for all integers k ≥ 1 a0 = a Use iteration to guess an explicit formula for the sequence a0=a a1=ra0=ra a2=ra1=r(ra)=r2a a3=ra2=r(r2a)=r3a Guess: an=rna = arn for all integers n≥0 The above sequence is geometric sequence and r is a common ratio.

17

18 Explicit formula for tower of Hanoi
mn = 2n – 1. (exponential order) To move 1 disk takes 1 second m64 = 264 –1 = * 1019 seconds = * 1011 years = billion years.

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

20 Terminology ak = Aak-1 + Bak-2
Second order: ak contains the two previous terms Linear: ak-1 and ak-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

21 Examples Second-Order Linear Homogeneous with constant coefficients
ak = 3ak-1 + 2ak yes. bk = bk-1 + bk-2 + bk-3 - no dk = (dk-1)2 + dk-1dk no; not linear ek = 2ek yes; A = 0, B = 2. fk = 2fk no; not homogeneous

22 Distinct-Roots Case


Download ppt "RECURRENCE Sequence Recursively defined sequence"

Similar presentations


Ads by Google