Presentation is loading. Please wait.

Presentation is loading. Please wait.

Opracowanie językowe dr inż. J. Jarnicki

Similar presentations


Presentation on theme: "Opracowanie językowe dr inż. J. Jarnicki"— Presentation transcript:

1 Opracowanie językowe dr inż. J. Jarnicki
Internet Engineering Czesław Smutnicki Discrete Mathematics – Recursive Equations

2 CONTENTS Recursive equations Generating functions

3 HANOI TOWERS A B C

4 HANOI TOWERS cont. lr(n) – the number of moves (for n discs).
n=0, lr(0)=0 n=1 ALG(1) K1: move disc on C. lr(1)=1 n=2 ALG(2) K1: small on B; K2: large on C K3: small on C; lr(2)=3 n=3 ALG(3) K1: small on C; K2: medium on B K3: small on B K4: large on C K5: small on A K6: medium on C K7: small on C lr(3)=7 n=4 ALG(4) KROK 1: 3 upper discs from A on B (alg. ALG(3)) lr(3) KROK 2: large na C 1 move KROK 3: 3 upper discs from B on C (alg. ALG(3)) lr(3) lr(4)=2lr(3)+1

5 HANOI TOWERS cont. Generally
lr(n)=2lr(n-1)+1=2n-1 with initial condition lr(0)=0. n 1 2 3 4 5 6 7 8 lr(n) 15 31 64 127 255

6 FIBONACCI NUMBERS Fibonacci numbers 1 2 3 5 8 13 21 34 55 89 ...
Recursive formula F1 = 1; F2 = 1; Fn = Fn-1 + Fn-2 , dla n > 2 b) Analytically

7 RABBITS M R RA pary okresy

8 CIRCLES Similarly for n=3 we have: 1 + 3 + 3 + 1 = 8 = 23
1 = = 2 = = 4 = 22 2 1 4 3 Similarly for n=3 we have: = 8 = 23 for n=4 we have: = 16 = 24

9 SOLUTION METHOD. CASE STUDY I
Given recursive sequence: (1) an = 2 an-1 + 1, n > 1 with initial value a1=1 The sequence starts from: 1, 3, 7, 15, 31, Find algebraic formula for the n-th element of the sequence. For n-1 we have: a n-1 =2 an , which we substitute into equation (1). Such substitution we continue until we obtain a1, so an = 2·an = 2·(2·an-2 + 1) + 1 = 22·an = = 22·(2·an-3 + 1) = 23·an = = 2kan-k + 2k-1 + 2k = = 2n-1 + 2n = 2n – 1

10 SOLUTION METHOD. CASE STUDY I. cont
This is the sum of a geometric sequence with the ratio q=ai+1/ai =2 and a1=1; so S= (1-2n)/(1-2) = - (1-2n) = 2n –1. Therefore an=2n –1. We can check this below. n an=2an-1 + 1 an = 2n - 1 1 2 3 4 5 2*1 + 1 = 3 2*3 + 3 = 7 2*7 + 1 = 15 2* = 31 22 – 1=3 23 –1 =7 24 – 1=15 25 – 1=31

11 SOLUTION METHOD. CASE STUDY II.
Consider the equation: sn = asn bsn-2 where values s0 and s1 are known, and a,b - are certain constants Case a) either a = 0 or b = 0 If b=0 then sn = asn-1 for n  1. Therefore s1 = as0 , s2 = as1 = a2 s0, ... and finally sn = ans0. If a = 0 then sn = bsn-2 for n  2. Therefore s2=bs0 , s4=bs2 =b2s0 and finally … s2n =bns0 n  N Similarly s3 = bs1 , s5 = bs3 = b2s1 and finally s2n+1 = bns1 n  N

12 SOLUTION METHOD. CASE STUDY II. cont
Case b) a ≠ 0 or b ≠ 0 has characteristics equation x2 - ax - b = 0 This equation follows from the supposition for the given constant c. Hence dividing by C we obtain then r is the root of the equation x2 - ax - b = 0

13 Thank you for your attention
DISCRETE MATHEMATICS Czesław Smutnicki


Download ppt "Opracowanie językowe dr inż. J. Jarnicki"

Similar presentations


Ads by Google