# High School Mathematics Extensions/Matrices/Linear Recurrence Relations Revisited

Content HSME Matrices Recurrence Relations Problem Set Project Exercises Solutions Problem Set Solutions Definition Sheet Full Version

## *Linear recurrence relations revisited*

We have already discussed linear recurrence relations in the Counting and Generating functions chapter. We shall study it again using matrices. Consider the Fibonacci numbers

1, 1, 2, 3, 5, 8, 13, 21...

where each number is the sum of two preceding numbers. Let xn be the (n + 1)th Fibonacci number, we can write:

${\displaystyle {\begin{matrix}{\begin{pmatrix}x_{n}\\x_{n-1}\end{pmatrix}}&=&{\begin{pmatrix}x_{n-1}+x_{n-2}\\x_{n-1}\end{pmatrix}}\\\\&=&{\begin{pmatrix}1&1\\1&0\end{pmatrix}}{\begin{pmatrix}x_{n-1}\\x_{n-2}\end{pmatrix}}\\\\&=&{\begin{pmatrix}1&1\\1&0\end{pmatrix}}^{2}{\begin{pmatrix}x_{n-2}\\x_{n-3}\end{pmatrix}}\\\\&...\\\\&=&{\begin{pmatrix}1&1\\1&0\end{pmatrix}}^{n-1}{\begin{pmatrix}x_{1}\\x_{0}\end{pmatrix}}\\\\&=&{\begin{pmatrix}1&1\\1&0\end{pmatrix}}^{n-1}{\begin{pmatrix}1\\1\end{pmatrix}}\end{matrix}}}$

In fact many linear recurrence relations can be expressed in matrix form , e.g.

${\displaystyle x_{n}=2x_{n-1}+x_{n-2};\ {\mbox{if n}}\geq 2}$
${\displaystyle x_{1}=1}$
${\displaystyle x_{0}=1}$

can be expressed as

${\displaystyle {\begin{pmatrix}x_{n}\\x_{n-1}\end{pmatrix}}={\begin{pmatrix}2&1\\1&0\end{pmatrix}}{\begin{pmatrix}x_{n-1}\\x_{n-2}\end{pmatrix}}}$

and therefore

${\displaystyle {\begin{pmatrix}x_{n}\\x_{n-1}\end{pmatrix}}={\begin{pmatrix}2&1\\1&0\end{pmatrix}}^{n-1}{\begin{pmatrix}1\\1\end{pmatrix}}}$

So if we knew how to compute the powers of matrices quickly then we can work out the (n + 1)th Fibonacci number rather quickly!

### Computing Powers Quickly

Note that from now on we emphasise if a matrix is a vector by writing an arrow on top of it.

Consider

${\displaystyle A={\begin{pmatrix}1&-2\\1&4\end{pmatrix}}}$
${\displaystyle {\overrightarrow {x}}={\begin{pmatrix}2\\-1\end{pmatrix}}}$
${\displaystyle {\overrightarrow {y}}={\begin{pmatrix}-1\\1\end{pmatrix}}}$

Something interesting happens when you multiply A by either ${\displaystyle {\overrightarrow {x}}}$ or ${\displaystyle {\overrightarrow {y}}}$ (Try it). In fact

${\displaystyle A{\overrightarrow {x}}=2{\overrightarrow {x}}}$

and

${\displaystyle A{\overrightarrow {y}}=3{\overrightarrow {y}}}$.

Generally for a matrix B, if a vector w0 (the matrix with all entries zero) such that

${\displaystyle B{\overrightarrow {w}}=\lambda {\overrightarrow {w}}}$

for some scalar λ, then ${\displaystyle {\overrightarrow {w}}}$ is called a eigenvector of B and λ the eigenvalue of B (corresponding to w).

This is a feature of matrices that be exploited to compute powers easily. Here's how, using A, x and y from above, we write the two pieces of information together in matrix form:

${\displaystyle A{\begin{pmatrix}{\overrightarrow {x}}&{\overrightarrow {y}}\end{pmatrix}}={\begin{pmatrix}{\overrightarrow {x}}&{\overrightarrow {y}}\end{pmatrix}}{\begin{pmatrix}2&0\\0&3\end{pmatrix}}}$

or written completely in numeral form

${\displaystyle {\begin{pmatrix}1&-2\\1&4\end{pmatrix}}{\begin{pmatrix}2&-1\\-1&1\end{pmatrix}}={\begin{pmatrix}2&-1\\-1&1\end{pmatrix}}{\begin{pmatrix}2&0\\0&3\end{pmatrix}}}$

you are encouraged to check the above is correct. What we did was we merged ${\displaystyle {\overrightarrow {x}}}$ and ${\displaystyle {\overrightarrow {y}}}$ into a matrix using each vector as a column, next we multiplied it by the diagonal matrix whose entries are the eigenvalue of each eigenvector correspondingly.

How to now exploit this matrix form to calculate powers of A quickly? We require a simple but ingenius step -- post-multiply (i.e. multiply from the right) both sides by the inverse of

${\displaystyle {\begin{pmatrix}2&-1\\-1&1\end{pmatrix}}}$

we have

${\displaystyle {\begin{pmatrix}1&-2\\1&4\end{pmatrix}}={\begin{pmatrix}2&-1\\-1&1\end{pmatrix}}{\begin{pmatrix}2&0\\0&3\end{pmatrix}}{\begin{pmatrix}2&-1\\-1&1\end{pmatrix}}^{-1}}$

Now to calculate An, we need only to do

${\displaystyle A^{n}={\begin{pmatrix}1&-2\\1&4\end{pmatrix}}^{n}=}$
${\displaystyle {\begin{pmatrix}2&-1\\-1&1\end{pmatrix}}{\begin{pmatrix}2&0\\0&3\end{pmatrix}}{\begin{pmatrix}2&-1\\-1&1\end{pmatrix}}^{-1}...{\begin{pmatrix}2&-1\\-1&1\end{pmatrix}}{\begin{pmatrix}2&0\\0&3\end{pmatrix}}{\begin{pmatrix}2&-1\\-1&1\end{pmatrix}}^{-1}}$

but inverses multiply to give I, so we are left with

${\displaystyle A^{n}={\begin{pmatrix}1&-2\\1&4\end{pmatrix}}^{n}={\begin{pmatrix}2&-1\\-1&1\end{pmatrix}}{\begin{pmatrix}2&0\\0&3\end{pmatrix}}^{n}{\begin{pmatrix}2&-1\\-1&1\end{pmatrix}}^{-1}}$

which is very easy to compute since powers of a diagonal matrix are easy to compute (just take each entry to the power).

#### Example 1

Compute A5 where A is given above.

Solution We do

${\displaystyle A^{5}={\begin{pmatrix}2&-1\\-1&1\end{pmatrix}}{\begin{pmatrix}2&0\\0&3\end{pmatrix}}^{5}{\begin{pmatrix}2&-1\\-1&1\end{pmatrix}}^{-1}}$
${\displaystyle A^{5}={\begin{pmatrix}2&-1\\-1&1\end{pmatrix}}{\begin{pmatrix}2^{5}&0\\0&3^{5}\end{pmatrix}}{\begin{pmatrix}1&1\\1&2\end{pmatrix}}}$
${\displaystyle A^{5}={\begin{pmatrix}2^{6}-3^{5}&2^{6}-2\times 3^{5}\\-2^{5}+3^{5}&-2^{5}+2\times 3^{5}\end{pmatrix}}}$

#### Example 2

Let

${\displaystyle B={\begin{pmatrix}-13&28\\-8&17\end{pmatrix}}}$

and its eigenvectors are

${\displaystyle {\begin{pmatrix}2\\1\end{pmatrix}}}$ and ${\displaystyle {\begin{pmatrix}7\\4\end{pmatrix}}}$

Calculate B5 directly (optional), and again using the method above.

Solution We need to first determine its eigenvalues. We do

${\displaystyle {\begin{pmatrix}-13&28\\-8&17\end{pmatrix}}{\begin{pmatrix}2\\1\end{pmatrix}}={\begin{pmatrix}2\\1\end{pmatrix}}}$

so the eigenvalue corresponding to

${\displaystyle {\begin{pmatrix}2\\1\end{pmatrix}}}$

is 1.

Similarly,

${\displaystyle {\begin{pmatrix}-13&28\\-8&17\end{pmatrix}}{\begin{pmatrix}7\\4\end{pmatrix}}={\begin{pmatrix}21\\12\end{pmatrix}}=3{\begin{pmatrix}7\\4\end{pmatrix}}}$

so the other eigenvalue is 3.

Now we write them in the form:

${\displaystyle {\begin{pmatrix}-13&28\\-8&17\end{pmatrix}}{\begin{pmatrix}2&7\\1&4\end{pmatrix}}={\begin{pmatrix}2&7\\1&4\end{pmatrix}}{\begin{pmatrix}1&0\\0&3\end{pmatrix}}}$

now make B the subject

${\displaystyle {\begin{pmatrix}-13&28\\-8&17\end{pmatrix}}={\begin{pmatrix}2&7\\1&4\end{pmatrix}}{\begin{pmatrix}1&0\\0&3\end{pmatrix}}{\begin{pmatrix}4&-7\\-1&2\end{pmatrix}}}$

Now

${\displaystyle {\begin{pmatrix}-13&28\\-8&17\end{pmatrix}}^{5}={\begin{pmatrix}2&7\\1&4\end{pmatrix}}{\begin{pmatrix}1^{5}&0\\0&3^{5}\end{pmatrix}}{\begin{pmatrix}4&-7\\-1&2\end{pmatrix}}}$
so multiplying the right hand side out, we get

${\displaystyle {\begin{pmatrix}-13&28\\-8&17\end{pmatrix}}^{5}={\begin{pmatrix}8-7\times 3^{5}&14(3^{5}-1)\\4(3^{5}-1)&-7+8\times 3^{5}\end{pmatrix}}}$

#### Summary -- compute powers quickly

Given eigenvectors of a matrix A

1. Compute the eigenvalues (if not given)
2. Write in the form A = PDP-1, where D is a diagonal matrix of the eigenvalues, and P the eigenvectors as columns
3. Compute An using the right hand side equivalent

#### Exercises

1. The eigenvectors of

${\displaystyle B={\begin{pmatrix}-8&6\\-15&11\end{pmatrix}}}$

are

${\displaystyle {\begin{pmatrix}2\\3\end{pmatrix}}}$ and ${\displaystyle {\begin{pmatrix}3\\5\end{pmatrix}}}$

calculate B5

2. The eigenvectors of

${\displaystyle B={\begin{pmatrix}-8&6\\-9&7\end{pmatrix}}}$

are

${\displaystyle {\begin{pmatrix}1\\1\end{pmatrix}}}$ and ${\displaystyle {\begin{pmatrix}2\\3\end{pmatrix}}}$

calculate B5

3. The eigenvectors of

${\displaystyle B={\begin{pmatrix}177&-140\\225&-178\end{pmatrix}}}$

are

${\displaystyle {\begin{pmatrix}4\\5\end{pmatrix}}}$ and ${\displaystyle {\begin{pmatrix}7\\9\end{pmatrix}}}$

calculate B5

### Eigenvector and eigenvalue

We know from the above section that for a matrix if we are given its eigenvectors, we can find the corresponding eigenvalues, and then we can compute its powers quickly. So the last hurdle becomes finding the eigenvectors.

An eigenvectors ${\displaystyle {\overrightarrow {x}}}$ of a matrix A and its corresponding eigenvalue λ are related by the following expression:

${\displaystyle A{\overrightarrow {x}}=\lambda {\overrightarrow {x}}}$

where x ≠ 0 where 0 is the zero matrix (all entries zero). We can safely assume that A is given so there are two unknowns -- ${\displaystyle {\overrightarrow {x}}}$ and λ. We have enough information now to be able to work out the eigenvalues (and from that the eigenvectors):

${\displaystyle A{\overrightarrow {x}}-\lambda {\overrightarrow {x}}=0}$
${\displaystyle A{\overrightarrow {x}}-\lambda I{\overrightarrow {x}}=0}$
${\displaystyle (A-\lambda I){\overrightarrow {x}}=0}$

The matrix (A - λI) must NOT have an inverse, because if it does then ${\displaystyle {\overrightarrow {x}}}$ = 0. Therefore det(A - λI) = 0. Suppose

${\displaystyle A={\begin{pmatrix}a&b\\c&d\end{pmatrix}}}$

then

${\displaystyle A-\lambda I={\begin{pmatrix}a-\lambda &b\\c&d-\lambda \end{pmatrix}}}$
${\displaystyle 0=\det(A-\lambda I)=(a-\lambda )(d-\lambda )-bc}$

Now we see det(A-λI) is a polynomial in λ and det(AI) = 0. We are already well-trained in solving quadratics, so it's easy to work out the values of λ. Once we've worked out the values of λ, we can work out ${\displaystyle {\overrightarrow {x}}}$ (see examples).

#### Example 1

Find the eigenvalues and eigenvectors of

${\displaystyle A={\begin{pmatrix}-4&15\\-2&7\end{pmatrix}}}$

and then find D and P such that A = P-1DP.

Solution

We aim to find ${\displaystyle {\overrightarrow {x}}}$ and λ such that

A${\displaystyle {\overrightarrow {x}}}$ = λ${\displaystyle {\overrightarrow {x}}}$

we proceed

${\displaystyle {\begin{pmatrix}-4&15\\-2&7\end{pmatrix}}{\overrightarrow {x}}=\lambda {\overrightarrow {x}}}$
${\displaystyle {\begin{pmatrix}-4-\lambda &15\\-2&7-\lambda \end{pmatrix}}{\overrightarrow {x}}=0}$ (**)
det(A - λI) =
0 = (-4 - λ)(7 - λ) + 30
0 = -28 - 3λ + λ2 + 30
0 = λ2 - 3λ + 2
0 = (λ - 1)(λ - 2)
λ = 1, 2

Now for each eigenvalue we will get a different corresponding eigenvector. So we consider the case λ = 1 and λ = 2 separately.

Consider first λ = 1, from (**) we get

${\displaystyle {\begin{pmatrix}-4-1&15\\-2&7-1\end{pmatrix}}x=0}$

i.e.

${\displaystyle {\begin{pmatrix}-5&15\\-2&6\end{pmatrix}}{\begin{pmatrix}u\\v\end{pmatrix}}=0}$

where ${\displaystyle x={\begin{pmatrix}u\\v\end{pmatrix}}}$ since det(A - λI) = 0, we know that there is no unique solution to the above equation. But we note that:

${\displaystyle x={\begin{pmatrix}3t\\1t\end{pmatrix}}}$

for any real number t is a solution, and we choose t = 1 as our solution because it's the simpliest. Therefore

${\displaystyle x={\begin{pmatrix}3\\1\end{pmatrix}}}$

is the eigenvector corresponding to λ = 1. (***)

Similarly, if λ = 2, from (**) we get

${\displaystyle {\begin{pmatrix}-4-2&15\\-2&7-2\end{pmatrix}}x=0}$

i.e.

${\displaystyle {\begin{pmatrix}-6&15\\-2&5\end{pmatrix}}{\begin{pmatrix}u\\v\end{pmatrix}}=0}$

where ${\displaystyle x={\begin{pmatrix}u\\v\end{pmatrix}}}$ we note that:

${\displaystyle x={\begin{pmatrix}5t\\2t\end{pmatrix}}}$

for any real number t is a solution, as before we choose t = 1 as our solution. Therefore

${\displaystyle x={\begin{pmatrix}5\\2\end{pmatrix}}}$ is the eigenvector corresponding to λ = 2. (****)

We summarise the result of (***) and (****), we have

${\displaystyle A{\begin{pmatrix}3\\1\end{pmatrix}}={\begin{pmatrix}3\\1\end{pmatrix}}}$
${\displaystyle A{\begin{pmatrix}5\\2\end{pmatrix}}=2{\begin{pmatrix}5\\2\end{pmatrix}}}$

we combine the results into one

${\displaystyle A{\begin{pmatrix}3&5\\1&2\end{pmatrix}}={\begin{pmatrix}3&5\\1&2\end{pmatrix}}{\begin{pmatrix}1&0\\0&2\end{pmatrix}}}$

and so

${\displaystyle A={\begin{pmatrix}3&5\\1&2\end{pmatrix}}{\begin{pmatrix}1&0\\0&2\end{pmatrix}}{\begin{pmatrix}3&5\\1&2\end{pmatrix}}^{-1}}$

#### Example 2

a) Diagonalize A, i.e find P (invertible) and B (diagonal) such that AP = PB
b) Compute A5
${\displaystyle A={\begin{pmatrix}1&2\\-1&4\end{pmatrix}}}$

' Solution a) We are solving Ax = λx, where λ is a constant and x a column vector. Firstly

${\displaystyle Ax-\lambda Ix=0}$
${\displaystyle (A-\lambda I)x=0}$

since x ≠ 0 we have

${\displaystyle det(A-\lambda I)=0}$

i.e.

${\displaystyle \det {\begin{pmatrix}1-\lambda &2\\-1&4-\lambda \end{pmatrix}}=0}$

${\displaystyle {\begin{matrix}(1-\lambda )(4-\lambda )+2&=&0\\\lambda ^{2}-5\lambda +6&=&0\end{matrix}}}$

${\displaystyle \lambda =3,\ 2}$

For λ = 3,

${\displaystyle (A-3I)x=0}$

${\displaystyle {\begin{pmatrix}-2&2\\-1&1\end{pmatrix}}{\begin{pmatrix}x\\y\end{pmatrix}}=0}$

Clearly

${\displaystyle {\begin{pmatrix}x\\y\end{pmatrix}}={\begin{pmatrix}1\\1\end{pmatrix}}}$

is a solution. Note that we do not accept x = 0 as an solution, because we assume x ≠ 0. Note also that

${\displaystyle {\begin{pmatrix}x\\y\end{pmatrix}}={\begin{pmatrix}t\\t\end{pmatrix}}}$

for some constant t is also a solution. Indeed we could use x = y = 2, 3 or 4 as a solution, but for convenience we choose the simplest i.e. x = y = 1.

For λ = 2,

${\displaystyle (A-2I)x=0}$

${\displaystyle {\begin{pmatrix}-1&2\\-1&2\end{pmatrix}}{\begin{pmatrix}x\\y\end{pmatrix}}=0}$

Clearly

${\displaystyle {\begin{pmatrix}x\\y\end{pmatrix}}={\begin{pmatrix}2\\1\end{pmatrix}}}$

is a solution.

Therefore

${\displaystyle A{\begin{pmatrix}1&2\\1&1\end{pmatrix}}={\begin{pmatrix}1&2\\1&1\end{pmatrix}}{\begin{pmatrix}3&0\\0&2\end{pmatrix}}}$

is a solution and

${\displaystyle A{\begin{pmatrix}2&1\\1&1\end{pmatrix}}={\begin{pmatrix}2&1\\1&1\end{pmatrix}}{\begin{pmatrix}2&0\\0&3\end{pmatrix}}}$

is also a solution.

b)
${\displaystyle A^{5}={\begin{pmatrix}{\begin{pmatrix}2&1\\1&1\end{pmatrix}}{\begin{pmatrix}2&0\\0&3\end{pmatrix}}{\begin{pmatrix}2&1\\1&1\end{pmatrix}}^{-1}\end{pmatrix}}^{5}}$

${\displaystyle A^{5}={\begin{pmatrix}2&1\\1&1\end{pmatrix}}{\begin{pmatrix}2&0\\0&3\end{pmatrix}}^{5}{\begin{pmatrix}2&1\\1&1\end{pmatrix}}^{-1}}$

${\displaystyle A^{5}={\begin{pmatrix}2&1\\1&1\end{pmatrix}}{\begin{pmatrix}2^{5}&0\\0&3^{5}\end{pmatrix}}{\begin{pmatrix}1&-1\\-1&2\end{pmatrix}}}$

${\displaystyle A^{5}={\begin{pmatrix}2^{6}-3^{5}&2^{6}-2\times 3^{5}\\2^{5}-3^{5}&-2^{5}+2\times 3^{5}\end{pmatrix}}}$

#### Example 3

Solve the linear recurrence relation

${\displaystyle {\begin{matrix}x_{n}&=&5x_{n-1}&-&6x_{n-2};\ {\mbox{if n}}\geq 2\\x_{1}&=&1\\x_{0}&=&0\\\end{matrix}}}$

Solution

${\displaystyle {\begin{pmatrix}x_{n}\\x_{n-1}\end{pmatrix}}={\begin{pmatrix}5&-6\\1&0\end{pmatrix}}^{n-1}{\begin{pmatrix}1\\0\end{pmatrix}}}$

We need to diagonalize

${\displaystyle A={\begin{pmatrix}5&-6\\1&0\end{pmatrix}}}$

we proceed:

${\displaystyle \det {(A-\lambda I)}=0\!}$

we get

λ = 2, 3

For λ = 2

${\displaystyle (A-2I)x=0\!}$
${\displaystyle x={\begin{pmatrix}2\\1\end{pmatrix}}}$

For λ = 3

${\displaystyle (A-3I)x=0\!}$
${\displaystyle x={\begin{pmatrix}3\\1\end{pmatrix}}}$

Therefore

${\displaystyle A={\begin{pmatrix}2&3\\1&1\end{pmatrix}}{\begin{pmatrix}2&0\\0&3\end{pmatrix}}{\begin{pmatrix}2&3\\1&1\end{pmatrix}}^{-1}}$

Now

${\displaystyle A^{n-1}={\begin{pmatrix}2&3\\1&1\end{pmatrix}}{\begin{pmatrix}2&0\\0&3\end{pmatrix}}^{n-1}{\begin{pmatrix}-1&3\\1&-2\end{pmatrix}}}$
${\displaystyle A^{n-1}={\begin{pmatrix}2&3\\1&1\end{pmatrix}}{\begin{pmatrix}2^{n-1}&0\\0&3^{n-1}\end{pmatrix}}{\begin{pmatrix}-1&3\\1&-2\end{pmatrix}}}$
${\displaystyle A^{n-1}={\begin{pmatrix}-2^{n}+3^{n}&3\times 2^{n}-2\times 3^{n}\\-2^{n-1}+3^{n-1}&3\times 2^{n-1}-2\times 3^{n-1}\end{pmatrix}}}$

Therefore

${\displaystyle {\begin{pmatrix}x_{n}\\x_{n-1}\end{pmatrix}}={\begin{pmatrix}-2^{n}+3^{n}&3\times 2^{n}-2\times 3^{n}\\-2^{n-1}+3^{n-1}&3\times 2^{n-1}-2\times 3^{n-1}\end{pmatrix}}{\begin{pmatrix}1\\0\end{pmatrix}}}$
${\displaystyle {\begin{pmatrix}x_{n}\\x_{n-1}\end{pmatrix}}={\begin{pmatrix}-2^{n}+3^{n}\\-2^{n-1}+3^{n-1}\end{pmatrix}}}$

i.e

${\displaystyle x_{n}=-2^{n}+3^{n}\!}$

### Exercises

1. Compute A5 where

${\displaystyle A={\begin{pmatrix}-12&10\\-21&17\end{pmatrix}}}$

2. Compute A5 where

${\displaystyle A={\begin{pmatrix}-6&28\\-2&9\end{pmatrix}}}$

3. Solve the following recurrence relations

${\displaystyle x_{n}=3x_{n-1}-x_{n-2}\!}$
${\displaystyle x_{1}=1\!}$
${\displaystyle x_{0}=0\!}$

Solutions

1.

${\displaystyle A^{5}={\begin{pmatrix}-2922&2110\\-4431&3197\end{pmatrix}}}$

2.

${\displaystyle A^{5}={\begin{pmatrix}-216&868\\-62&249\end{pmatrix}}}$

...more to come

# Feedback

What do you think? Too easy or too hard? Too much information or not enough? How can we improve? Please let us know by leaving a comment in the discussion tab. Better still, edit it yourself and make it better.