Download presentation
Presentation is loading. Please wait.
Published byLaureen Payne Modified over 9 years ago
1
Internet Engineering Czesław Smutnicki Discrete Mathematics – Recursive Equations
2
CONTENT S Recursive equations Generating functions
3
HANOI TOWERS ABC
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 C1 move KROK 3: 3 upper discs from B on C (alg. ALG(3))lr(3) --------------------- lr(4)=2lr(3)+1
5
HANOI TOWERS cont. n012345678 lr(n)0137153164127255 Generally lr(n)=2lr(n-1)+1=2n-1 with initial condition lr(0)=0.
6
FIBONACCI NUMBERS Fibonacci numbers 11 2 3 5 8 13 21 34 55 89... a)Recursive formula F 1 = 1;F 2 = 1; F n = F n-1 + F n-2, dla n > 2 b) Analytically
7
RABBITS M M M M M M M R RARA RARA RARA RARA RARA RARA RARA RARA RARA RARA M RARA pary 1 1 2 3 5 8 okresy 1 2 3 4 5 6
8
CIRCLES 1 = 2 0 1 + 1 = 2 = 2 1 1 + 2 + 1 = 4 = 2 2 2 1 2 4 1 3 Similarly for n=3 we have: 1 + 3 + 3 + 1 = 8 = 2 3 for n=4 we have: 1 + 4 + 6 + 4 +1 = 16 = 2 4
9
SOLUTION METHOD. CASE STUDY I Given recursive sequence: (1) a n = 2 a n-1 + 1, n > 1 with initial value a 1 =1 The sequence starts from: 1, 3, 7, 15, 31, 63.... Find algebraic formula for the n-th element of the sequence. For n-1 we have: a n-1 =2 a n-2 + 1, which we substitute into equation (1). Such substitution we continue until we obtain a 1, so a n = 2·a n-1 + 1 = 2·(2·a n-2 + 1) + 1 = 2 2 ·a n-2 + 2 + 1 = = 2 2 ·(2·a n-3 + 1) + 2 + 1 = 2 3 ·a n-3 + 2 2 + 2 1 + 2 0 =... = 2 k a n-k + 2 k-1 + 2 k-2 +... + 2 2 + 2 1 + 2 0 = = 2 n-1 + 2 n-2 +... + 2 2 + 2 1 + 2 0 = 2 n – 1
10
SOLUTION METHOD. CASE STUDY I. cont This is the sum of a geometric sequence with the ratio q=a i+1 /a i =2 and a 1 =1; so S= (1-2 n )/(1-2) = - (1-2 n ) = 2 n –1. Therefore a n =2 n –1. We can check this below. n a n =2a n-1 + 1a n = 2 n - 1 1234512345 1 2*1 + 1 = 3 2*3 + 3 = 7 2*7 + 1 = 15 2*15 + 1 = 31 1 2 2 – 1=3 2 3 –1 =7 2 4 – 1=15 2 5 – 1=31
11
SOLUTION METHOD. CASE STUDY II. Consider the equation: s n = as n-1 + bs n-2 where values s 0 and s 1 are known, and a,b - are certain constants Case a) either a = 0 or b = 0 If b=0 then s n = as n-1 for n 1. Therefore s 1 = as 0, s 2 = as 1 = a 2 s 0,... and finally s n = a n s 0. If a = 0 then s n = bs n-2 for n 2. Therefore s 2 =bs 0, s 4 =bs 2 =b 2 s 0 and finally … s 2n =b n s 0 n N Similarly s 3 = bs 1, s 5 = bs 3 = b 2 s 1 and finally s 2n+1 = b n s 1 n N
12
SOLUTION METHOD. CASE STUDY II. cont Case b) a ≠ 0 or b ≠ 0 has characteristics equation x 2 - ax - b = 0 This equation follows from the suppositionfor the given constant c. Hence dividing by C we obtain then r is the root of the equation x 2 - ax - b = 0
13
Thank you for your attention DISCRETE MATHEMATICS Czesław Smutnicki
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.