SlideShare a Scribd company logo
Solving Linear Recurrence
Relations
Niloufar Shafiei
1
Review
A recursive definition of a sequence specifies
 Initial conditions
 Recurrence relation
Example:
a0=0 and a1=3
an = 2an-1 - an-2
an = 3n
Initial conditions
Recurrence relation
Solution
2
Linear recurrences
Linear recurrence:
Each term of a sequence is a linear function of earlier
terms in the sequence.
For example:
a0 = 1 a1 = 6 a2 = 10
an = an-1 + 2an-2 + 3an-3
a3 = a0 + 2a1 + 3a2
= 1 + 2(6) + 3(10) = 43
3
Linear recurrences
Linear recurrences
1. Linear homogeneous recurrences
2. Linear non-homogeneous recurrences
4
Linear homogeneous recurrences
A linear homogenous recurrence relation of degree k with
constant coefficients is a recurrence relation of the form
an = c1an-1 + c2an-2 + … + ckan-k,
where c1, c2, …, ck are real numbers, and ck0.
an is expressed in terms of the previous k terms of the sequence,
so its degree is k.
This recurrence includes k initial conditions.
a0 = C0 a1 = C1 … ak = Ck
5
Example
Determine if the following recurrence relations are linear homogeneous
recurrence relations with constant coefficients.
 Pn = (1.11)Pn-1
a linear homogeneous recurrence relation of degree one
 an = an-1 + a2
n-2
not linear
 fn = fn-1 + fn-2
a linear homogeneous recurrence relation of degree two
 Hn = 2Hn-1+1
not homogeneous
 an = an-6
a linear homogeneous recurrence relation of degree six
 Bn = nBn-1
does not have constant coefficient
6
Solving linear homogeneous
recurrences
Proposition 1:
 Let an = c1an-1 + c2an-2 + … + ckan-k be a linear homogeneous
recurrence.
 Assume the sequence an satisfies the recurrence.
 Assume the sequence a’n also satisfies the recurrence.
 So, bn = an + a’n and dn=an are also sequences that satisfy the
recurrence.
( is any constant)
Proof:
bn = an + a’n
= (c1an-1 + c2an-2 + … + ckan-k) + (c1a’n-1 + c2a’n-2 + … + cka’n-k)
= c1 (an-1+ a’n-1) + c2 (an-2+ a’n-2) + … + ck (an-k + a’n-k)
= c1bn-1 + c2bn-2 + … + ckbn-k
So, bn is a solution of the recurrence.
7
Solving linear homogeneous
recurrences
Proposition 1:
 Let an = c1an-1 + c2an-2 + … + ckan-k be a linear homogeneous
recurrence.
 Assume the sequence an satisfies the recurrence.
 Assume the sequence a’n also satisfies the recurrence.
 So, bn = an + a’n and dn=an are also sequences that satisfy the
recurrence.
( is any constant)
Proof:
dn = an
=  (c1an-1 + c2an-2 + … + ckan-k)
= c1 (an-1) + c2 (an-2) + … + ck (an-k)
= c1dn-1 + c2dn-2 + … + ckdn-k
So, dn is a solution of the recurrence.
8
Solving linear homogeneous
recurrences
It follows from the previous proposition, if we
find some solutions to a linear
homogeneous recurrence, then any linear
combination of them will also be a solution
to the linear homogeneous recurrence.
9
Solving linear homogeneous
recurrences
Geometric sequences come up a lot when
solving linear homogeneous recurrences.
So, try to find any solution of the form an = rn
that satisfies the recurrence relation.
10
Solving linear homogeneous
recurrences
 Recurrence relation
an = c1an-1 + c2an-2 + … + ckan-k
 Try to find a solution of form rn
rn = c1rn-1 + c2rn-2 + … + ckrn-k
rn - c1rn-1 - c2rn-2 - … - ckrn-k = 0
rk - c1rk-1 - c2rk-2 - … - ck = 0 (dividing both sides by rn-k)
This equation is called the characteristic equation.
11
Example
Example:
The Fibonacci recurrence is
Fn = Fn-1 + Fn-2
Its characteristic equation is
r2 - r - 1 = 0
12
Solving linear homogeneous
recurrences
Proposition 2:
r is a solution of rk - c1rk-1 - c2rk-2 - … - ck = 0 if and
only if rn is a solution of an = c1an-1 + c2an-2 + … +
ckan-k.
Example:
consider the characteristic equation r2 - 4r + 4 = 0.
r2 - 4r + 4 = (r - 2)2 = 0
So, r=2.
So, 2n satisfies the recurrence Fn = 4Fn-1 - 4Fn-2.
2n = 4 . 2n-1 - 4 . 2n-2
2n-2 ( 4 - 8 + 4) = 0
13
Solving linear homogeneous
recurrences
Theorem 1:
 Consider the characteristic equation rk - c1rk-1 - c2rk-2 - … - ck =
0 and the recurrence an = c1an-1 + c2an-2 + … + ckan-k.
 Assume r1, r2, …and rm all satisfy the equation.
 Let 1, 2, …, m be any constants.
 So, an = 1 r1
n + 2 r2
n + … + m rm
n satisfies the recurrence.
Proof:
By Proposition 2, i ri
n satisfies the recurrence.
So, by Proposition 1, i i ri
n satisfies the recurrence.
Applying Proposition 1 again, the sequence an = 1 r1
n + 2 r2
n + …
+ m rm
n satisfies the recurrence.
14
Example
What is the solution of the recurrence relation
an = an-1 + 2an-2
with a0=2 and a1=7?
Solution:
 Since it is linear homogeneous recurrence, first find its
characteristic equation
r2 - r - 2 = 0
(r+1)(r-2) = 0 r1 = 2 and r2 = -1
 So, by theorem an = 12n + 2(-1)n is a solution.
 Now we should find 1 and 2 using initial conditions.
a0= 1 + 2 = 2
a1= 12 + 2(-1) = 7
 So, 1= 3 and 2 = -1.
 an = 3 . 2n - (-1)n is a solution.
15
Example
What is the solution of the recurrence relation
fn = fn-1 + fn-2
with f0=0 and f1=1?
Solution:
 Since it is linear homogeneous recurrence, first find its
characteristic equation
r2 - r - 1 = 0
r1 = (1+)/2 and r2 = (1-)/2
 So, by theorem fn = 1((1+)/2)n + 2((1-)/2)n is a solution.
 Now we should find 1 and 2 using initial conditions.
f0= 1 + 2 = 0
f1= 1(1+)/2 + 2 (1-)/2 = 1
 So, 1= 1/ and 2 = -1/.
 an = 1/ . ((1+)/2)n - 1/((1-)/2)n is a solution.
16
Example
What is the solution of the recurrence relation
an = -an-1 + 4an-2 + 4an-3
with a0=8, a1=6 and a2=26?
Solution:
 Since it is linear homogeneous recurrence, first find its characteristic
equation
r3 + r2 - 4r - 4 = 0
(r+1)(r+2)(r-2) = 0 r1 = -1, r2 = -2 and r3 = 2
 So, by theorem an = 1(-1)n + 2(-2)n + 32n is a solution.
 Now we should find 1, 2 and 3 using initial conditions.
a0= 1 + 2 + 3 = 8
a1= - 1 - 22 + 23 = 6
a2= 1 + 42 + 43 = 26
 So, 1= 2, 2 = 1 and 3 = 5.
 an = 2 . (-1)n + (-2)n + 5 . 2n is a solution.
17
Solving linear homogeneous
recurrences
If the characteristic equation has k distinct solutions
r1, r2, …, rk, it can be written as
(r - r1)(r - r2)…(r - rk) = 0.
If, after factoring, the equation has m+1 factors of (r -
r1), for example, r1 is called a solution of the
characteristic equation with multiplicity m+1.
When this happens, not only r1
n is a solution, but also
nr1
n, n2r1
n, … and nmr1
n are solutions of the
recurrence.
18
Solving linear homogeneous
recurrences
Proposition 3:
 Assume r0 is a solution of the characteristic
equation with multiplicity at least m+1.
 So, nmr0
n is a solution to the recurrence.
19
Solving linear homogeneous
recurrences
When a characteristic equation has fewer than k
distinct solutions:
 We obtain sequences of the form described in
Proposition 3.
 By Proposition 1, we know any combination of
these solutions is also a solution to the
recurrence.
 We can find those that satisfies the initial
conditions.
20
Solving linear homogeneous
recurrences
Theorem 2:
 Consider the characteristic equation rk - c1rk-1 - c2rk-2 - … -
ck = 0 and the recurrence an = c1an-1 + c2an-2 + … + ckan-k.
 Assume the characteristic equation has tk distinct
solutions.
 Let i (1it) ri with multiplicity mi be a solution of the
equation.
 Let i,j (1it and 0jmi-1) ij be a constant.
 So, an = (10 + 11 n+ … + 1,m1-1 nm1-1 ) r1
n
+ (20 + 21 n+ … + 2,m2-1 nm2-1 ) r2
n
+ …
+ (t0 + t1 n+ … + t,mt-1 nmt-1 ) rt
n
satisfies the recurrence.
21
Example
What is the solution of the recurrence relation
an = 6an-1 - 9an-2
with a0=1 and a1=6?
Solution:
 First find its characteristic equation
r2 - 6r + 9 = 0
(r - 3)2 = 0 r1 = 3 (Its multiplicity is 2.)
 So, by theorem an = (10 + 11n)(3)n is a solution.
 Now we should find constants using initial conditions.
a0= 10 = 1
a1= 3 10 + 311 = 6
 So, 11= 1 and 10 = 1.
 an = 3n + n3n is a solution.
22
Example
What is the solution of the recurrence relation
an = -3an-1 - 3an-2 - an-3
with a0=1, a1=-2 and a2=-1?
Solution:
 Find its characteristic equation
r3 + 3r2 + 3r + 1 = 0
(r + 1)3 = 0 r1 = -1 (Its multiplicity is 3.)
 So, by theorem an = (10 + 11n + 12n2)(-1)n is a solution.
 Now we should find constants using initial conditions.
a0= 10 = 1
a1= -10 - 11 - 12 = -2
a2= 10 + 211 + 412 = -1
 So, 10= 1, 11 = 3 and 12 = -2.
 an = (1 + 3n - 2n2) (-1)n is a solution.
23
Example
What is the solution of the recurrence relation
an = 8an-2 - 16an-4 , for n4,
with a0=1, a1=4, a2=28 and a3=32?
Solution:
 Find its characteristic equation
r4 - 8r2 + 16 = 0
(r2 - 4)2 = (r-2)2 (r+2)2 = 0
r1 = 2 r2 = -2 (Their multiplicities are 2.)
 So, by theorem an = (10 + 11n)(2)n + (20 + 21n)(-2)n is a solution.
 Now we should find constants using initial conditions.
a0= 10 + 20 = 1
a1= 210 + 211 - 220 - 221 = 4
a2= 410 + 811 + 420 + 821 = 28
a3= 810 + 2411 - 820 - 2421 = 32
 So, 10= 1, 11 = 2, 20 = 0 and 21 = 1.
 an = (1 + 2n) 2n + n (-2)n is a solution.
24
Linear non-homogeneous
recurrences
A linear non-homogenous recurrence relation with constant
coefficients is a recurrence relation of the form
an = c1an-1 + c2an-2 + … + ckan-k+ f(n),
where c1, c2, …, ck are real numbers, and f(n) is a function depending
only on n.
The recurrence relation
an = c1an-1 + c2an-2 + … + ckan-k,
is called the associated homogeneous recurrence relation.
This recurrence includes k initial conditions.
a0 = C0 a1 = C1 … ak = Ck
25
Example
The following recurrence relations are linear non-
homogeneous recurrence relations.
 an = an-1 + 2n
 an = an-1 + an-2 + n2 + n + 1
 an = an-1 + an-4 + n!
 an = an-6 + n2n
26
Linear non-homogeneous
recurrences
Proposition 4:
 Let an = c1an-1 + c2an-2 + … + ckan-k + f(n) be a
linear non-homogeneous recurrence.
 Assume the sequence bn satisfies the recurrence.
 Another sequence an satisfies the non-
homogeneous recurrence if and only if hn = an - bn
is also a sequence that satisfies the associated
homogeneous recurrence.
27
Linear non-homogeneous
recurrences
Proof:
Part1: if hn satisfies the associated homogeneous recurrence
then an is satisfies the non-homogeneous recurrence.
 bn = c1bn-1 + c2bn-2 + … + ckbn-k + f(n)
 hn = c1hn-1 + c2hn-2 + … + ckhn-k
bn + hn
= c1 (bn-1+ hn-1) + c2 (bn-2+ hn-2) + … + ck (bn-k + hn-k) + f(n)
Since an = bn + hn, an = c1an-1 + c2an-2 + … + ckan-k+ f(n).
So, an is a solution of the non-homogeneous recurrence.
28
Linear non-homogeneous
recurrences
Proof:
Part2: if an satisfies the non-homogeneous recurrence then hn
is satisfies the associated homogeneous recurrence.
 bn = c1bn-1 + c2bn-2 + … + ckbn-k + f(n)
 an = c1an-1 + c2an-2 + … + ckan-k+ f(n)
an - bn
= c1 (an-1- bn-1) + c2 (an-2- bn-2) + … + ck (an-k - bn-k)
Since hn = an - bn, hn = c1hn-1 + c2hn-2 + … + ckhn-k
So, hn is a solution of the associated homogeneous
recurrence.
29
Linear non-homogeneous
recurrences
Proposition 4:
 Let an = c1an-1 + c2an-2 + … + ckan-k + f(n) be a linear non-
homogeneous recurrence.
 Assume the sequence bn satisfies the recurrence.
 Another sequence an satisfies the non-homogeneous recurrence if
and only if hn = an - bn is also a sequence that satisfies the
associated homogeneous recurrence.
 We already know how to find hn.
 For many common f(n), a solution bn to the non-homogeneous
recurrence is similar to f(n).
 Then you should find solution an = bn + hn to the non-
homogeneous recurrence that satisfies both recurrence and
initial conditions.
30
Example
What is the solution of the recurrence relation
an = an-1 + an-2 + 3n + 1 for n2,
with a0=2 and a1=3?
Solution:
 Since it is linear non-homogeneous recurrence, bn is similar to f(n)
Guess: bn = cn + d
bn = bn-1 + bn-2 + 3n + 1
cn + d = c(n-1) + d + c(n-2) + d + 3n + 1
cn + d = cn - c + d + cn -2c + d +3n + 1
0 = (3+c)n + (d-3c+1)
c = -3 d=-10
 So, bn = - 3n - 10.
(bn only satisfies the recurrence, it does not satisfy the initial
conditions.)
31
Example
What is the solution of the recurrence relation
an = an-1 + an-2 + 3n + 1 for n2,
with a0=2 and a1=3?
Solution:
 We are looking for an that satisfies both recurrence and initial conditions.
 an = bn + hn where hn is a solution for the associated homogeneous
recurrence: hn = hn-1 + hn-2
 By previous example, we know hn = 1((1+)/2)n + 2((1-)/2)n.
an = bn + hn
= - 3n - 10 + 1((1+)/2)n + 2((1-)/2)n
 Now we should find constants using initial conditions.
a0= -10 + 1 + 2 = 2
a1= -13 + 1 (1+)/2 + 2 (1-)/2 = 3
1 = 6 + 2  2 = 6 - 2 
So, an = -3n - 10 + (6 + 2 )((1+)/2)n + (6 - 2 )((1-)/2)n.
32
Example
What is the solution of the recurrence relation
an = 2an-1 - an-2 + 2n for n2,
with a0=1 and a1=2?
Solution:
 Since it is linear non-homogeneous recurrence, bn is similar to f(n)
Guess: bn = c2n + d
bn = 2bn-1 - bn-2 + 2n
c2n + d = 2(c2n-1 + d) - (c2n-2 + d) + 2n
c2n + d = c2n + 2d - c2n-2 - d + 2n
0 = (-4c + 4c - c + 4)2n-2 + (-d + 2d -d)
c = 4 d=0
 So, bn = 4 . 2n.
(bn only satisfies the recurrence, it does not satisfy the initial
conditions.)
33
Example
What is the solution of the recurrence relation
an = 2an-1 - an-2 + 2n for n2,
with a0=1 and a1=2?
Solution:
 We are looking for an that satisfies both recurrence and initial
conditions.
 an = bn + hn where hn is a solution for the associated homogeneous
recurrence: hn = 2hn-1 - hn-2.
 Find its characteristic equation
r2 - 2r + 1 = 0
(r - 1)2 = 0
r1 = 1 (Its multiplicity is 2.)
 So, by theorem hn = (1 + 2n)(1)n = 1 + 2n is a solution.
34
Example
What is the solution of the recurrence relation
an = 2an-1 - an-2 + 2n for n2,
with a0=1 and a1=2?
Solution:
 an = bn + hn
 an = 4 . 2n + 1 + 2n is a solution.
 Now we should find constants using initial conditions.
a0= 4 + 1 = 1
a1= 8 - 1 + 2 = 2
1 = -3 2 = -3
So, an = 4 . 2n - 3n - 3.
35
Recommended exercises
1,3,15,17,19,21,23,25,31,35
Eric Ruppert’s Notes about Solving
Recurrences
(http://www.cse.yorku.ca/course_archive/2007
-08/F/1019/A/recurrence.pdf)

More Related Content

What's hot

Methods of solving ODE
Methods of solving ODEMethods of solving ODE
Methods of solving ODE
kishor pokar
 
Data Structure: Algorithm and analysis
Data Structure: Algorithm and analysisData Structure: Algorithm and analysis
Data Structure: Algorithm and analysis
Dr. Rajdeep Chatterjee
 
recurence solutions
recurence solutionsrecurence solutions
recurence solutions
soumya8396
 
Engr 213 midterm 2b sol 2010
Engr 213 midterm 2b sol 2010Engr 213 midterm 2b sol 2010
Engr 213 midterm 2b sol 2010akabaka12
 
LINEAR RECURRENCE RELATIONS WITH CONSTANT COEFFICIENTS
 LINEAR RECURRENCE RELATIONS WITH CONSTANT COEFFICIENTS LINEAR RECURRENCE RELATIONS WITH CONSTANT COEFFICIENTS
LINEAR RECURRENCE RELATIONS WITH CONSTANT COEFFICIENTS
AartiMajumdar1
 
Unit1
Unit1Unit1
Infinite sequences and series i
Infinite sequences and series iInfinite sequences and series i
Infinite sequences and series i
EasyStudy3
 
Z transform ROC eng.Math
Z transform ROC eng.MathZ transform ROC eng.Math
Z transform ROC eng.Math
Adhana Hary Wibowo
 
Complex numbers and quadratic equations
Complex numbers and quadratic equationsComplex numbers and quadratic equations
Complex numbers and quadratic equationsriyadutta1996
 
Gamma beta functions-1
Gamma   beta functions-1Gamma   beta functions-1
Gamma beta functions-1
Selvaraj John
 
Test for convergence
Test for convergenceTest for convergence
Test for convergence
Ayush Agrawal
 
7 cavalieri principle-x
7 cavalieri principle-x7 cavalieri principle-x
7 cavalieri principle-x
math266
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notationsNikhil Sharma
 
MCQs Ordinary Differential Equations
MCQs Ordinary Differential EquationsMCQs Ordinary Differential Equations
MCQs Ordinary Differential Equations
DrDeepaChauhan
 
strassen matrix multiplication algorithm
strassen matrix multiplication algorithmstrassen matrix multiplication algorithm
strassen matrix multiplication algorithm
evil eye
 
Double Integral Powerpoint
Double Integral PowerpointDouble Integral Powerpoint
Double Integral Powerpoint
oaishnosaj
 
Vcla.ppt COMPOSITION OF LINEAR TRANSFORMATION KERNEL AND RANGE OF LINEAR TR...
Vcla.ppt COMPOSITION OF LINEAR TRANSFORMATION   KERNEL AND RANGE OF LINEAR TR...Vcla.ppt COMPOSITION OF LINEAR TRANSFORMATION   KERNEL AND RANGE OF LINEAR TR...
Vcla.ppt COMPOSITION OF LINEAR TRANSFORMATION KERNEL AND RANGE OF LINEAR TR...
Sukhvinder Singh
 
Power series & Radius of convergence
Power series & Radius of convergencePower series & Radius of convergence
Power series & Radius of convergence
Dhruv Darji
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
Saranya Natarajan
 
Linear dependence & independence vectors
Linear dependence & independence vectorsLinear dependence & independence vectors
Linear dependence & independence vectors
Rakib Hossain
 

What's hot (20)

Methods of solving ODE
Methods of solving ODEMethods of solving ODE
Methods of solving ODE
 
Data Structure: Algorithm and analysis
Data Structure: Algorithm and analysisData Structure: Algorithm and analysis
Data Structure: Algorithm and analysis
 
recurence solutions
recurence solutionsrecurence solutions
recurence solutions
 
Engr 213 midterm 2b sol 2010
Engr 213 midterm 2b sol 2010Engr 213 midterm 2b sol 2010
Engr 213 midterm 2b sol 2010
 
LINEAR RECURRENCE RELATIONS WITH CONSTANT COEFFICIENTS
 LINEAR RECURRENCE RELATIONS WITH CONSTANT COEFFICIENTS LINEAR RECURRENCE RELATIONS WITH CONSTANT COEFFICIENTS
LINEAR RECURRENCE RELATIONS WITH CONSTANT COEFFICIENTS
 
Unit1
Unit1Unit1
Unit1
 
Infinite sequences and series i
Infinite sequences and series iInfinite sequences and series i
Infinite sequences and series i
 
Z transform ROC eng.Math
Z transform ROC eng.MathZ transform ROC eng.Math
Z transform ROC eng.Math
 
Complex numbers and quadratic equations
Complex numbers and quadratic equationsComplex numbers and quadratic equations
Complex numbers and quadratic equations
 
Gamma beta functions-1
Gamma   beta functions-1Gamma   beta functions-1
Gamma beta functions-1
 
Test for convergence
Test for convergenceTest for convergence
Test for convergence
 
7 cavalieri principle-x
7 cavalieri principle-x7 cavalieri principle-x
7 cavalieri principle-x
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
MCQs Ordinary Differential Equations
MCQs Ordinary Differential EquationsMCQs Ordinary Differential Equations
MCQs Ordinary Differential Equations
 
strassen matrix multiplication algorithm
strassen matrix multiplication algorithmstrassen matrix multiplication algorithm
strassen matrix multiplication algorithm
 
Double Integral Powerpoint
Double Integral PowerpointDouble Integral Powerpoint
Double Integral Powerpoint
 
Vcla.ppt COMPOSITION OF LINEAR TRANSFORMATION KERNEL AND RANGE OF LINEAR TR...
Vcla.ppt COMPOSITION OF LINEAR TRANSFORMATION   KERNEL AND RANGE OF LINEAR TR...Vcla.ppt COMPOSITION OF LINEAR TRANSFORMATION   KERNEL AND RANGE OF LINEAR TR...
Vcla.ppt COMPOSITION OF LINEAR TRANSFORMATION KERNEL AND RANGE OF LINEAR TR...
 
Power series & Radius of convergence
Power series & Radius of convergencePower series & Radius of convergence
Power series & Radius of convergence
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
Linear dependence & independence vectors
Linear dependence & independence vectorsLinear dependence & independence vectors
Linear dependence & independence vectors
 

Similar to Daa linear recurrences

Maths
MathsMaths
Recurrence_Theory.pptx studdents nees free
Recurrence_Theory.pptx studdents nees freeRecurrence_Theory.pptx studdents nees free
Recurrence_Theory.pptx studdents nees free
White44420
 
Impact of Linear Homogeneous Recurrent Relation Analysis
Impact of Linear Homogeneous Recurrent Relation AnalysisImpact of Linear Homogeneous Recurrent Relation Analysis
Impact of Linear Homogeneous Recurrent Relation Analysis
ijtsrd
 
RecurrenceRelations.ppt
RecurrenceRelations.pptRecurrenceRelations.ppt
RecurrenceRelations.ppt
MumitAhmed1
 
Recurrence Relations for Discrete mathematics
Recurrence Relations for Discrete mathematicsRecurrence Relations for Discrete mathematics
Recurrence Relations for Discrete mathematics
meychu1
 
pdf of recurrence relation which is used in statistics
pdf of recurrence relation which is used in statisticspdf of recurrence relation which is used in statistics
pdf of recurrence relation which is used in statistics
pranjaltarte
 
Solving recurrences
Solving recurrencesSolving recurrences
Solving recurrences
Waqas Akram
 
Solving recurrences
Solving recurrencesSolving recurrences
Solving recurrences
Waqas Akram
 
Recurrence equations
Recurrence equationsRecurrence equations
Recurrence equationsTarun Gehlot
 
8.-DAA-LECTURE-8-RECURRENCES-AND-ITERATION-METHOD.pdf
8.-DAA-LECTURE-8-RECURRENCES-AND-ITERATION-METHOD.pdf8.-DAA-LECTURE-8-RECURRENCES-AND-ITERATION-METHOD.pdf
8.-DAA-LECTURE-8-RECURRENCES-AND-ITERATION-METHOD.pdf
RishikeshJha33
 
Analysis Of Algorithms Ii
Analysis Of Algorithms IiAnalysis Of Algorithms Ii
Analysis Of Algorithms IiSri Prasanna
 
Elementary Differential Equations 11th Edition Boyce Solutions Manual
Elementary Differential Equations 11th Edition Boyce Solutions ManualElementary Differential Equations 11th Edition Boyce Solutions Manual
Elementary Differential Equations 11th Edition Boyce Solutions Manual
MiriamKennedys
 
1624 sequence
1624 sequence1624 sequence
1624 sequence
Dr Fereidoun Dejahang
 
Solution manual for introduction to nonlinear finite element analysis nam-h...
Solution manual for introduction to nonlinear finite element analysis   nam-h...Solution manual for introduction to nonlinear finite element analysis   nam-h...
Solution manual for introduction to nonlinear finite element analysis nam-h...
Salehkhanovic
 
Week 8 [compatibility mode]
Week 8 [compatibility mode]Week 8 [compatibility mode]
Week 8 [compatibility mode]
Hazrul156
 

Similar to Daa linear recurrences (20)

Maths
MathsMaths
Maths
 
Recurrence_Theory.pptx studdents nees free
Recurrence_Theory.pptx studdents nees freeRecurrence_Theory.pptx studdents nees free
Recurrence_Theory.pptx studdents nees free
 
Impact of Linear Homogeneous Recurrent Relation Analysis
Impact of Linear Homogeneous Recurrent Relation AnalysisImpact of Linear Homogeneous Recurrent Relation Analysis
Impact of Linear Homogeneous Recurrent Relation Analysis
 
RecurrenceRelations.ppt
RecurrenceRelations.pptRecurrenceRelations.ppt
RecurrenceRelations.ppt
 
Recurrence Relations for Discrete mathematics
Recurrence Relations for Discrete mathematicsRecurrence Relations for Discrete mathematics
Recurrence Relations for Discrete mathematics
 
pdf of recurrence relation which is used in statistics
pdf of recurrence relation which is used in statisticspdf of recurrence relation which is used in statistics
pdf of recurrence relation which is used in statistics
 
Solving recurrences
Solving recurrencesSolving recurrences
Solving recurrences
 
Solving recurrences
Solving recurrencesSolving recurrences
Solving recurrences
 
Recurrence equations
Recurrence equationsRecurrence equations
Recurrence equations
 
8.-DAA-LECTURE-8-RECURRENCES-AND-ITERATION-METHOD.pdf
8.-DAA-LECTURE-8-RECURRENCES-AND-ITERATION-METHOD.pdf8.-DAA-LECTURE-8-RECURRENCES-AND-ITERATION-METHOD.pdf
8.-DAA-LECTURE-8-RECURRENCES-AND-ITERATION-METHOD.pdf
 
Analysis Of Algorithms Ii
Analysis Of Algorithms IiAnalysis Of Algorithms Ii
Analysis Of Algorithms Ii
 
Elementary Differential Equations 11th Edition Boyce Solutions Manual
Elementary Differential Equations 11th Edition Boyce Solutions ManualElementary Differential Equations 11th Edition Boyce Solutions Manual
Elementary Differential Equations 11th Edition Boyce Solutions Manual
 
Ch07 6
Ch07 6Ch07 6
Ch07 6
 
Ch05 2
Ch05 2Ch05 2
Ch05 2
 
1624 sequence
1624 sequence1624 sequence
1624 sequence
 
Ch05 7
Ch05 7Ch05 7
Ch05 7
 
Solution manual for introduction to nonlinear finite element analysis nam-h...
Solution manual for introduction to nonlinear finite element analysis   nam-h...Solution manual for introduction to nonlinear finite element analysis   nam-h...
Solution manual for introduction to nonlinear finite element analysis nam-h...
 
Ch04 2
Ch04 2Ch04 2
Ch04 2
 
Week 8 [compatibility mode]
Week 8 [compatibility mode]Week 8 [compatibility mode]
Week 8 [compatibility mode]
 
01_AJMS_317_21.pdf
01_AJMS_317_21.pdf01_AJMS_317_21.pdf
01_AJMS_317_21.pdf
 

Recently uploaded

Adjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTESAdjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTES
Subhajit Sahu
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Subhajit Sahu
 
一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单
ewymefz
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
ewymefz
 
FP Growth Algorithm and its Applications
FP Growth Algorithm and its ApplicationsFP Growth Algorithm and its Applications
FP Growth Algorithm and its Applications
MaleehaSheikh2
 
Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year Rebound
Oppotus
 
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
ukgaet
 
The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...
jerlynmaetalle
 
一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单
ocavb
 
SOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape ReportSOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape Report
SOCRadar
 
Opendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptxOpendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptx
Opendatabay
 
社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .
NABLAS株式会社
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
ewymefz
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
yhkoc
 
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
correoyaya
 
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
vcaxypu
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Subhajit Sahu
 
一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单
enxupq
 
Investigate & Recover / StarCompliance.io / Crypto_Crimes
Investigate & Recover / StarCompliance.io / Crypto_CrimesInvestigate & Recover / StarCompliance.io / Crypto_Crimes
Investigate & Recover / StarCompliance.io / Crypto_Crimes
StarCompliance.io
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP
 

Recently uploaded (20)

Adjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTESAdjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTES
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
 
一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
 
FP Growth Algorithm and its Applications
FP Growth Algorithm and its ApplicationsFP Growth Algorithm and its Applications
FP Growth Algorithm and its Applications
 
Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year Rebound
 
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
 
The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...
 
一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单
 
SOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape ReportSOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape Report
 
Opendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptxOpendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptx
 
社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
 
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
 
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
 
一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单
 
Investigate & Recover / StarCompliance.io / Crypto_Crimes
Investigate & Recover / StarCompliance.io / Crypto_CrimesInvestigate & Recover / StarCompliance.io / Crypto_Crimes
Investigate & Recover / StarCompliance.io / Crypto_Crimes
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
 

Daa linear recurrences

  • 2. 1 Review A recursive definition of a sequence specifies Initial conditions Recurrence relation Example: a0=0 and a1=3 an = 2an-1 - an-2 an = 3n Initial conditions Recurrence relation Solution
  • 3. 2 Linear recurrences Linear recurrence: Each term of a sequence is a linear function of earlier terms in the sequence. For example: a0 = 1 a1 = 6 a2 = 10 an = an-1 + 2an-2 + 3an-3 a3 = a0 + 2a1 + 3a2 = 1 + 2(6) + 3(10) = 43
  • 4. 3 Linear recurrences Linear recurrences 1. Linear homogeneous recurrences 2. Linear non-homogeneous recurrences
  • 5. 4 Linear homogeneous recurrences A linear homogenous recurrence relation of degree k with constant coefficients is a recurrence relation of the form an = c1an-1 + c2an-2 + … + ckan-k, where c1, c2, …, ck are real numbers, and ck0. an is expressed in terms of the previous k terms of the sequence, so its degree is k. This recurrence includes k initial conditions. a0 = C0 a1 = C1 … ak = Ck
  • 6. 5 Example Determine if the following recurrence relations are linear homogeneous recurrence relations with constant coefficients. Pn = (1.11)Pn-1 a linear homogeneous recurrence relation of degree one an = an-1 + a2 n-2 not linear fn = fn-1 + fn-2 a linear homogeneous recurrence relation of degree two Hn = 2Hn-1+1 not homogeneous an = an-6 a linear homogeneous recurrence relation of degree six Bn = nBn-1 does not have constant coefficient
  • 7. 6 Solving linear homogeneous recurrences Proposition 1: Let an = c1an-1 + c2an-2 + … + ckan-k be a linear homogeneous recurrence. Assume the sequence an satisfies the recurrence. Assume the sequence a’n also satisfies the recurrence. So, bn = an + a’n and dn=an are also sequences that satisfy the recurrence. ( is any constant) Proof: bn = an + a’n = (c1an-1 + c2an-2 + … + ckan-k) + (c1a’n-1 + c2a’n-2 + … + cka’n-k) = c1 (an-1+ a’n-1) + c2 (an-2+ a’n-2) + … + ck (an-k + a’n-k) = c1bn-1 + c2bn-2 + … + ckbn-k So, bn is a solution of the recurrence.
  • 8. 7 Solving linear homogeneous recurrences Proposition 1: Let an = c1an-1 + c2an-2 + … + ckan-k be a linear homogeneous recurrence. Assume the sequence an satisfies the recurrence. Assume the sequence a’n also satisfies the recurrence. So, bn = an + a’n and dn=an are also sequences that satisfy the recurrence. ( is any constant) Proof: dn = an = (c1an-1 + c2an-2 + … + ckan-k) = c1 (an-1) + c2 (an-2) + … + ck (an-k) = c1dn-1 + c2dn-2 + … + ckdn-k So, dn is a solution of the recurrence.
  • 9. 8 Solving linear homogeneous recurrences It follows from the previous proposition, if we find some solutions to a linear homogeneous recurrence, then any linear combination of them will also be a solution to the linear homogeneous recurrence.
  • 10. 9 Solving linear homogeneous recurrences Geometric sequences come up a lot when solving linear homogeneous recurrences. So, try to find any solution of the form an = rn that satisfies the recurrence relation.
  • 11. 10 Solving linear homogeneous recurrences Recurrence relation an = c1an-1 + c2an-2 + … + ckan-k Try to find a solution of form rn rn = c1rn-1 + c2rn-2 + … + ckrn-k rn - c1rn-1 - c2rn-2 - … - ckrn-k = 0 rk - c1rk-1 - c2rk-2 - … - ck = 0 (dividing both sides by rn-k) This equation is called the characteristic equation.
  • 12. 11 Example Example: The Fibonacci recurrence is Fn = Fn-1 + Fn-2 Its characteristic equation is r2 - r - 1 = 0
  • 13. 12 Solving linear homogeneous recurrences Proposition 2: r is a solution of rk - c1rk-1 - c2rk-2 - … - ck = 0 if and only if rn is a solution of an = c1an-1 + c2an-2 + … + ckan-k. Example: consider the characteristic equation r2 - 4r + 4 = 0. r2 - 4r + 4 = (r - 2)2 = 0 So, r=2. So, 2n satisfies the recurrence Fn = 4Fn-1 - 4Fn-2. 2n = 4 . 2n-1 - 4 . 2n-2 2n-2 ( 4 - 8 + 4) = 0
  • 14. 13 Solving linear homogeneous recurrences Theorem 1: Consider the characteristic equation rk - c1rk-1 - c2rk-2 - … - ck = 0 and the recurrence an = c1an-1 + c2an-2 + … + ckan-k. Assume r1, r2, …and rm all satisfy the equation. Let 1, 2, …, m be any constants. So, an = 1 r1 n + 2 r2 n + … + m rm n satisfies the recurrence. Proof: By Proposition 2, i ri n satisfies the recurrence. So, by Proposition 1, i i ri n satisfies the recurrence. Applying Proposition 1 again, the sequence an = 1 r1 n + 2 r2 n + … + m rm n satisfies the recurrence.
  • 15. 14 Example What is the solution of the recurrence relation an = an-1 + 2an-2 with a0=2 and a1=7? Solution: Since it is linear homogeneous recurrence, first find its characteristic equation r2 - r - 2 = 0 (r+1)(r-2) = 0 r1 = 2 and r2 = -1 So, by theorem an = 12n + 2(-1)n is a solution. Now we should find 1 and 2 using initial conditions. a0= 1 + 2 = 2 a1= 12 + 2(-1) = 7 So, 1= 3 and 2 = -1. an = 3 . 2n - (-1)n is a solution.
  • 16. 15 Example What is the solution of the recurrence relation fn = fn-1 + fn-2 with f0=0 and f1=1? Solution: Since it is linear homogeneous recurrence, first find its characteristic equation r2 - r - 1 = 0 r1 = (1+)/2 and r2 = (1-)/2 So, by theorem fn = 1((1+)/2)n + 2((1-)/2)n is a solution. Now we should find 1 and 2 using initial conditions. f0= 1 + 2 = 0 f1= 1(1+)/2 + 2 (1-)/2 = 1 So, 1= 1/ and 2 = -1/. an = 1/ . ((1+)/2)n - 1/((1-)/2)n is a solution.
  • 17. 16 Example What is the solution of the recurrence relation an = -an-1 + 4an-2 + 4an-3 with a0=8, a1=6 and a2=26? Solution: Since it is linear homogeneous recurrence, first find its characteristic equation r3 + r2 - 4r - 4 = 0 (r+1)(r+2)(r-2) = 0 r1 = -1, r2 = -2 and r3 = 2 So, by theorem an = 1(-1)n + 2(-2)n + 32n is a solution. Now we should find 1, 2 and 3 using initial conditions. a0= 1 + 2 + 3 = 8 a1= - 1 - 22 + 23 = 6 a2= 1 + 42 + 43 = 26 So, 1= 2, 2 = 1 and 3 = 5. an = 2 . (-1)n + (-2)n + 5 . 2n is a solution.
  • 18. 17 Solving linear homogeneous recurrences If the characteristic equation has k distinct solutions r1, r2, …, rk, it can be written as (r - r1)(r - r2)…(r - rk) = 0. If, after factoring, the equation has m+1 factors of (r - r1), for example, r1 is called a solution of the characteristic equation with multiplicity m+1. When this happens, not only r1 n is a solution, but also nr1 n, n2r1 n, … and nmr1 n are solutions of the recurrence.
  • 19. 18 Solving linear homogeneous recurrences Proposition 3: Assume r0 is a solution of the characteristic equation with multiplicity at least m+1. So, nmr0 n is a solution to the recurrence.
  • 20. 19 Solving linear homogeneous recurrences When a characteristic equation has fewer than k distinct solutions: We obtain sequences of the form described in Proposition 3. By Proposition 1, we know any combination of these solutions is also a solution to the recurrence. We can find those that satisfies the initial conditions.
  • 21. 20 Solving linear homogeneous recurrences Theorem 2: Consider the characteristic equation rk - c1rk-1 - c2rk-2 - … - ck = 0 and the recurrence an = c1an-1 + c2an-2 + … + ckan-k. Assume the characteristic equation has tk distinct solutions. Let i (1it) ri with multiplicity mi be a solution of the equation. Let i,j (1it and 0jmi-1) ij be a constant. So, an = (10 + 11 n+ … + 1,m1-1 nm1-1 ) r1 n + (20 + 21 n+ … + 2,m2-1 nm2-1 ) r2 n + … + (t0 + t1 n+ … + t,mt-1 nmt-1 ) rt n satisfies the recurrence.
  • 22. 21 Example What is the solution of the recurrence relation an = 6an-1 - 9an-2 with a0=1 and a1=6? Solution: First find its characteristic equation r2 - 6r + 9 = 0 (r - 3)2 = 0 r1 = 3 (Its multiplicity is 2.) So, by theorem an = (10 + 11n)(3)n is a solution. Now we should find constants using initial conditions. a0= 10 = 1 a1= 3 10 + 311 = 6 So, 11= 1 and 10 = 1. an = 3n + n3n is a solution.
  • 23. 22 Example What is the solution of the recurrence relation an = -3an-1 - 3an-2 - an-3 with a0=1, a1=-2 and a2=-1? Solution: Find its characteristic equation r3 + 3r2 + 3r + 1 = 0 (r + 1)3 = 0 r1 = -1 (Its multiplicity is 3.) So, by theorem an = (10 + 11n + 12n2)(-1)n is a solution. Now we should find constants using initial conditions. a0= 10 = 1 a1= -10 - 11 - 12 = -2 a2= 10 + 211 + 412 = -1 So, 10= 1, 11 = 3 and 12 = -2. an = (1 + 3n - 2n2) (-1)n is a solution.
  • 24. 23 Example What is the solution of the recurrence relation an = 8an-2 - 16an-4 , for n4, with a0=1, a1=4, a2=28 and a3=32? Solution: Find its characteristic equation r4 - 8r2 + 16 = 0 (r2 - 4)2 = (r-2)2 (r+2)2 = 0 r1 = 2 r2 = -2 (Their multiplicities are 2.) So, by theorem an = (10 + 11n)(2)n + (20 + 21n)(-2)n is a solution. Now we should find constants using initial conditions. a0= 10 + 20 = 1 a1= 210 + 211 - 220 - 221 = 4 a2= 410 + 811 + 420 + 821 = 28 a3= 810 + 2411 - 820 - 2421 = 32 So, 10= 1, 11 = 2, 20 = 0 and 21 = 1. an = (1 + 2n) 2n + n (-2)n is a solution.
  • 25. 24 Linear non-homogeneous recurrences A linear non-homogenous recurrence relation with constant coefficients is a recurrence relation of the form an = c1an-1 + c2an-2 + … + ckan-k+ f(n), where c1, c2, …, ck are real numbers, and f(n) is a function depending only on n. The recurrence relation an = c1an-1 + c2an-2 + … + ckan-k, is called the associated homogeneous recurrence relation. This recurrence includes k initial conditions. a0 = C0 a1 = C1 … ak = Ck
  • 26. 25 Example The following recurrence relations are linear non- homogeneous recurrence relations. an = an-1 + 2n an = an-1 + an-2 + n2 + n + 1 an = an-1 + an-4 + n! an = an-6 + n2n
  • 27. 26 Linear non-homogeneous recurrences Proposition 4: Let an = c1an-1 + c2an-2 + … + ckan-k + f(n) be a linear non-homogeneous recurrence. Assume the sequence bn satisfies the recurrence. Another sequence an satisfies the non- homogeneous recurrence if and only if hn = an - bn is also a sequence that satisfies the associated homogeneous recurrence.
  • 28. 27 Linear non-homogeneous recurrences Proof: Part1: if hn satisfies the associated homogeneous recurrence then an is satisfies the non-homogeneous recurrence. bn = c1bn-1 + c2bn-2 + … + ckbn-k + f(n) hn = c1hn-1 + c2hn-2 + … + ckhn-k bn + hn = c1 (bn-1+ hn-1) + c2 (bn-2+ hn-2) + … + ck (bn-k + hn-k) + f(n) Since an = bn + hn, an = c1an-1 + c2an-2 + … + ckan-k+ f(n). So, an is a solution of the non-homogeneous recurrence.
  • 29. 28 Linear non-homogeneous recurrences Proof: Part2: if an satisfies the non-homogeneous recurrence then hn is satisfies the associated homogeneous recurrence. bn = c1bn-1 + c2bn-2 + … + ckbn-k + f(n) an = c1an-1 + c2an-2 + … + ckan-k+ f(n) an - bn = c1 (an-1- bn-1) + c2 (an-2- bn-2) + … + ck (an-k - bn-k) Since hn = an - bn, hn = c1hn-1 + c2hn-2 + … + ckhn-k So, hn is a solution of the associated homogeneous recurrence.
  • 30. 29 Linear non-homogeneous recurrences Proposition 4: Let an = c1an-1 + c2an-2 + … + ckan-k + f(n) be a linear non- homogeneous recurrence. Assume the sequence bn satisfies the recurrence. Another sequence an satisfies the non-homogeneous recurrence if and only if hn = an - bn is also a sequence that satisfies the associated homogeneous recurrence. We already know how to find hn. For many common f(n), a solution bn to the non-homogeneous recurrence is similar to f(n). Then you should find solution an = bn + hn to the non- homogeneous recurrence that satisfies both recurrence and initial conditions.
  • 31. 30 Example What is the solution of the recurrence relation an = an-1 + an-2 + 3n + 1 for n2, with a0=2 and a1=3? Solution: Since it is linear non-homogeneous recurrence, bn is similar to f(n) Guess: bn = cn + d bn = bn-1 + bn-2 + 3n + 1 cn + d = c(n-1) + d + c(n-2) + d + 3n + 1 cn + d = cn - c + d + cn -2c + d +3n + 1 0 = (3+c)n + (d-3c+1) c = -3 d=-10 So, bn = - 3n - 10. (bn only satisfies the recurrence, it does not satisfy the initial conditions.)
  • 32. 31 Example What is the solution of the recurrence relation an = an-1 + an-2 + 3n + 1 for n2, with a0=2 and a1=3? Solution: We are looking for an that satisfies both recurrence and initial conditions. an = bn + hn where hn is a solution for the associated homogeneous recurrence: hn = hn-1 + hn-2 By previous example, we know hn = 1((1+)/2)n + 2((1-)/2)n. an = bn + hn = - 3n - 10 + 1((1+)/2)n + 2((1-)/2)n Now we should find constants using initial conditions. a0= -10 + 1 + 2 = 2 a1= -13 + 1 (1+)/2 + 2 (1-)/2 = 3 1 = 6 + 2 2 = 6 - 2 So, an = -3n - 10 + (6 + 2 )((1+)/2)n + (6 - 2 )((1-)/2)n.
  • 33. 32 Example What is the solution of the recurrence relation an = 2an-1 - an-2 + 2n for n2, with a0=1 and a1=2? Solution: Since it is linear non-homogeneous recurrence, bn is similar to f(n) Guess: bn = c2n + d bn = 2bn-1 - bn-2 + 2n c2n + d = 2(c2n-1 + d) - (c2n-2 + d) + 2n c2n + d = c2n + 2d - c2n-2 - d + 2n 0 = (-4c + 4c - c + 4)2n-2 + (-d + 2d -d) c = 4 d=0 So, bn = 4 . 2n. (bn only satisfies the recurrence, it does not satisfy the initial conditions.)
  • 34. 33 Example What is the solution of the recurrence relation an = 2an-1 - an-2 + 2n for n2, with a0=1 and a1=2? Solution: We are looking for an that satisfies both recurrence and initial conditions. an = bn + hn where hn is a solution for the associated homogeneous recurrence: hn = 2hn-1 - hn-2. Find its characteristic equation r2 - 2r + 1 = 0 (r - 1)2 = 0 r1 = 1 (Its multiplicity is 2.) So, by theorem hn = (1 + 2n)(1)n = 1 + 2n is a solution.
  • 35. 34 Example What is the solution of the recurrence relation an = 2an-1 - an-2 + 2n for n2, with a0=1 and a1=2? Solution: an = bn + hn an = 4 . 2n + 1 + 2n is a solution. Now we should find constants using initial conditions. a0= 4 + 1 = 1 a1= 8 - 1 + 2 = 2 1 = -3 2 = -3 So, an = 4 . 2n - 3n - 3.
  • 36. 35 Recommended exercises 1,3,15,17,19,21,23,25,31,35 Eric Ruppert’s Notes about Solving Recurrences (http://www.cse.yorku.ca/course_archive/2007 -08/F/1019/A/recurrence.pdf)