Recurrences and Continued Fractions

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 73

Recurrences and Continued Fractions

Great Theoretical Ideas In Computer Science


V. Adamchik
D. Sleator
CS 15-251 Spring 2010
Lecture 8 Feb 04, 2010 Carnegie Mellon University

Solve in integers

x
1
+ x
2
++ x
5
= 40
x
k
rk;

y
k
=x
k
k
y
1
+ y
2
++ y
5
= 25
y
k
0;
|
|
.
|

\
|
4
29

Solve in integers

x + y + z = 11
xr0; 0y3; zr0

2
3 2

x) - (1
x x x 1 + + +
[X
11
]

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
n nx 3x 2x 1x
n 3 2 1
= + + + + ...
) x - )...(1 x - )(1 x - x)(1 - (1
n 3 2
1
Plan
Review: Sat, 6-8pm in 2315 DH
Exam: Mon in recitations

Characteristic Equations
Golden Ratio
Continued Fractions

Applied Combinatorics, by Alan Tucker
The Divine Proportion, by H. E. Huntley
Leonardo Fibonacci
In 1202, Fibonacci has become
interested in rabbits and what they do
The rabbit reproduction model
A rabbit lives forever
The population starts as a single newborn
pair
Every 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
month 1 2 3 4 5 6 7
rabbits 1 1 2 3 5 8 13

What is a closed form
formula for F
n
?
F
0
=0, F
1
=1,
F
n
=F
n-1
+F
n-2
for n2
We wont be using GFs!

This lecture has
explicit mathematical
content that can be
shocking to some
students.


WARNING!!!!
Characteristic Equation
F
n
= F
n-1
+ F
n-2

Consider solutions of the form:
F
n
=
n

for some (unknown) constant 0

must satisfy:

n
-
n-1
-
n-2
= 0

n
-
n-1
-
n-2
= 0


iff
n-2
(
2
-

- 1) = 0

iff
2
-

- 1

= 0

2
5 1+
= |
Characteristic
equation
= |, or = -1/|

| (phi) is the golden ratio
So for all these values of the
inductive condition is satisfied:


2
-

- 1= 0

Do any of them happen to satisfy the base
condition as well?
F
0
=0, F
1
=1
a,b a |
n
+ b (-1/|)
n

satisfies the inductive condition
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
5
1
b ,
5
1
a = =
Leonhard Euler (1765)
5
) 1 (
F
n n
n
| |
=
2
5 1+
= |
Fibonacci Power Series
??
0
=

= k
k
k
x F
2
1 x x
x

Fibonacci Bamboozlement
8
8
13
5
Cassinis 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

How to convert
kilometers into miles?




Heads-on

50 km = 34 + 13 + 3

Magic conversion
F
8
+ F
6
+ F
3
= 31

miles
50 = F
9
+ F
7
+ F
4
From the previous lecture
1 d 0, d
2d d d
1 0
2 n 1 n n
= =
+ =

Characteristic Equation
1 d 0, d
2d d d
1 0
2 n 1 n n
= =
+ =

0 2
2
=
2 , 1
2 1
= =
n n
n
2 b 1) ( a d + =
a, b
n n
n
2 b 1) ( a d + =
b a 2 b 1) ( a 0 d
0 0
0
+ = + = =
b 2 a 2 b 1) ( a 1 d
1 1
1
+ = + = =
3
1
a ,
3
1
b = =
Characteristic Equation
2 x 1, x
x 2x x
1 0
2 n 1 n n
= =
=

0 1 2
2
= +
1
2 1
= =
Characteristic Equation
Theorem. Let be a root of multiplicity p
of the characteristic equation. Then
n 1 - p n 2 n n
n ,..., n , n ,
are all solutions.
2 n 1 n n
x 2x x

=
The theorem says that x
n
=n is a solution.
This can be easily verified: n = 2 n - n
From the previous lecture:
Rogue Recurrence
4 a 1, a 0, a
4a 8a 5a a
2 1 0
3 n 2 n 1 n n
= = =
+ =

0 4 8 5
2 3
= +
Characteristic equation:
2 , 1
3 2 1
= = =
4 a 1, a 0, a
4a 8a 5a a
2 1 0
3 n 2 n 1 n n
= = =
+ =

n n
n
2 n c 2 b a a + + =
General solution:
8c 4b a 4 a
2c 2b a 1 a
b a 0 a
2
1
0
+ + = =
+ + = =
+ = =
2
1
c
0, b a
=
= =
1 - n
n
2 n a =
The Golden Ratio

Some other majors have their
mystery numbers, like t and e.
In Computer Science the mystery
number is |, the Golden Ratio.
S.Rudich
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.


BC
AB
AB
AC
= = |
BC
AC
BC
AB
AB
AC
= =
2
|
1
BC
AB AC
BC
AB
BC
AC
=

= = | |
2
A B C
0 1
2
= | |
Golden Ratio - the divine
proportion
| = 1.6180339887498948482045

Phi is named after the Greek sculptor
Phidias
0 1
2
= | |
2
5 1+
= |
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).
Which is the most attractive
rectangle?
Which is the most attractive rectangle?
Golden
Rectangle
1
|
The Golden Ratio
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

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

For the sake of salvation, the list
must end here Luca Pacioli
Divina Proportione
Luca Pacioli (1509)
"Ninth Most Excellent Effect"

two diagonals of a regular pentagon
divide each other in the Divine
Proportion.

C
B
A
BC
AB
AB
AC
= = |
Expanding Recursively
0 1
2
= | |
|
|
1
1+ =
|
|
1
1
1
1
+
+ =
Expanding Recursively
|
|
1
1
1
1
1
1
1
1
+
+
+
+ =
A (Simple) Continued Fraction Is
Any Expression Of The Form:
1
1
1
1
1
1
1
1
1
....
a
b
c
d
e
f
g
h
i
j
+
+
+
+
+
+
+
+
+
+
where a, b, c, are whole numbers.
A Continued Fraction can have a
finite or infinite number of terms.
We also denote this fraction by [a,b,c,d,e,f,]
1
1
1
1
1
1
1
1
1
....
a
b
c
d
e
f
g
h
i
j
+
+
+
+
+
+
+
+
+
+
Continued Fraction Representation
8 1
1
1
5
1
1
1
1
1
1
= +
+
+
+
= [1,1,1,1,1,0,0,0,]
Recursively Defined Form For CF
CF
1
number whole
number whole CF
+ =
=
Proposition: Any finite
continued fraction
evaluates to a rational.

Converse: Any rational has
a finite continued fraction
representation.
Euclids GCD = Continued Fraction
Euclid(A,B) = Euclid(B, A mod B)
Stop when B=0
0 q r r
....
r q r r
r q r b
r q b a
1 k k 1 k
3 3 2 1
2 2 1
1 1
+ =
+ =
+ =
+ =
+
Euclids GCD = Continued Fraction
0 q r r
....
r q r r
r q r b
r q b a
1 k k 1 k
3 3 2 1
2 2 1
1 1
+ =
+ =
+ =
+ =
+
1
r
b
1
1
1
1
q
b
r
q
b
a
+ = + =
2
1
r
r
2
1
2
2
1
1
q
r
r
q
r
b
+ = + =
3
2
r
r
3
2
3
3
2
1
1
q
r
r
q
r
r
+ = + =
Euclids GCD = Continued Fraction
0 q r r
....
r q r r
r q r b
r q b a
1 k k 1 k
3 3 2 1
2 2 1
1 1
+ =
+ =
+ =
+ =
+
3
r
2
r
1
3
2
r
1
r
1
q
1
2
1
1
2
1
r
b
1
q
1
q
q
1
q
1
q
b
a
+
+
+ =
+
+ =
+ =
A Pattern for |
Let r
1
= [1,0,0,0,] = 1
r
2
= [1,1,0,0,0,] = 2/1
r
3
= [1,1,1,0,0,0] = 3/2
r
4
= [1,1,1,1,0,0,0] = 5/3
and so on.

Theorem:
| = F
n
/F
n-1
when n ->
|
|
1
1
1
1
+
+ =
Divine Proportion
|
|
|
|
|
|
|
= =
|
|
.
|

\
|

|
|
.
|

\
|

=


1 n
n
n
1 n
1 n
n
n
n
1 n
n
n
lim
1
1
lim
F
F
lim
Quadratic Equations
X
2
3x 1 = 0

X
2
= 3X + 1

X = 3 + 1/X
3 13
2
X
+
=

X = 3 + 1/X = 3 + 1/[3 + 1/X] =
A Periodic CF
3 13 1
3
1
2
3
1
3
1
3
1
3
1
3
1
3
1
3
1
3
3 ....
+
= +
+
+
+
+
+
+
+
+
+
A period-2 CF
... 4
1
8
1
4
1
8
1
4
1
1
1
3
2 1
+
+
+
+
+
+
=
+
Proposition: Any quadratic
solution has a periodic
continued fraction.

Converse: Any periodic
continued fraction is the
solution of a quadratic
equation

What about those
non-periodic
continued fractions?



What is the
continued fraction
expansion for t?
Euclids GCD = Continued Fraction
0 q r r
....
r q r r
r q r b
r q b a
1 k k 1 k
3 3 2 1
2 2 1
1 1
+ =
+ =
+ =
+ =
+
0.000078 0.00882 1 0.00885
0.00882 0.00885 15 0.1415
0.00885 0.1415 7 1
0.1415 1 3
+ =
+ =
+ =
+ =
??
What is the pattern?
1
3
1
7
1
15
1
1
1
292
1
1
1
1
1
1
1
2
1 ....
t = +
+
+
+
+
+
+
+
+
+
What is the pattern?
1
1 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1 ...
2
4
6
.
e = +
+
+
+
+
+
+
+
+
+

Every irrational number
greater than 1 is the
limit of a
unique infinite
continued fraction.


Every irrational number greater than 1 is
the limit of a unique infinite continued
fraction.
Suppose that y>1 is irrational and y = [b
0
;b
1
,b
2
, . . .].
1
0
1
0
y
1
b
... b
1
b y + =
+
+ =
where y
1
> 1.
Thus,

y
y
1
y b
1
0
= =
Similarly, for all b
k
.
To calculate the continued
fraction for a real number
y, set y
0
=y and then

k k
1 k
k k
b y
1
y
y b

=
=
+
What a cool
representation!

Finite CF: Rationals
Periodic CF: Quadratic
roots
And some numbers reveal
hidden regularity.
Let us embark now on
approximations
1
3
1
7
1
15
1
1
1
292
1
1
1
1
1
1
1
2
1 ....
t = +
+
+
+
+
+
+
+
+
+
CF for Approximations
3.14151
15
1
7
1
3
3.1428
7
1
3
3
=
+
+ =
= + =
=
We say that an positive irrational number y
is approximable by rationals to order n
if there exist a positive constant c and
infinitely many rationals p/q with q > 0
such that
n
q
c
q
p
y s
We will see that algebraic numbers are
not approximable to arbitrarily high order.
Positive rational numbers are
approximable to order 1
Let y = a/b be a rational
number, with gcd(a,b) = 1. By
Euclids algorithm we can find
p
0
,q
0
such that p
0
b q
0
a = 1.
Then
0 0
0
q
1
q
p
b
a
s
Positive rational numbers are approximable
to order 1
0 0 0
0
0 0
0
0 0
0 0
q
1
bq
1
q
p
b
a
bq
1
b
a
q
p
b
1
b
a
q p
1 a q b p
s =
=
=
=
Positive rational numbers are approximable
to order 1
0 0 0
0
q
1
bq
1
q
p
b
a
s =
Similarly,
m m
m
q
1
q
p
b
a
s
Liouvilles number

=
1 k
k!
10 y
. . 0000010. 0000000000 0.11000100 y =
Transcendental number
Liouvilles number
t and e are
transcendental number
What about t
e
?
Aperys constant
irrational number

=
=
1 k
3
k
1
(3)
transcendental number - ???
Riemann Zeta function
Study Bee
Review GCD algorithm
Recurrences, Phi and CF
Solving Recurrences

You might also like