Presentation is loading. Please wait.

Presentation is loading. Please wait.

Recurrences, Phi and CF Great Theoretical Ideas In Computer Science S. Rudich V. Adamchik CS 15-251 Spring 2006 Lecture 13 Feb 28, 2006 Carnegie Mellon.

Similar presentations


Presentation on theme: "Recurrences, Phi and CF Great Theoretical Ideas In Computer Science S. Rudich V. Adamchik CS 15-251 Spring 2006 Lecture 13 Feb 28, 2006 Carnegie Mellon."— Presentation transcript:

1

2 Recurrences, Phi and CF Great Theoretical Ideas In Computer Science S. Rudich V. Adamchik CS 15-251 Spring 2006 Lecture 13 Feb 28, 2006 Carnegie Mellon University

3 Solve in integers x 1 +x 2 +x 3 =11 x 1 r 0; x 2 b 3; x 3 r 0 Warm-up

4 Solve in integers x 1 +x 2 +x 3 =11 x 1 r 0; x 2 b 3; x 3 r 0 [X 11 ] Warm-up

5 Find the number of ways to make change for $1 using pennies, nickels, dimes and quarters Make Change (interview question)

6 Find the number of ways to make change for $1 using pennies, nickels, dimes and quarters [X 100 ] Make Change

7 Find the number of ways to make change for $1 using pennies, nickels, dimes and quarters Make Change

8 Find the number of ways to partition the integer n 3 = 1+1+1=1+2 4=1+1+1+1=1+1+2=1+3=2+2 Partitions

9 Find the number of ways to partition the integer n Partitions

10 Find the number of ways to partition the integer n Partitions

11 Leonardo Fibonacci In 1202, Fibonacci proposed a problem about the growth of rabbit populations.

12 The rabbit reproduction model A rabbit lives foreverA rabbit lives forever The population starts as a single newborn pairThe population starts as a single newborn pair Every month, each productive pair begets a new pair which will become productive after 2 months oldEvery month, each productive pair begets a new pair which will become productive after 2 months old F n = # of rabbit pairs at the beginning of the n th month month1234567 rabbit s 112358 13131313

13 F n is called the n th Fibonacci number month1234567 rabbit s 112358 13131313 F 0 =0, F 1 =1, and F n =F n-1 +F n-2 for n  2 F n is defined by a recurrence relation.

14 What is a closed form formula for F n ? F 0 =0, F 1 =1, F n =F n-1 +F n-2 for n  2

15 Techniques you have seen so far F n =F n-1 +F n-2 Consider solutions of the form: F n = c n for some constant c c must satisfy: c n - c n-1 - c n-2 = 0

16 iff iff c n-2 (c 2 - c - 1) = 0 iff c=0 or c 2 - c - 1 = 0 Iff c = 0, c = , or c = -1/   (“phi”) is the golden ratio

17 c = 0, c = , or c = -(1/  ) So for all these values of c the inductive condition is satisfied: c n - c n-1 - c n-2 = 0 Do any of them happen to satisfy the base condition as well? F 0 =0, F 1 =1

18  a,b a  n + b (-1/  ) n satisfies the inductive condition Adjust a and b to fit the base conditions. n=0: a+b = 0 n=1: a  1 + b (-1/  ) 1 = 1 a= 1/  5 b= -1/  5

19 Leonhard Euler (1765)

20 Fibonacci Power Series

21 Fibonacci Bamboozlement

22 Cassini’s Identity F n+1 F n-1 - F n 2 = (-1) n We dissect F n xF n square and rearrange pieces into F n+1 xF n-1 square

23 Golden Ratio Divine Proportion Ratio obtained when you divide a line segment into two unequal parts such that the ratio of the whole to the larger part is the same as the ratio of the larger to the smaller. ABC

24 Ratio of height of the person to height of a person’s navel

25 Aesthetics  plays a central role in renaissance art and architecture. After measuring the dimensions of pictures, cards, books, snuff boxes, writing paper, windows, and such, psychologist Gustav Fechner claimed that the preferred rectangle had sides in the golden ratio (1871).

26 Which is the most attractive rectangle?

27 Golden Rectangle 1 

28 Divina Proportione Luca Pacioli (1509) Pacioli devoted an entire book to the marvelous properties of . The book was illustrated by a friend of his named: Leonardo Da Vinci

29 Table of contents The first considerable effectThe first considerable effect The second essential effectThe second essential effect The third singular effectThe third singular effect The fourth ineffable effectThe fourth ineffable effect The fifth admirable effectThe fifth admirable effect The sixth inexpressible effectThe sixth inexpressible effect The seventh inestimable effectThe seventh inestimable effect The ninth most excellent effectThe ninth most excellent effect The twelfth incomparable effectThe twelfth incomparable effect The thirteenth most distinguished effectThe thirteenth most distinguished effect

30 Divina Proportione Luca Pacioli (1509) "Ninth Most Excellent Effect" two diagonals of a regular pentagon divide each other in the Divine Proportion.

31 Expanding Recursively

32

33

34

35 A (Simple) Continued Fraction Is Any Expression Of The Form: where a, b, c, … are whole numbers.

36 A Continued Fraction can have a finite or infinite number of terms. We also denote this fraction by [a,b,c,d,e,f,…]

37 Continued Fraction Representation = [1,1,1,1,1,0,0,0,…]

38 Recursively Defined Form For CF

39 Proposition: Any finite continued fraction evaluates to a rational. Converse: Any rational has a finite continued fraction representation.

40 Euclid’s GCD = Continued Fractions Euclid(A,B) = Euclid(B, A mod B) Stop when B=0

41 A Pattern for  Let r 1 = [1,0,0,0,…] = 1 r 2 = [1,1,0,0,0,…] = 2/1 r 2 = [1,1,0,0,0,…] = 2/1 r 3 = [1,1,1,0,0,0…] = 3/2 r 3 = [1,1,1,0,0,0…] = 3/2 r 4 = [1,1,1,1,0,0,0…] = 5/3 r 4 = [1,1,1,1,0,0,0…] = 5/3 and so on. Theorem: r n = F n+1 /F n

42 Divine Proportion

43 How to convert kilometers into miles? Heads-on

44 50 km = 34 + 13 + 3 50 = F 9 + F 7 + F 4 F 8 + F 6 + F 3 = 31 miles Magic conversion

45 Quadratic Equations X 2 – 3x – 1 = 0 X 2 = 3X + 1 X = 3 + 1/X X = 3 + 1/X = 3 + 1/[3 + 1/X] = …

46 A Periodic CF

47 A period-2 CF

48 Proposition: Any quadratic solution has a periodic continued fraction. Converse: Any periodic continued fraction is the solution of a quadratic equation

49 What about those non-periodic continued fractions?

50 Non-periodic CFs

51 What is the pattern?

52 What a cool representation! Finite CF: Rationals Periodic CF: Quadratic roots And some numbers reveal hidden regularity.

53 More recurrences!! Let us embark now on the Catalan numbers

54 Count the number of binary trees with n nodes. Counting Binary Trees

55 Let T n represent the number of trees with n nodes T 1 =1, T 2 =2 Counting Binary Trees

56 Size n-1-kSize k Size n =

57 Counting Binary Trees Size n-1-kSize k Size n = T n = T 0 T n-1 + T 1 T n-2 +…+T n-1 T 0 T n = T 0 T n-1 + T 1 T n-2 +…+T n-1 T 0

58 Counting Binary Trees

59 Count the number of ways to divide a convex n-gon into triangles with noncrossing diagonals. Triangulation

60 Study Bee Review GCD algorithm Recurrences, Phi and CF The Catalan numbers


Download ppt "Recurrences, Phi and CF Great Theoretical Ideas In Computer Science S. Rudich V. Adamchik CS 15-251 Spring 2006 Lecture 13 Feb 28, 2006 Carnegie Mellon."

Similar presentations


Ads by Google