Homogeneous Linear Recursion CK Cheng May 5 2011 2 3 Analysis 31 Introduction 32 Homogeneous Linear Recursion 33 Pigeonhole Principle 34 InclusionExclusion Principle 3 31 Introduction ID: 556549
Download Presentation The PPT/PDF document "1 CSE 20 Lecture 12: Analysis of" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
1
CSE 20 Lecture 12: Analysis of Homogeneous Linear Recursion
CK Cheng
May 5, 2011Slide2
2
3. Analysis 3.1 Introduction
3.2 Homogeneous Linear Recursion
3.3 Pigeonhole Principle
3.4 Inclusion-Exclusion Principle Slide3
3
3.1 Introduction
Derive the bound of functions or recursions
Estimate CPU time and memory allocation
Eg
.
PageRank
calculation
Allocation of memory, CPU time,
Resource optimization
MRI imaging
Real time?
VLSI design
Design automation flow to meet the deadline for tape out?
Further Study
Algorithm, ComplexitySlide4
4
3.1 Introduction
Derive the bound of functions or recursions
Estimate CPU time and memory allocation
Example on Fibonacci Sequence: Estimate f
n
.
Index: 0 1 2 3 4 5 6 7 8 9
f
n
: 0 1 1 2 3 4 5 8 13 21 34Slide5
5
Example: Fibonacci Sequence
0
1
2
3
4
5
6
7
8
9
0
1
1
2
3
58132134
Slide6
6
3.2 Homogeneous Linear Recursion(1) Arithmetic Recursion
a,
a+
d
, a+
2d
, …,
a+
kd
(2) Geometric Recursion
a, a
r, ar
2, …, ark
(3) Linear Recursion
a
n
= e1an-1+e2an-2+…+ekan-k+ f(n)Slide7
7
Linear Recursion and Homogeneous Linear Recursion
Linear Recursion: There are no powers or products of
Homogenous Linear Recursion: A linear recursion with
f(n)=0
.Slide8
8
Solving Linear Recursion
Input: Formula
and k initial values
characteristic polynomial:
Find the root of the characteristic polynomial (assuming
r
i
are distinct)
Set
Determine
c
i from k initial valuesSlide9
9
Solving Linear Recursion
Input: Formula
and k initial values
characteristic polynomial:
Rewrite the formula with n=k
Replace
a
i
with x
iSlide10
10
Solving Linear Recursion
Input: Formula
and k initial values
2. Find the root of the polynomial
Or,Slide11
11
Solving Linear Recursion
Input: Formula
and k initial values
3. Set (assuming that the roots are distinct.)
4. Determine
c
i
from k initial valuesSlide12
12
Solving Linear Recursion
Input: Formula
and k initial values
3. Set (when the roots are not distinct.)
where
r
i
is a root of
multiplicity
w
iSlide13
Example on Fibonacci sequence
Input: initial values a0=0 and a
1
=1; and recursion formula a
n
=a
n-1
+a
n-2
.
Rewrite recursion: a
n-an-1
-an-2=0.1. Characteristic polynomial: x2-x-1=0.
2. Roots of the polynomial:
13
3. Set: a
n
=c1r1n+c2r2n.Slide14
Example on Fibonacci sequence
Input: initial values a0
=0 and a
1
=1; and recursion formula a
n
=a
n-1
+a
n-2
.
4. Determine ci from k initial values
a0=c1r1
0+c2r20: c
1
+c
2
=0a1=c1r11+c2r21: c1r1+c2r2=1, where14Thus, we haveSlide15
Example 2
Given initial values a0=1 and a1=1;
and recursion formula: a
n
=a
n-1
+2a
n-2
Rewrite recursion: a
n
-a
n-1-2an-2=01. Characteristic polynomial: x2-x-2=0
2. Characteristic roots: r1=2 and r2= -13. We have a
n=c1r1n
+c
2
r
2n=c12n+c2(-1)n4. We use two initial values for n=0 and n=1: a0=c1+c2 a1=c12+c2(-1)15Slide16
Example 2 (cont)
Two initial valuesa0=c
1
+c
2
: c
1
+c
2
=1
a
1=2c1+(-1)c2: 2c1-c2=1
Thus, we have c1=2/3, c2
=1/3.Since an=c1r
1
n
+c
2r2n,the formula is an=2/3*2n+1/3*(-1)n,16Slide17
Example 3 (identical roots)
Given initial values a0=1 and a1=1; and recursion a
n
=-2a
n-1
-a
n-2
Rewrite the recursion: a
n
+2a
n-1
+an-2=01.Characteristic polynomial: x2+2x+1=02.Characteristic roots: r1
=r2=-13.Formula for roots of multiplicity 2 an
=c1r1n+c2
nr
1
n
=c1(-1)n+c2n(-1)nNote the formula is different for roots of multiplicity.17Slide18
Example 3 (identical roots)
Given initial values a0=1 and a1
=1; and recursion a
n
=-2a
n-1
-a
n-2
4. Two initial conditions:
a
0
=c1(-1)0+c20(-1)0=c
1 a1=c1(-1)
1+c21(-1)1=-c
1
-c
2
with a0=1 and a1=1Thus, c1= 1 and c2= -2.Therefore, an= (-1)n-2n(-1)nExercise: verify the sequence a2, a3 and a4.18