SlideShare ist ein Scribd-Unternehmen logo
1 von 6
RECURRENCE EQUATION BY TARUN GEHLOTS

We solve recurrence equations often in analyzing
complexity of algorithms, circuits, and such other
cases.

A homogeneous recurrence equation is written as:
a0tn + a1tn-1 + . . . . + aktn-k = 0.

Solution technique:

Step 1: Set up a corresponding Characteristic
Equation:
a0 xn + a1 x(n-1) + …. + ak x(n-k) = 0,
x(n-k) [a0 xk + a1 x(k-1) + … +ak ] = 0,

a0xk + a1xk-1 + . . . . + ak = 0 [ for x =/= 0]

Step 2: Solve the characteristic equation as a
polynomial equation. Say, the real roots are r1, r2, . . . . ,
rk. Note, there are k solutions for k-th order
polynomial equation.
Step 3: The general solution for the original
recurrence equation is:
tn = i=1kcirin

Step 4: Using initial conditions (if available) solve
for the coefficients in above equation in order to find
the particular solution.

Example 1:
tn – 3tn-1 – 4tn-2 = 0, for n >= 2. {Initial condition:
t0=0, t1=1}

Characteristic equation: xn – 3x(n-1) – 4x(n-2) = 0,
Or, x(n-2) [x2 –3x –4] = 0,
Or, x2 – 3x – 4 = 0,
Or, x2 + x – 4x – 4 = 0,
Or, x(x+1) –4(x+1) = 0,
Or, (x+1)(x-4) = 0,
Therefore, roots are, x = -1, 4.

So, the general solution of the given recurrence
equation is:
tn = c1*(-1)n + c2*(4n)

Use t0 = c1 + c2 = 0, and t1 = -c1 + 4c2 = 1. [Note,
we need two initial conditions for two coefficients.]
Sove for c1 and c2,
c1 = -(1/5), c2 = (1/5).

So, the particular solution is:
tn = (1/5)[4n – (-1)n] = (4n)

End example.

Inhomogeneous recurrence equation

a0tn + a1tn-1 + . . . . + aktn-k = bnp(n), where b is a
          constant and p(n) is a polynomial of order n.

Solution technique:

Step 0: Homogenize the given equation to an
equivalent homogeneous recurrence equation form.

Step 1 through 3 (or 4) are the same as in the case of
solving homogeneous recurrence equation.

Example 2:

tn – 2tn-1 = 3n. [Note, this is a special case with p(n)
=1, polynomial of 0-th order, and there is no initial
condition – so we get the general solution only.]

Transform with n->n+1:
tn+1 – 2tn = 3n+1   Eqn(1).

Multiply original eqn with 3 on both the sides:
3tn – 6tn-1 = 3n+1 Eqn(2).

Subtract Eqn(2) from Eqn(1):
tn+1 – 5tn + 6tn-1 = 0, this is a homogeneous
recurrence equation which is equivalent to the given
inhomogeneous equation.

Characteristic equation: x2 – 5 x + 6 = 0.
Which is (x-2)(x-3) = 0.

So, roots are x = 2, 3.

General solution of the given recurrence equation is:
tn = c1*(2n) + c2*(3n) = (3n)

End example 2.

Homogenizing may need multiple steps.

Example 3:

tn – 2tn-1 = n

So, tn+1 – 2tn = n+1
Subtracting the former (given) eqn from the latter
eqn,
tn+1 – 3tn + 2tn-1 = 1

Still not a homogeneous eqn. Second stage of
homogenizing,
tn+2 – 3tn+1 + 2tn = 1

Subtract once again,
tn+2 – 4tn+1 + 5tn - 2tn-1 = 0

Now it is a homogeneous recurrence equation and
one can solve it in the usual way.

End example 3e.

An important special case:

If the characteristic eqn. is like
(x-2)(x-3)2 = 0,      [CAN YOU CONSTRUCT THE
ORIGINAL HOMOGENEOUS RECURRENCE EQN
BACK?]

The roots are x = 2, 3, 3 for a polynomial eqn. of
order 3.

The general solution for the given recurrence eqn. is
then,
tn = c1*(2n) + c2*(3n) + c3*n*(3n)

Note the additional n in the third term.

If the roots were
x = 3, 3, 3, then

The general solution would be
tn = c1*(3n) + c2*n*(3n) + c3*(n2)*( 3n),

and so on so forth…


A special type of recurrence equation that is
frequently encountered in algorithms' analyses
                    i
T(n) = aT(n/b) + cn , for some constant integer i, and
constants of coefficients a and c.

Three cases:
     i
a = b , the solution is T(n) = O(ni log b n);
     i                                  a
a > b , the solution is T(n) = O(nlog_b );
     i
a < b , the solution is T(n) = O(ni);

Weitere ähnliche Inhalte

Was ist angesagt?

ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra Sahil Kumar
 
Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Deepak John
 
Circular linked list
Circular linked listCircular linked list
Circular linked listchauhankapil
 
Sets and disjoint sets union123
Sets and disjoint sets union123Sets and disjoint sets union123
Sets and disjoint sets union123Ankita Goyal
 
01. design & analysis of agorithm intro & complexity analysis
01. design & analysis of agorithm intro & complexity analysis01. design & analysis of agorithm intro & complexity analysis
01. design & analysis of agorithm intro & complexity analysisOnkar Nath Sharma
 
Arguments and methods of proof
Arguments and methods of proofArguments and methods of proof
Arguments and methods of proofRobert Geofroy
 
CONTEXT FREE GRAMMAR
CONTEXT FREE GRAMMAR CONTEXT FREE GRAMMAR
CONTEXT FREE GRAMMAR Zahid Parvez
 
RABIN KARP ALGORITHM STRING MATCHING
RABIN KARP ALGORITHM STRING MATCHINGRABIN KARP ALGORITHM STRING MATCHING
RABIN KARP ALGORITHM STRING MATCHINGAbhishek Singh
 
CHOMSKY AND GREIBACH NORMAL FORM.ppt
CHOMSKY AND GREIBACH NORMAL FORM.pptCHOMSKY AND GREIBACH NORMAL FORM.ppt
CHOMSKY AND GREIBACH NORMAL FORM.pptMansiMalik22
 
strassen matrix multiplication algorithm
strassen matrix multiplication algorithmstrassen matrix multiplication algorithm
strassen matrix multiplication algorithmevil eye
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of AlgorithmsArvind Krishnaa
 
Simplifies and normal forms - Theory of Computation
Simplifies and normal forms - Theory of ComputationSimplifies and normal forms - Theory of Computation
Simplifies and normal forms - Theory of ComputationNikhil Pandit
 
Counting Sort and Radix Sort Algorithms
Counting Sort and Radix Sort AlgorithmsCounting Sort and Radix Sort Algorithms
Counting Sort and Radix Sort AlgorithmsSarvesh Rawat
 
Advanced procedures in assembly language Full chapter ppt
Advanced procedures in assembly language Full chapter pptAdvanced procedures in assembly language Full chapter ppt
Advanced procedures in assembly language Full chapter pptMuhammad Sikandar Mustafa
 

Was ist angesagt? (20)

ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
 
Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1
 
Circular linked list
Circular linked listCircular linked list
Circular linked list
 
Sets and disjoint sets union123
Sets and disjoint sets union123Sets and disjoint sets union123
Sets and disjoint sets union123
 
Shell sort[1]
Shell sort[1]Shell sort[1]
Shell sort[1]
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 
01. design & analysis of agorithm intro & complexity analysis
01. design & analysis of agorithm intro & complexity analysis01. design & analysis of agorithm intro & complexity analysis
01. design & analysis of agorithm intro & complexity analysis
 
Arguments and methods of proof
Arguments and methods of proofArguments and methods of proof
Arguments and methods of proof
 
CONTEXT FREE GRAMMAR
CONTEXT FREE GRAMMAR CONTEXT FREE GRAMMAR
CONTEXT FREE GRAMMAR
 
Multi ways trees
Multi ways treesMulti ways trees
Multi ways trees
 
b+ tree
b+ treeb+ tree
b+ tree
 
RABIN KARP ALGORITHM STRING MATCHING
RABIN KARP ALGORITHM STRING MATCHINGRABIN KARP ALGORITHM STRING MATCHING
RABIN KARP ALGORITHM STRING MATCHING
 
CHOMSKY AND GREIBACH NORMAL FORM.ppt
CHOMSKY AND GREIBACH NORMAL FORM.pptCHOMSKY AND GREIBACH NORMAL FORM.ppt
CHOMSKY AND GREIBACH NORMAL FORM.ppt
 
strassen matrix multiplication algorithm
strassen matrix multiplication algorithmstrassen matrix multiplication algorithm
strassen matrix multiplication algorithm
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of Algorithms
 
Ch2 finite automaton
Ch2 finite automatonCh2 finite automaton
Ch2 finite automaton
 
Simplifies and normal forms - Theory of Computation
Simplifies and normal forms - Theory of ComputationSimplifies and normal forms - Theory of Computation
Simplifies and normal forms - Theory of Computation
 
Counting Sort and Radix Sort Algorithms
Counting Sort and Radix Sort AlgorithmsCounting Sort and Radix Sort Algorithms
Counting Sort and Radix Sort Algorithms
 
Advanced procedures in assembly language Full chapter ppt
Advanced procedures in assembly language Full chapter pptAdvanced procedures in assembly language Full chapter ppt
Advanced procedures in assembly language Full chapter ppt
 
P versus NP
P versus NPP versus NP
P versus NP
 

Andere mochten auch

Intervals of validity
Intervals of validityIntervals of validity
Intervals of validityTarun Gehlot
 
Modelling with first order differential equations
Modelling with first order differential equationsModelling with first order differential equations
Modelling with first order differential equationsTarun Gehlot
 
Real meaning of functions
Real meaning of functionsReal meaning of functions
Real meaning of functionsTarun Gehlot
 
How to draw a good graph
How to draw a good graphHow to draw a good graph
How to draw a good graphTarun Gehlot
 
Describing and exploring data
Describing and exploring dataDescribing and exploring data
Describing and exploring dataTarun Gehlot
 
Linear approximations
Linear approximationsLinear approximations
Linear approximationsTarun Gehlot
 
An applied approach to calculas
An applied approach to calculasAn applied approach to calculas
An applied approach to calculasTarun Gehlot
 
Graphs of trigonometric functions
Graphs of trigonometric functionsGraphs of trigonometric functions
Graphs of trigonometric functionsTarun Gehlot
 
Solution of nonlinear_equations
Solution of nonlinear_equationsSolution of nonlinear_equations
Solution of nonlinear_equationsTarun Gehlot
 
Probability and statistics as helpers in real life
Probability and statistics as helpers in real lifeProbability and statistics as helpers in real life
Probability and statistics as helpers in real lifeTarun Gehlot
 
C4 discontinuities
C4 discontinuitiesC4 discontinuities
C4 discontinuitiesTarun Gehlot
 
The shortest distance between skew lines
The shortest distance between skew linesThe shortest distance between skew lines
The shortest distance between skew linesTarun Gehlot
 
Review taylor series
Review taylor seriesReview taylor series
Review taylor seriesTarun Gehlot
 
The newton raphson method
The newton raphson methodThe newton raphson method
The newton raphson methodTarun Gehlot
 
Linear programming
Linear programmingLinear programming
Linear programmingTarun Gehlot
 
Limitations of linear programming
Limitations of linear programmingLimitations of linear programming
Limitations of linear programmingTarun Gehlot
 

Andere mochten auch (20)

Logicgates
LogicgatesLogicgates
Logicgates
 
Intervals of validity
Intervals of validityIntervals of validity
Intervals of validity
 
Modelling with first order differential equations
Modelling with first order differential equationsModelling with first order differential equations
Modelling with first order differential equations
 
Real meaning of functions
Real meaning of functionsReal meaning of functions
Real meaning of functions
 
How to draw a good graph
How to draw a good graphHow to draw a good graph
How to draw a good graph
 
Describing and exploring data
Describing and exploring dataDescribing and exploring data
Describing and exploring data
 
Linear approximations
Linear approximationsLinear approximations
Linear approximations
 
Critical points
Critical pointsCritical points
Critical points
 
An applied approach to calculas
An applied approach to calculasAn applied approach to calculas
An applied approach to calculas
 
Graphs of trigonometric functions
Graphs of trigonometric functionsGraphs of trigonometric functions
Graphs of trigonometric functions
 
Solution of nonlinear_equations
Solution of nonlinear_equationsSolution of nonlinear_equations
Solution of nonlinear_equations
 
Matrix algebra
Matrix algebraMatrix algebra
Matrix algebra
 
Probability and statistics as helpers in real life
Probability and statistics as helpers in real lifeProbability and statistics as helpers in real life
Probability and statistics as helpers in real life
 
C4 discontinuities
C4 discontinuitiesC4 discontinuities
C4 discontinuities
 
The shortest distance between skew lines
The shortest distance between skew linesThe shortest distance between skew lines
The shortest distance between skew lines
 
Thermo dynamics
Thermo dynamicsThermo dynamics
Thermo dynamics
 
Review taylor series
Review taylor seriesReview taylor series
Review taylor series
 
The newton raphson method
The newton raphson methodThe newton raphson method
The newton raphson method
 
Linear programming
Linear programmingLinear programming
Linear programming
 
Limitations of linear programming
Limitations of linear programmingLimitations of linear programming
Limitations of linear programming
 

Ähnlich wie Recurrence equations

Daa linear recurrences
Daa linear recurrencesDaa linear recurrences
Daa linear recurrencesAtul Verma
 
LINEAR RECURRENCE RELATIONS WITH CONSTANT COEFFICIENTS
 LINEAR RECURRENCE RELATIONS WITH CONSTANT COEFFICIENTS LINEAR RECURRENCE RELATIONS WITH CONSTANT COEFFICIENTS
LINEAR RECURRENCE RELATIONS WITH CONSTANT COEFFICIENTSAartiMajumdar1
 
recurence solutions
recurence solutionsrecurence solutions
recurence solutionssoumya8396
 
Solving linear homogeneous recurrence relations
Solving linear homogeneous recurrence relationsSolving linear homogeneous recurrence relations
Solving linear homogeneous recurrence relationsDr. Maamoun Ahmed
 
Solving recurrences
Solving recurrencesSolving recurrences
Solving recurrencesWaqas Akram
 
Solving recurrences
Solving recurrencesSolving recurrences
Solving recurrencesWaqas Akram
 
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 ManualMiriamKennedys
 
Analysis Of Algorithms Ii
Analysis Of Algorithms IiAnalysis Of Algorithms Ii
Analysis Of Algorithms IiSri Prasanna
 
RECURRENCE EQUATIONS & ANALYZING THEM
RECURRENCE EQUATIONS & ANALYZING THEMRECURRENCE EQUATIONS & ANALYZING THEM
RECURRENCE EQUATIONS & ANALYZING THEMAlpana Ingale
 
Recurrence_Theory.pptx studdents nees free
Recurrence_Theory.pptx studdents nees freeRecurrence_Theory.pptx studdents nees free
Recurrence_Theory.pptx studdents nees freeWhite44420
 
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.pdfRishikeshJha33
 
T2311 - Ch 4_Part1.pptx
T2311 - Ch 4_Part1.pptxT2311 - Ch 4_Part1.pptx
T2311 - Ch 4_Part1.pptxGadaFarhan
 
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 Analysisijtsrd
 
Recurrence Relation
Recurrence RelationRecurrence Relation
Recurrence RelationPapu Kumar
 

Ähnlich wie Recurrence equations (20)

Daa linear recurrences
Daa linear recurrencesDaa linear recurrences
Daa linear recurrences
 
LINEAR RECURRENCE RELATIONS WITH CONSTANT COEFFICIENTS
 LINEAR RECURRENCE RELATIONS WITH CONSTANT COEFFICIENTS LINEAR RECURRENCE RELATIONS WITH CONSTANT COEFFICIENTS
LINEAR RECURRENCE RELATIONS WITH CONSTANT COEFFICIENTS
 
recurence solutions
recurence solutionsrecurence solutions
recurence solutions
 
Solving linear homogeneous recurrence relations
Solving linear homogeneous recurrence relationsSolving linear homogeneous recurrence relations
Solving linear homogeneous recurrence relations
 
Time complexity
Time complexityTime complexity
Time complexity
 
Solving recurrences
Solving recurrencesSolving recurrences
Solving recurrences
 
Solving recurrences
Solving recurrencesSolving recurrences
Solving recurrences
 
3.pdf
3.pdf3.pdf
3.pdf
 
Ch07 7
Ch07 7Ch07 7
Ch07 7
 
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
 
Analysis Of Algorithms Ii
Analysis Of Algorithms IiAnalysis Of Algorithms Ii
Analysis Of Algorithms Ii
 
Ch07 5
Ch07 5Ch07 5
Ch07 5
 
RECURRENCE EQUATIONS & ANALYZING THEM
RECURRENCE EQUATIONS & ANALYZING THEMRECURRENCE EQUATIONS & ANALYZING THEM
RECURRENCE EQUATIONS & ANALYZING THEM
 
Recurrence_Theory.pptx studdents nees free
Recurrence_Theory.pptx studdents nees freeRecurrence_Theory.pptx studdents nees free
Recurrence_Theory.pptx studdents nees free
 
Ch07 6
Ch07 6Ch07 6
Ch07 6
 
Maths
MathsMaths
Maths
 
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
 
T2311 - Ch 4_Part1.pptx
T2311 - Ch 4_Part1.pptxT2311 - Ch 4_Part1.pptx
T2311 - Ch 4_Part1.pptx
 
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
 
Recurrence Relation
Recurrence RelationRecurrence Relation
Recurrence Relation
 

Mehr von Tarun Gehlot

Materials 11-01228
Materials 11-01228Materials 11-01228
Materials 11-01228Tarun Gehlot
 
Continuity and end_behavior
Continuity and  end_behaviorContinuity and  end_behavior
Continuity and end_behaviorTarun Gehlot
 
Continuity of functions by graph (exercises with detailed solutions)
Continuity of functions by graph   (exercises with detailed solutions)Continuity of functions by graph   (exercises with detailed solutions)
Continuity of functions by graph (exercises with detailed solutions)Tarun Gehlot
 
Factoring by the trial and-error method
Factoring by the trial and-error methodFactoring by the trial and-error method
Factoring by the trial and-error methodTarun Gehlot
 
Introduction to finite element analysis
Introduction to finite element analysisIntroduction to finite element analysis
Introduction to finite element analysisTarun Gehlot
 
Finite elements : basis functions
Finite elements : basis functionsFinite elements : basis functions
Finite elements : basis functionsTarun Gehlot
 
Finite elements for 2‐d problems
Finite elements  for 2‐d problemsFinite elements  for 2‐d problems
Finite elements for 2‐d problemsTarun Gehlot
 
Error analysis statistics
Error analysis   statisticsError analysis   statistics
Error analysis statisticsTarun Gehlot
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabTarun Gehlot
 
Linear approximations and_differentials
Linear approximations and_differentialsLinear approximations and_differentials
Linear approximations and_differentialsTarun Gehlot
 
Local linear approximation
Local linear approximationLocal linear approximation
Local linear approximationTarun Gehlot
 
Interpolation functions
Interpolation functionsInterpolation functions
Interpolation functionsTarun Gehlot
 
Propeties of-triangles
Propeties of-trianglesPropeties of-triangles
Propeties of-trianglesTarun Gehlot
 
Gaussian quadratures
Gaussian quadraturesGaussian quadratures
Gaussian quadraturesTarun Gehlot
 
Basics of set theory
Basics of set theoryBasics of set theory
Basics of set theoryTarun Gehlot
 
Numerical integration
Numerical integrationNumerical integration
Numerical integrationTarun Gehlot
 
Applications of set theory
Applications of  set theoryApplications of  set theory
Applications of set theoryTarun Gehlot
 
Miscellneous functions
Miscellneous  functionsMiscellneous  functions
Miscellneous functionsTarun Gehlot
 

Mehr von Tarun Gehlot (20)

Materials 11-01228
Materials 11-01228Materials 11-01228
Materials 11-01228
 
Binary relations
Binary relationsBinary relations
Binary relations
 
Continuity and end_behavior
Continuity and  end_behaviorContinuity and  end_behavior
Continuity and end_behavior
 
Continuity of functions by graph (exercises with detailed solutions)
Continuity of functions by graph   (exercises with detailed solutions)Continuity of functions by graph   (exercises with detailed solutions)
Continuity of functions by graph (exercises with detailed solutions)
 
Factoring by the trial and-error method
Factoring by the trial and-error methodFactoring by the trial and-error method
Factoring by the trial and-error method
 
Introduction to finite element analysis
Introduction to finite element analysisIntroduction to finite element analysis
Introduction to finite element analysis
 
Finite elements : basis functions
Finite elements : basis functionsFinite elements : basis functions
Finite elements : basis functions
 
Finite elements for 2‐d problems
Finite elements  for 2‐d problemsFinite elements  for 2‐d problems
Finite elements for 2‐d problems
 
Error analysis statistics
Error analysis   statisticsError analysis   statistics
Error analysis statistics
 
Matlab commands
Matlab commandsMatlab commands
Matlab commands
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Linear approximations and_differentials
Linear approximations and_differentialsLinear approximations and_differentials
Linear approximations and_differentials
 
Local linear approximation
Local linear approximationLocal linear approximation
Local linear approximation
 
Interpolation functions
Interpolation functionsInterpolation functions
Interpolation functions
 
Propeties of-triangles
Propeties of-trianglesPropeties of-triangles
Propeties of-triangles
 
Gaussian quadratures
Gaussian quadraturesGaussian quadratures
Gaussian quadratures
 
Basics of set theory
Basics of set theoryBasics of set theory
Basics of set theory
 
Numerical integration
Numerical integrationNumerical integration
Numerical integration
 
Applications of set theory
Applications of  set theoryApplications of  set theory
Applications of set theory
 
Miscellneous functions
Miscellneous  functionsMiscellneous  functions
Miscellneous functions
 

Recurrence equations

  • 1. RECURRENCE EQUATION BY TARUN GEHLOTS We solve recurrence equations often in analyzing complexity of algorithms, circuits, and such other cases. A homogeneous recurrence equation is written as: a0tn + a1tn-1 + . . . . + aktn-k = 0. Solution technique: Step 1: Set up a corresponding Characteristic Equation: a0 xn + a1 x(n-1) + …. + ak x(n-k) = 0, x(n-k) [a0 xk + a1 x(k-1) + … +ak ] = 0, a0xk + a1xk-1 + . . . . + ak = 0 [ for x =/= 0] Step 2: Solve the characteristic equation as a polynomial equation. Say, the real roots are r1, r2, . . . . , rk. Note, there are k solutions for k-th order polynomial equation.
  • 2. Step 3: The general solution for the original recurrence equation is: tn = i=1kcirin Step 4: Using initial conditions (if available) solve for the coefficients in above equation in order to find the particular solution. Example 1: tn – 3tn-1 – 4tn-2 = 0, for n >= 2. {Initial condition: t0=0, t1=1} Characteristic equation: xn – 3x(n-1) – 4x(n-2) = 0, Or, x(n-2) [x2 –3x –4] = 0, Or, x2 – 3x – 4 = 0, Or, x2 + x – 4x – 4 = 0, Or, x(x+1) –4(x+1) = 0, Or, (x+1)(x-4) = 0, Therefore, roots are, x = -1, 4. So, the general solution of the given recurrence equation is: tn = c1*(-1)n + c2*(4n) Use t0 = c1 + c2 = 0, and t1 = -c1 + 4c2 = 1. [Note, we need two initial conditions for two coefficients.]
  • 3. Sove for c1 and c2, c1 = -(1/5), c2 = (1/5). So, the particular solution is: tn = (1/5)[4n – (-1)n] = (4n) End example. Inhomogeneous recurrence equation a0tn + a1tn-1 + . . . . + aktn-k = bnp(n), where b is a constant and p(n) is a polynomial of order n. Solution technique: Step 0: Homogenize the given equation to an equivalent homogeneous recurrence equation form. Step 1 through 3 (or 4) are the same as in the case of solving homogeneous recurrence equation. Example 2: tn – 2tn-1 = 3n. [Note, this is a special case with p(n) =1, polynomial of 0-th order, and there is no initial condition – so we get the general solution only.] Transform with n->n+1:
  • 4. tn+1 – 2tn = 3n+1 Eqn(1). Multiply original eqn with 3 on both the sides: 3tn – 6tn-1 = 3n+1 Eqn(2). Subtract Eqn(2) from Eqn(1): tn+1 – 5tn + 6tn-1 = 0, this is a homogeneous recurrence equation which is equivalent to the given inhomogeneous equation. Characteristic equation: x2 – 5 x + 6 = 0. Which is (x-2)(x-3) = 0. So, roots are x = 2, 3. General solution of the given recurrence equation is: tn = c1*(2n) + c2*(3n) = (3n) End example 2. Homogenizing may need multiple steps. Example 3: tn – 2tn-1 = n So, tn+1 – 2tn = n+1
  • 5. Subtracting the former (given) eqn from the latter eqn, tn+1 – 3tn + 2tn-1 = 1 Still not a homogeneous eqn. Second stage of homogenizing, tn+2 – 3tn+1 + 2tn = 1 Subtract once again, tn+2 – 4tn+1 + 5tn - 2tn-1 = 0 Now it is a homogeneous recurrence equation and one can solve it in the usual way. End example 3e. An important special case: If the characteristic eqn. is like (x-2)(x-3)2 = 0, [CAN YOU CONSTRUCT THE ORIGINAL HOMOGENEOUS RECURRENCE EQN BACK?] The roots are x = 2, 3, 3 for a polynomial eqn. of order 3. The general solution for the given recurrence eqn. is then,
  • 6. tn = c1*(2n) + c2*(3n) + c3*n*(3n) Note the additional n in the third term. If the roots were x = 3, 3, 3, then The general solution would be tn = c1*(3n) + c2*n*(3n) + c3*(n2)*( 3n), and so on so forth… A special type of recurrence equation that is frequently encountered in algorithms' analyses i T(n) = aT(n/b) + cn , for some constant integer i, and constants of coefficients a and c. Three cases: i a = b , the solution is T(n) = O(ni log b n); i a a > b , the solution is T(n) = O(nlog_b ); i a < b , the solution is T(n) = O(ni);