0% found this document useful (0 votes)
45 views20 pages

Chapter 5-3

This document discusses variations on solving recurrence relations with constant coefficients. It covers recurrence relations with characteristic polynomials of higher degree, as well as non-homogeneous recurrence relations. For non-homogeneous relations, the solution involves finding a particular solution to the non-homogeneous term and adding it to the general solution of the homogeneous relation. Examples are provided to demonstrate solving both homogeneous and non-homogeneous recurrence relations. The document also discusses the halting problem, which is shown to be undecidable using a proof by contradiction.

Uploaded by

val
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views20 pages

Chapter 5-3

This document discusses variations on solving recurrence relations with constant coefficients. It covers recurrence relations with characteristic polynomials of higher degree, as well as non-homogeneous recurrence relations. For non-homogeneous relations, the solution involves finding a particular solution to the non-homogeneous term and adding it to the general solution of the homogeneous relation. Examples are provided to demonstrate solving both homogeneous and non-homogeneous recurrence relations. The document also discusses the halting problem, which is shown to be undecidable using a proof by contradiction.

Uploaded by

val
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

CHAPTER 5

R E C U R R E N C E R E L AT I O N S
VARIATIONS ON SOLVING RECURRENCE
RELATIONS WITH CONSTANT COEFFICIENTS

• We will discuss some extra problems


• The first group of problems will just be variations on LHRRCC
– Never forget what LHRCC stands for 
VARIATION 1: THE CHARACTERISTIC
POLYNOMIAL HAS HIGH DEGREE
• We only solved problems with a quadratic characteristic polynomial
• That doesn’t have to happen
• Here is a recurrence relation with a characteristic polynomial of higher degree
– For example, an = 2an-1 + an-2 – 2an-3
• This is solvable
– For example, an = an-1 – + an-2 – an-3
• This is s not directly solvable
• It can be “solved” numerically
VARIATION 2: THE RECURRENCE
RELATION IS NOT HOMOGENEOUS
• So now LHRRCC has change to LRCC 
• For this kind of problem, we use a table
– This table is explained (in words, not as a table) on p. 244 as Problem 40
– I have included the table here
• There is an extra step for nonhomogeneous problems that we didn’t have with
homogeneous problems
– You have to find a particular solution to the nonhomogeneous problem
– You have to find a general solution to the HOMOGENEOUS version of the problem
– The solution is the sum of the two
THE TABLE FOR NONHOMOGENEOUS
PROBLEMS
• The original equation is an = c1an-1 + c2an-2 + f(n)
• The characteristic equation is then x2 – c1x – c2 = 0
Is 1 a root of the 1 is not a root 1 is a single root 1 is a double root
characteristic polynomial?

f(n) Format for solution to particular equation


(constant) D Dn Dn2

Cn D1n + D2 D1n2 + D2n D1n3 + D2n2


Cn2 D1n2 + D2n + D3 D1n3 + D2n2 + D3n D1n4 + D2n3 + D3n2
AN EXAMPLE OF A NON-HOMOGENEOUS
RECURRENCE RELATION
• Let’s try to solve an = 6an-1 - 8an-2 + 3
• The homogeneous version of the problem is an = 6an-1 + 8an-2
– The characteristic equation is?
– The roots of the characteristic equation are?
– The solution to the homogeneous equation is?
• Stop and solve this part of the problem
AN EXAMPLE OF A NON-HOMOGENEOUS
RECURRENCE RELATION
• Let’s try to solve an = 6an-1 – 8an-2 + 3
• The homogeneous version of the problem is an = 6an-1 – 8an-2
– The characteristic equation is x2 – 6x + 8 = 0
– The roots of the characteristic equation are 2 and 4
– The solution to the homogeneous equation is an = R(2n) + S(4n)
AN EXAMPLE OF A HOMOGENEOUS
RECURRENCE RELATION
• Now, we solve the nonhomogeneous problem
– The non-homogeneous part is f(n) = 3
• In order to use the table, we need to know if 1 is a root of the characteristic equation
– The answer is no, since the roots are 2, 4
• The table says we should look for a solution to have the form
an = D
• Substituting this into the non-homogeneous equation gives
D = 6D – 8D + 3
• Solving this equation gives D = 1
PUTTING IT ALL TOGETHER

• So the solution is
an = R(2n) + S(4n) + 1
• You have to go through this entire process every time

• If initial conditions are given, you can determine R and S:


• Suppose a0 = 4 and a1 = 11
• Then we have 4 = R(20) + S(40) + 1 and 11 = R(21) + S(41) + 1
• Solving this system gives R = 1 and S = 2, for the solution to the original problem being
an = 2n + 2(4n) + 1
A SECOND EXAMPLE

• Let’s try to solve an = 2an-1 + 8an-2 + 81n2


• The homogeneous version of the problem is?
• The characteristic equation is?
• The roots of the characteristic equation are?
• The solution to the homogeneous equation is?
• See if you can also determine what f(n) is

• Stop and solve this part of the problem


THE ANSWERS

• The equation is an = 2an-1 + 8an-2 + 81n2


• The homogeneous version of the problem is an = 2an-1 + 8an-2
– The characteristic equation is x2 – 2x – 8 = 0
– The roots of the characteristic equation are –2, 4
– The solution to the homogeneous equation is an = R(-2)n + S(4n)
f(n) = 81n2
CONTINUING ON

• Since 1 is not a root of the characteristic equation, the particular solution has the form
an = D1n2 + D2n + D3
• Notice that
an-1 = D1(n-1)2 + D2(n-1) + D3
an-2 = D1(n-2)2 + D2(n-2) + D3

• The recurrence relation an = 2an-1 + 8an-2 + 81n2 becomes


D1n2 + D2n + D3 = 2[D1(n-1)2 + D2(n-1) + D3] + 8[D1(n-2)2 + D2(n-2) + D3] + 81n2
FINDING THE CONSTANTS-PART 1

• We have
D1n2 + D2n + D3 = 2[D1(n-1)2 + D2(n-1) + D3] + 8[D1(n-2)2 + D2(n-2) + D3] + 81n2
• Expanding powers of n gives
D1n2 + D2n + D3 = 2D1(n2-2n+1) + 2D1D2(n-1) + 2D1D3 + 8D1(n2-4n+4) + D2(n-2) + D3 + 81n2
• Distributing and grouping based on powers of n gives
(–9D1 – 81)n2 + (36D1 – 9D2)n + (34D1 + 18D2 – 9D3) = 0
• Since this must be true for all n, we have three separate equations
(–9D1 – 81) = 0
(36D1 – 9D2) = 0
(34D1 + 18D2 – 9D3) = 0
FINISHING THE PROBLEM

• Solving the first equation gives D1 = –9


• Substituting that into the second equation and solving gives D 2 = –36
• Substituting both D1 and D2 into the third equation and solving gives D3 = –38
• So the particular solution is an = –9n2 – 36n – 38
• The solution to the original recurrence relation is
an = R(-2)n + S(4n) – 9n2 – 36n – 38
A PROBLEM TO TRY

• an = 4an-1 – 3an-2 + 20
• The homogeneous version of the problem is?
• The characteristic equation is?
• The roots of the characteristic equation are?
• The solution to the homogeneous equation is?
• See if you can also determine what f(n) is

• Stop and solve this part of the problem


FINISHING THE PROBLEM

• You can see that 1 is a root of the characteristic equation


• This means the particular solution has the form a n = Dn
• Then
an-1 = D(n-1) = Dn – D and an-2 = D(n-2) = Dn – 2D
• We need to solve an = 4an-1 – 3an-2 + 20
Dn = 4Dn – 4D – 3Dn + 6D + 20
• Continuing to solve gives the particular solution of
an = –10n
• For the full solution, find the general solution, and add –10n
THE HALTING PROBLEM

• There is one leftover idea from this chapter


• This is the Halting Problem
• Can you write a program that
– takes as its input another program and that program’s input, and
– determines if that program will run infinitely or stop?
THE HALTING DECIDER

• Suppose you did have a program that could decide


• Let’s call it the Halting Decider.

• I will create another program


• Let’s call it the Halting Undecider
– This program also takes as its input a program
– This program does the opposite of its input.
• If the input program stops, the new program runs forever, (like an infinite loop)
• If the input program runs forever, the new program stops.
HALTING OR NOT?

• Now, we take the Undecider, use it as input to itself, and give this to the Halting Decider

• Now, either a program stops or it doesn’t


– We know this because the Halting Decider can tell us this
• Let’s look at the new Undecider program
– If it stops, it runs forever
– If it runs forever, it stops
• So, there is no Halting Decider, because it can’t tell us if this program halts or not
• We call the halting problem “undecidable”
– This means that it’s impossible to decide if the problem has a solution or not
PRACTICE PROBLEMS

• p. 244, #41-47

You might also like