Linear Recurrence Relations - Arizona State Universityboerner/mat243/8.2 Solving...While there is no...

Preview:

Citation preview

Solving Linear Recurrence Relations

IntroductionRecall from the presentation on sequences and summation that a (k-step) recurrence relation is an equation that defines the elements of a sequence recursively, i.e. in terms of their own predecessors, going back k indices:

π‘Žπ‘› = 𝑓(π‘Žπ‘›βˆ’1, π‘Žπ‘›βˆ’2, … , π‘Žπ‘›βˆ’π‘˜)

A recursive definition involving a k-step recurrence relation requires the values of the first k terms: π‘Ž0, π‘Ž1, … , π‘Žπ‘˜ , called the initial conditions, to define a sequence properly.

The Fibonacci sequence, 𝑓0= 1, 𝑓1 = 1, 𝑓𝑛 = π‘“π‘›βˆ’1 + π‘“π‘›βˆ’2 for 𝑛 = 2,3,4, … is the most well known example of a sequence that is defined recursively.

Recursive definitions are not computationally effective for very large indices. How would you evaluate 𝑓𝑛 where 𝑛 = 10100? Computing this using the recursive definition would require about 10100

additions, which would take far longer than the age of the universe to carry out even on a very fast computer, and in light of the estimate we proved in the presentation on recursively defined functions and sets,

𝑓𝑛 >3

2

π‘›βˆ’2

𝑓𝑛 would have far more digits than the estimated number of atoms in the universe, so it could never even be stored.

Therefore , a natural question with a recursive definition is: can we find a closed-form definition, i.e. a definition that lets us compute (or find a good estimate of) π‘Žπ‘› as a function of 𝑛 alone?

While there is no general method for solving a recurrence relation, there is one that works for linear recurrence relations with constant coefficients, i.e. recurrence relations of the form

π‘Žπ‘›+π‘˜ = 𝑐1π‘Žπ‘›+π‘˜βˆ’1 + 𝑐2π‘Žπ‘›+π‘˜βˆ’2 +β‹―+ π‘π‘˜π‘Žπ‘›

where the 𝑐1, … , π‘π‘˜ are constants. An example of such a recurrence relation would be the 3-step recurrence relation

π‘Žπ‘›+3 = π‘Žπ‘›+2 + 4π‘Žπ‘›+1 βˆ’ 4π‘Žπ‘›

Bad News and Good News

Idea of the MethodOne of the simplest linear, constant-coefficient recurrence relation is π‘Žπ‘›+1 = 2π‘Žπ‘›. Since the sequence value doubles with each step, we know immediately that solution sequences of this recurrence are exponential (aka geometric), i.e. π‘Žπ‘› = 𝑐2𝑛 where 𝑐 = π‘Ž0 is the initial value. In particular, π‘Žπ‘› = 2𝑛 is a solution.

By a solution of a recurrence relation, we mean a sequence whose terms satisfy the recurrence relation. In the example above, π‘Žπ‘›+1 =2𝑛+1 = 2 βˆ™ 2𝑛 = 2π‘Žπ‘›.

This gives us the idea: perhaps all linear, constant-coefficient recurrence relations have exponential solutions? The answer turns out to be affirmative, and this enables us to find all solutions.

Given a recurrence relation, our goal is to find an exponential solution π‘Žπ‘› = π‘Ÿπ‘›, where the unknown base π‘Ÿ β‰  0 remains to be determined.

We substitute π‘Žπ‘› = π‘Ÿπ‘› into the recurrence and find the values of π‘Ÿ for which the recurrence is satisfied.

Example 1π‘Žπ‘›+3 = π‘Žπ‘›+2 + 4π‘Žπ‘›+1 βˆ’ 4π‘Žπ‘›

Substituting π‘Žπ‘› = π‘Ÿπ‘›, we get

π‘Ÿπ‘›+3 = π‘Ÿπ‘›+2 + 4π‘Ÿπ‘›+1 βˆ’ 4π‘Ÿπ‘›

orπ‘Ÿπ‘›+3 βˆ’ π‘Ÿπ‘›+2 βˆ’ 4π‘Ÿπ‘›+1 + 4π‘Ÿπ‘› = 0

Since all terms have a factor π‘Ÿπ‘› in common, we can factor it out:

π‘Ÿπ‘› π‘Ÿ3 βˆ’ π‘Ÿ2 βˆ’ 4π‘Ÿ + 4characteristic polynomial

= 0

We need this to be zero for all 𝑛. Since π‘Ÿ β‰  0, the equation can only be satisfied if the cubic factor is zero. We can factor it by grouping:

π‘Ÿ3 βˆ’ π‘Ÿ2 βˆ’ 4π‘Ÿ + 4 = π‘Ÿ2 π‘Ÿ βˆ’ 1 βˆ’ 4 π‘Ÿ βˆ’ 1 = (π‘Ÿ2βˆ’4)(π‘Ÿ βˆ’ 1) = (π‘Ÿ + 2)(π‘Ÿ βˆ’ 2)(π‘Ÿ βˆ’ 1).

We just found three π‘Ÿ values for which the recurrence is satisfied: π‘Ÿ = βˆ’2, 2, 1.

The cubic polynomial whose zeros we just found is called the characteristic polynomial of the recurrence relation.

Now we know thatπ‘Žπ‘›+3 = π‘Žπ‘›+2 + 4π‘Žπ‘›+1 βˆ’ 4π‘Žπ‘›

is satisfied for π‘Žπ‘›= 2𝑛, π‘Žπ‘› = (βˆ’2)𝑛 and π‘Žπ‘› = 1.

Let’s verify the first of these solutions before we proceed. (The other one can be verified in the same way.)

If π‘Žπ‘›= 2𝑛, thenπ‘Žπ‘›+2 + 4π‘Žπ‘›+1 βˆ’ 4π‘Žπ‘›

= 2𝑛+2 + 4 βˆ™ 2𝑛+1 βˆ’ 4 βˆ™ 2𝑛

= 4 βˆ™ 2𝑛 + 4 βˆ™ 2𝑛+1 βˆ’ 4 βˆ™ 2𝑛

= 4 βˆ™ 2𝑛+1 = 2𝑛+3.

π‘Žπ‘›= 2𝑛, π‘Žπ‘› = (βˆ’2)𝑛 and π‘Žπ‘› = 1 are not the only solutions of

π‘Žπ‘›+3 = π‘Žπ‘›+2 + 4π‘Žπ‘›+1 βˆ’ 4π‘Žπ‘›however. Any constant multiple of a solution is again a solution, and a sum of solutions is again a solution.

Therefore, if π‘Žπ‘›, 𝑏𝑛 and 𝑐𝑛 are solutions, then so must be π‘π‘Žπ‘› + π‘žπ‘π‘› + π‘Ÿπ‘π‘›. Such a sum of the individual solutions with constant factors attached is known as a linear combination of solutions.

Therefore, for any numbers 𝑝, π‘ž and π‘Ÿ,

π‘Žπ‘›= 𝑝2𝑛 + π‘ž βˆ’2 𝑛 + π‘Ÿ

is a solution of our recurrence. In fact, it is the general solution. By that, we mean that any solution of the recurrence is contained in the above formula, for a specific value of 𝑝, π‘ž and π‘Ÿ. We will not prove this, but allude to the reason in non-rigorous terms. First though, we will discuss how initial conditions fit into the picture.

Initial Conditions

Suppose we have a sequence defined recursively by a recurrence relation and a set of initial conditions. Let us study how we can use what we just learned to find a non-recursive description of the sequence. Let us use the following example:

π‘Žπ‘›+3 = π‘Žπ‘›+2 + 4π‘Žπ‘›+1 βˆ’ 4π‘Žπ‘›

with π‘Ž0 = 2, π‘Ž1 = 0, π‘Ž2 = 8.

We know from the calculation we just made that the general solution to the recurrence is

π‘Žπ‘› = 𝑝2𝑛 + π‘ž βˆ’2 𝑛 + π‘Ÿ

That means that we can find 𝑝, π‘ž and π‘Ÿ to match the initial conditions. Substituting the initial conditions leads to a linear system in 3 equations and 3 unknowns:

π‘Ž0 = 2 = 𝑝 + π‘ž + π‘Ÿπ‘Ž1 = 0 = 2𝑝 βˆ’ 2π‘ž + π‘Ÿπ‘Ž2 = 8 = 4𝑝 + 4π‘ž + π‘Ÿ

We can now see why a rigorous, proof-based discussion of the solution theory of linear recurrence relations with constant coefficients and initial conditions is beyond the scope of this class: it requires knowledge of linear algebra. Intuitively though, we can glimpse the reason why the alleged general solution above is the general solution: it has three free variables, p,q,r, and every choice of these variables corresponds to exactly one initial condition π‘Ž0, π‘Ž1 and π‘Ž2, and vice versa.

Solving the linear system

We may solve linear systems of equations by elimination. A full discussion of the elimination method belongs in a linear algebra class; we will only discuss the method by example.

π‘Ž0 = 2 = 𝑝 + π‘ž + π‘Ÿπ‘Ž1 = 0 = 2𝑝 βˆ’ 2π‘ž + π‘Ÿπ‘Ž2 = 8 = 4𝑝 + 4π‘ž + π‘Ÿ

We subtract equation 1 from equation 2 to get a new equation, and we subtract equation 2 from equation 3 to get another new equation. In both equations, the variable π‘Ÿ has been eliminated:

βˆ’2 = 𝑝 βˆ’ 3π‘ž8 = 2𝑝 + 6π‘ž

Now we add two times the first equation to the second to get 4 = 4𝑝, hence 𝑝 = 1. Back-substituting, we get π‘ž = 1 and π‘Ÿ = 0. Therefore, we found

π‘Žπ‘› = 2𝑛 + βˆ’2 𝑛.

The example we just finished is representative of the general situation, as long as the characteristic polynomial has distinct zeros, i.e. zeros that all have multiplicity 1. (Recall from algebra that the multiplicity of a zero of a polynomial is how many times the corresponding linear factor is repeated in the linear factorization of the polynomial.)

Generalization

We solve a linear, constant-coefficient, k-step recurrence relation

π‘Žπ‘›+π‘˜ = 𝑐1π‘Žπ‘›+π‘˜βˆ’1 + 𝑐2π‘Žπ‘›+π‘˜βˆ’2 +β‹―+ π‘π‘˜π‘Žπ‘›

by finding the zeros of the characteristic polynomial

π‘Ÿπ‘˜ βˆ’ 𝑐1π‘Ÿπ‘˜βˆ’1 βˆ’ 𝑐2π‘Ÿ

π‘˜βˆ’2 βˆ’β‹―βˆ’ π‘π‘˜

If these zeros (aka characteristic values) π‘Ÿ1, π‘Ÿ2, … , π‘Ÿπ‘˜ are all distinct (equivalently, have multiplicity one), then the general solution of the recurrence relation is

π‘Žπ‘› = 𝑝1π‘Ÿ1𝑛 + 𝑝2π‘Ÿ2

𝑛 +β‹―+ π‘π‘˜π‘Ÿπ‘˜π‘›

where 𝑝1 to π‘π‘˜ are constants. For each set of initial conditions, π‘Ž0β€¦π‘Žπ‘˜ given, there is one and only one choice of the 𝑝1 to π‘π‘˜ to match the initial conditions. We find these numbers by solving a linear system of k equations in k unknowns.

Repeated Zeros of the Characteristic Polynomial

When the characteristic polynomial has repeated zeros, then our solution method cannot work because the β€œgeneral” solution does not have enough free variables. Therefore, the correct general solution must have a different form. We will not prove or explain the following theorem:

if π‘Ÿ is a repeated zero of the characteristic polynomial with multiplicity π‘š, then not only is π‘Ÿπ‘› a solution, but also π‘›π‘Ÿπ‘›, 𝑛2π‘Ÿπ‘›, … , π‘›π‘šβˆ’1π‘Ÿπ‘›. The general solution is obtained by replacing the constant coefficient of π‘Ÿπ‘› by a general polynomial of degree π‘šβˆ’ 1 in 𝑛.

The required notation to represent this theorem symbolically is a little awkward, so we will illustrate the theorem with an example instead:

Suppose the characteristic polynomial of a linear recurrence relation with constant coefficients is

π‘Ÿ + 1 π‘Ÿ βˆ’ 2 3 π‘Ÿ + 4 2.Then the general solution is

π‘Žπ‘› = 𝑝1 βˆ’1 𝑛 + 𝑝2 + 𝑝3𝑛 + 𝑝4𝑛2 2𝑛 + 𝑝5 + 𝑝6𝑛 βˆ’4 𝑛

Complex Zeros (I)Sometimes, the zeros of the characteristic polynomial are complex. In that case, the general solution will be formally complex as well, but produce real solutions for all real initial values. Let us consider the following example problem:

π‘Žπ‘›+2 = βˆ’π‘Žπ‘›

with π‘Ž0 = 1 and π‘Ž1 = 0.

We can immediately see that this sequence is 1,0,-1,0,1,0,.., but it is not obvious how to describe that with a closed form formula.

The characteristic polynomial is π‘Ÿ2 + 1, hence the two characteristic values are ±𝑖. Thus, the general solution of the recurrence is π‘Žπ‘› = 𝑝𝑖𝑛 + π‘ž βˆ’π‘– 𝑛, with complex numbers p and q. Substituting the initial conditions, we get

1 = 𝑝 + π‘ž0 = 𝑝𝑖 βˆ’ π‘žπ‘–

By dividing the second equation by 𝑖, we get 0 = 𝑝 βˆ’ π‘ž. We can add that to the first

equation to get 2𝑝 = 1 or 𝑝 =1

2. It follows that π‘ž =

1

2. Hence, π‘Žπ‘› =

1

2(𝑖𝑛 + βˆ’π‘– 𝑛).

Complex Zeros (II)It is always possible to rewrite a formally complex, but real-valued solution solely in terms of real functions using a piecewise definition. The key to doing that lies in the fact that 𝑖4 = 1, which causes the integer powers of i to assume only 4 distinct values:

𝑖0 = 1, 𝑖1= 𝑖, 𝑖2 = βˆ’1, 𝑖3 = βˆ’π‘–, 𝑖4= 1, 𝑖5 = 𝑖, 𝑖6 = βˆ’1, 𝑖7 = βˆ’π‘–, 𝑖8 = 1, etc. More formally:

If n is an integer, then 𝑛 = 4π‘˜ + π‘Ÿ for some integer π‘˜ and π‘Ÿ ∈ {0,1,2,3}. Then 𝑖𝑛 = 𝑖4π‘˜+π‘Ÿ = 𝑖4π‘˜π‘–π‘Ÿ =(𝑖4)π‘˜π‘–π‘Ÿ = 1π‘˜π‘–π‘Ÿ = π‘–π‘Ÿ . Using that π‘Ÿ = 𝑛 mod 4, that tells us that

𝑖𝑛 = 𝑖𝑛 mod 4 =

1 if 𝑛 mod 4 = 0𝑖 if 𝑛 mod 4 = 1βˆ’1 if 𝑛 mod 4 = 2βˆ’π‘– if 𝑛 mod 4 = 3

For example, our previous solution π‘Žπ‘› =1

2(𝑖𝑛 + βˆ’π‘– 𝑛) can be simplified as follows:

π‘Žπ‘› =

1 if 𝑛 mod 4 = 00 if 𝑛 mod 4 = 1βˆ’1 if 𝑛 mod 4 = 20 if 𝑛 mod 4 = 3

which is of course a piecewise description of π‘Žπ‘› that we could have come up with immediately based on the definition of π‘Žπ‘›.

Complex Zeros (III)Let us study an example of a recurrence with complex but not purely imaginary characteristic values:

π‘Žπ‘›+2 = π‘Žπ‘›+1 βˆ’2π‘Žπ‘› with π‘Ž0 = 0 and π‘Ž1 = 1.

The characteristic polynomial is π‘Ÿ2 βˆ’ π‘Ÿ + 2. By applying the quadratic formula, we find the two characteristic values to be

π‘Ÿ1,2 =1 Β± 𝑖 7

2.

Therefore, the general solution of the recurrence is π‘Žπ‘› = 𝑝1+𝑖 7

2

𝑛

+ π‘ž1βˆ’π‘– 7

2

𝑛

where p and q are

complex numbers. Substituting the initial conditions and simplifying, we get

0 = 𝑝 + π‘ž

2 = 𝑝 1 + 𝑖 7 + π‘ž 1 βˆ’ 𝑖 7

The first equation implies π‘ž = βˆ’π‘. Substituting this into the second equation produces

2 = 𝑝 1 + 𝑖 7 βˆ’ 𝑝 1 βˆ’ 𝑖 7 = 𝑝 β‹… 2𝑖 7.

This leads to 𝑝 = βˆ’π‘–

7and π‘ž =

𝑖

7, and to the solution π‘Žπ‘› = βˆ’

𝑖

7

1+𝑖 7

2

𝑛

βˆ’1βˆ’π‘– 7

2

𝑛

.

Observe that this solution is formally complex, even though each π‘Žπ‘› is a real number (in fact, an integer).

Complex Zeros (IV)Since the characteristic roots in our second example are mixed real/imaginary quantities, it is more difficult to make it formally apparent that the solution

π‘Žπ‘› = βˆ’π‘–

2𝑛 71 + 𝑖 7

π‘›βˆ’ 1 βˆ’ 𝑖 7

𝑛

is purely real-valued. We have to use the binomial theorem:

1 + 𝑖 7π‘›βˆ’ 1 βˆ’ 𝑖 7

𝑛=

π‘˜=0

𝑛𝑛

π‘˜π‘–π‘˜ βˆ’ βˆ’π‘– π‘˜ 7

π‘˜

π‘žπ‘˜

To simplify the quantity π‘žπ‘˜, we once again have to make a case distinction here based on the remainder of π‘˜ mod 4. If π‘˜ mod 4 is 0 or 2, then π‘žπ‘˜ = 0 since π‘˜ is even in these cases.

If π‘˜ mod 4 = 1, then π‘žπ‘˜ = 2𝑖 7π‘˜

, and if π‘˜ mod 4 = 3, then π‘žπ‘˜ = βˆ’2𝑖 7π‘˜

. After some

simplification and making the substitution j=2k+1 in the sigma sum, we get the explicitly real representation

π‘Žπ‘› =1

2π‘›βˆ’1

𝑗=0

π‘›βˆ’12

𝑛

2𝑗 + 1βˆ’7 𝑗

which cannot be further simplified (and is not an efficient way of computing π‘Žπ‘›).

Recommended