Lecture 40 · Week 10· 23:36

Eigenvalues in action

Matrix powers, Markov chains, linear recurrences.

Play: Lecture 40: Eigenvalues in action
Lecture · 23:36 · Open on YouTube · Report a problem with this video
TranscriptThe full text of the lecture. Click any sentence to play the video from there.

Today: eigenvalues at work

Welcome back. In the last three lectures we found eigenvalues and eigenvectors, and we learned when a matrix can be diagonalised. Today we put all of that to work. First, a recap. Let A be an n by n matrix over a field F. A is diagonalisable exactly when F n has a basis of eigenvectors of A. Then A equals P D P inverse, where the columns of P are those eigenvectors, and D is the diagonal matrix of their eigenvalues, in the same order. Many questions come down to applying the same matrix again and again: bikes moving between stations from day to day, or a sequence in which each term is built from the ones before it. Applying A three times to a vector x is A cubed x, and after k steps, we need A to the power k.

Eigenvalues make these powers easy to compute, and they tell us what happens in the long run. Here is the plan. First, matrix powers, and what they do to a vector. Then Markov chains, which describe random movement between states. And finally, linear recurrences, with the Fibonacci numbers as the highlight.

Powers of a diagonalisable matrix

Powers of a diagonal matrix are easy. To multiply two diagonal matrices, we just multiply their diagonal entries. So D squared has the entries lambda one squared, down to lambda n squared, and D to the k has the entries lambda one to the k, down to lambda n to the k. Here is the theorem. If A equals P D P inverse, with P invertible and D diagonal, then for every k at least zero, A to the k equals P, D to the k, P inverse. For the proof, write A to the k as k copies of P D P inverse, side by side. Between neighbouring copies, P inverse meets P, and P inverse times P is the identity.

So all the inner pairs drop out. Only the first P, the k copies of D, and the last P inverse remain, and the copies of D pack into D to the k. For k equal to zero, both sides are the identity. Let us use it. Take the matrix A with rows four, one, and two, three. Its characteristic polynomial is four minus t, times three minus t, minus two. That is t squared minus seven t plus ten, which factors as t minus five, times t minus two. So the eigenvalues are five and two. For lambda equal to five, A minus five I has rows minus one, one, and two, minus two, and it sends the vector (one, one), to zero. For lambda equal to two, A minus two I has rows two, one, and two, one, and it sends the vector (one, minus two), to zero. These are our eigenvectors, v one and v two.

So the first column of P is v one, the second column is v two, and D is the diagonal matrix with entries five and two, in the same order. The determinant of P is one times minus two, minus one times one, which is minus three. By the formula for two by two inverses, we swap the diagonal entries, change the signs of the other two, and divide by minus three. So P inverse is one third of the matrix with rows two, one, and one, minus one. Now multiply. P times D to the k multiplies the first column of P by five to the k, and the second column by two to the k.

Then we multiply by P inverse, row by column. The first row of the result is two times five to the k plus two to the k, and five to the k minus two to the k. The second row is two times five to the k minus two times two to the k, and five to the k plus two times two to the k. All of this is divided by three. So we have one formula for every power of A at once. Check it with k equal to one. We get one third of the rows twelve, three, and six, nine. That is four, one, and two, three, the matrix A itself. With k equal to two, we get eighteen, seven, and fourteen, eleven. And A times A, multiplied out directly, gives the same matrix.

Now every power costs the same small amount of work. For example, A to the tenth has entries in the millions, and the formula gives them at once.

What powers do to a vector

There is a second way to see powers, without P inverse at all. If v is an eigenvector of A with eigenvalue lambda, then A v is lambda v. Applying A again, A squared v is lambda times A v, which is lambda squared v. In general, A to the k v is lambda to the k v. Now let v one up to v n be a basis of eigenvectors, with eigenvalues lambda one up to lambda n, and write any vector x as c one v one, plus up to c n v n. By linearity, A to the k x is c one lambda one to the k v one, plus up to c n lambda n to the k v n. So in a basis of eigenvectors, each coordinate is simply multiplied by its own eigenvalue at every step. The matrix acts as n separate scalings, one along each eigenvector.

Back to our example, with x zero equal to the vector (one, zero). We write it as c one v one plus c two v two. The second entries give c one minus two c two equals zero, and the first entries give c one plus c two equals one. So c two is one third, and c one is two thirds. So A to the k x zero is two thirds of five to the k v one, plus one third of two to the k v two. This is the first column of the formula for A to the k that we found before. The first part grows like five to the k, the second only like two to the k. So for large k the first part takes over, and A to the k x zero points more and more along v one.

Here is the picture. To keep the vectors on the screen, we divide by five to the k. That leaves two thirds of v one, plus one third of two fifths to the k, times v two. Let us draw it one term at a time. Start with v one, and take two thirds of it. This part does not depend on k. Next, v two, and take one third of it: that is the second term when k is zero. To add the two terms, move the v two part to the tip of the v one part. Its tip is the point for k equal to zero. Now let k grow. The v one part stays fixed, while the v two part shrinks by the factor two fifths at every step. Watch the points. As k gets larger and larger, two fifths to the k goes to zero, so the v two part fades away, and the points close in on the tip of two thirds of v one. In the long run, only the direction of v one is left. This is the general lesson. When one eigenvalue is larger in absolute value than all the others, and x zero has a component along its eigenvector, then in the long run that eigenvalue takes over, and its eigenvector gives the direction.

Markov chains

Now a question about random movement. A city runs a bike sharing scheme with two stations, North and South, and every bike ends each day at one of them. Of the bikes that start a day at North, ninety percent end it at North, and ten percent at South. Of the bikes that start at South, eighty percent stay there, and twenty percent move to North. Let x sub k hold the fractions of the bikes at North and at South after k days. At the end of the next day, the fraction at North is zero point nine of the North fraction, plus zero point two of the South fraction. The fraction at South is zero point one of the North fraction, plus zero point eight of the South fraction.

In matrix form, x sub k plus one equals M x sub k. The first column of M is zero point nine, zero point one, and the second is zero point two, zero point eight. Each column says where the bikes from one station go, so its entries are at least zero, and they add up to one. This is the general setting. A Markov matrix is a square real matrix whose entries are all at least zero, and whose columns each add up to one. A probability vector is a vector whose entries are at least zero and add up to one. A Markov chain is a sequence of probability vectors x zero, x one, x two, and so on, with x sub k plus one equal to M x sub k. And a steady state is a probability vector s with M s equal to s.

Say all the bikes start at South, so x zero is the vector (zero, one). After one day, x one is M x zero, which is the second column of M, zero point two, zero point eight. After two days, x two is M x one. In the first entry, zero point nine times zero point two, plus zero point two times zero point eight, is zero point three four. In the second, zero point one times zero point two, plus zero point eight times zero point eight, is zero point six six. So after two days, thirty four percent of the bikes are at North. The numbers keep changing, but they settle down. Where do they settle, and why? Two facts hold for every Markov matrix.

Theorem. Let M be an n by n Markov matrix. First, if x is a probability vector, then so is M x. Second, one is an eigenvalue of M. For the first part: each entry of M x is a sum of products of numbers that are at least zero, so it is at least zero. To add up all the entries of M x, collect the terms that contain x j. Together they give x j times the sum of column j of M, which is x j. So the total is x one plus up to x n, which is one. For the second part, look at rows instead of columns. Since every column of M adds up to one, M transpose times the vector of all ones is again the vector of all ones. So M transpose minus I sends that vector to zero, is not invertible, and has determinant zero.

A matrix and its transpose have the same determinant, and M minus I is the transpose of M transpose minus I. So M minus I has determinant zero too, and one is an eigenvalue of M. The same trick bounds every other eigenvalue. If lambda is a real eigenvalue of M, it is also an eigenvalue of M transpose, with an eigenvector y. Pick the entry y i that is largest in absolute value. Entry i of M transpose y is a sum of the entries of y, weighted by column i of M. These weights are at least zero and add up to one, so the absolute value of the sum is at most the absolute value of y i. So the absolute value of lambda times y i is at most the absolute value of y i. Dividing by it, the absolute value of lambda is at most one.

These two facts are what all this work was for. Every Markov matrix has the eigenvalue one, and no real eigenvalue is larger than one in absolute value. Keep them in mind: in a moment, they will tell us where a chain ends up.

Two-state chains settle down

For two states we can say exactly what happens. Every two by two Markov matrix has the first column one minus p, p, and the second column q, one minus q. Here p is the fraction that leaves the first state at each step, and q is the fraction that leaves the second. Theorem. Let p and q be numbers between zero and one, with p plus q strictly between zero and two. Then M has the eigenvalues one and one minus p minus q, with the eigenvectors (q, p), and (one, minus one). Its only steady state is s, equal to one over p plus q, times the vector (q, p). And every Markov chain with this matrix approaches the steady state, as k goes to infinity, wherever it starts.

The proof uses everything we have done today, so take it slowly. First, the eigenvectors. Earlier we proved that every Markov matrix has the eigenvalue one, so we already know what to look for: a vector that M leaves unchanged. In the first entry of M times the vector (q, p), one minus p times q, plus q times p, is q. In the second entry, p times q, plus one minus q times p, is p. So we get q, p again, with the eigenvalue one, as promised. In the same way, M times the vector (one, minus one), is the vector (one minus p minus q, p minus one plus q), which is one minus p minus q, times the vector (one, minus one). Since p plus q is not zero, the two eigenvalues are different, so these two eigenvectors form a basis of R two. Write x zero as b times the vector (q, p), plus c times the vector (one, minus one).

Now add up the entries on both sides. On the left we get one, since x zero is a probability vector. On the right, the entries of the vector (one, minus one), add up to zero, so we get b times p plus q. So b is one over p plus q, whatever x zero is, and the first part is exactly s. Earlier we saw that each power of M simply multiplies each eigenvector by its eigenvalue. So x sub k, which is M to the k x zero, equals s, plus c times one minus p minus q to the k, times the vector (one, minus one). Finally, the second eigenvalue. Here the bound we proved earlier, which may have looked like a technical detail at the time, becomes our tool. One minus p minus q is a real eigenvalue of a Markov matrix, so it lies between minus one and one. It equals one only when p plus q is zero, and minus one only when p plus q is two, and we excluded both cases at the start. So it is strictly between minus one and one. As k gets larger and larger, its powers go to zero, the second term fades away, and x sub k tends to the vector s. And a steady state is a chain that never moves, so it must be s itself.

Back to the bikes. Here p is zero point one and q is zero point two. The second eigenvalue is one minus zero point three, which is zero point seven. The steady state is one over zero point three, times the vector (zero point two, zero point one), which is the vector (two thirds, one third). Starting with all the bikes at South, the first entry of x zero gives c equal to zero minus two thirds, which is minus two thirds. So x sub k is s, minus two thirds times zero point seven to the k, times the vector (one, minus one). For k equal to two, this gives zero point three four and zero point six six, just as we computed step by step. Here is the fraction at North, day by day, starting with all the bikes at South, and starting with all of them at North. Now let the days go by, with k larger and larger, and watch where the two curves go.

Both close in on the same value: in the long run, two thirds of the bikes are at North, wherever they started. The difference from the steady state shrinks by thirty percent every day: the second eigenvalue sets the speed. The two excluded cases are easy to picture. When p plus q is zero, M is the identity, and nothing ever moves. When p plus q is two, M swaps the two states at every step, and a chain that starts at North flips back and forth forever.

Try it yourself

You can try this yourself, on this lecture's page at Open Semester dot com. Here p and q are the fractions of bikes that leave North and South each day, and the plot is the one we just drew: the share of bikes at North, day by day, starting with all of them at North, and with all of them at South. With p equal to zero point one and q equal to zero point two, we get our bikes again: both curves settle at two thirds, just as in our plot. Now switch the plot to South. From the same two starts, the share at South settles at one third, the other entry of the steady state.

Next, raise both p and q. With p equal to zero point five and q equal to zero point four, the second eigenvalue is zero point one, and the chain settles almost at once. And when p and q are both close to one, the second eigenvalue is negative. The share jumps from one side of the steady state to the other, while the gap still shrinks. Try your own values, and watch the second eigenvalue set the speed.

Linear recurrences

Our last application is to sequences. Take the rule: a sub k plus two equals a sub k plus one, plus two a sub k, starting from zero and three. Each term is the previous one plus twice the one before it: zero, three, three, nine, fifteen, thirty three, and so on. Is there a formula for a sub k, without computing all the terms before it? The trick is to keep two neighbouring terms together in one vector, u sub k, with the entries a sub k plus one and a sub k. Then u sub k plus one has two entries. The first is a sub k plus two, which is a sub k plus one, plus two a sub k. The second is a sub k plus one. Written in full, the second entry is one a sub k plus one, plus zero a sub k.

So u sub k plus one equals C u sub k, where C has rows one, two, and one, zero. This is the companion matrix of the recurrence. Hence u sub k is C to the k u zero, and we know how to compute powers. The characteristic polynomial of C is one minus t, times minus t, minus two. That is t squared minus t minus two, which factors as t minus two, times t plus one. So the eigenvalues are two and minus one. Look at this polynomial: t squared minus t minus two. It is the recurrence itself, with a sub k plus two replaced by t squared, a sub k plus one by t, and a sub k by one. We call it the polynomial of the recurrence.

The eigenvectors are (two, one), for two, and (minus one, one), for minus one. Write u zero, which is (three, zero), as b times the vector (two, one), plus c times the vector (minus one, one). The second entries give b plus c equals zero, and the first entries give two b minus c equals three. So b is one, and c is minus one. So u sub k is two to the k times the vector (two, one), minus, minus one to the k times the vector (minus one, one). Its second entry is a sub k, so a sub k equals two to the k, minus, minus one to the k. Check: for k equal to four, sixteen minus one is fifteen. The same argument works for every recurrence of this kind. Theorem: let a sub k plus two equal alpha a sub k plus one, plus beta a sub k, and suppose that t squared minus alpha t minus beta has two different roots, lambda one and lambda two, in the field.

Then the solutions are exactly the sequences a sub k equals b lambda one to the k, plus c lambda two to the k, and the numbers b and c are fixed by a zero and a one. The proof is the one we just did. Now C has rows alpha, beta, and one, zero. For a root lambda, C times the vector (lambda, one), is the vector (alpha lambda plus beta, lambda), and alpha lambda plus beta is lambda squared, because lambda is a root. So the vector (lambda, one), is an eigenvector of C, with eigenvalue lambda. Two different eigenvalues give a basis of eigenvectors. Writing u zero as b times the vector (lambda one, one), plus c times the vector (lambda two, one), the powers give u sub k, and its second entry is b lambda one to the k, plus c lambda two to the k.

And each sequence lambda to the k, for a root lambda, satisfies the recurrence, so every such combination is a solution. The same holds for recurrences of any order n, with n distinct roots; the book has the details.

The Fibonacci numbers

Now the most famous recurrence of all: the Fibonacci numbers. They start with zero and one, and each term is the sum of the two before it: zero, one, one, two, three, five, eight, thirteen, and so on. Here alpha and beta are both one, so the polynomial is t squared minus t minus one. By the quadratic formula, its roots are phi, equal to one plus root five, over two, and psi, equal to one minus root five, over two. The root phi is about one point six one eight, and psi is about minus zero point six one eight. By the theorem on recurrences that we just proved, F sub k equals b phi to the k, plus c psi to the k. From F zero equal to zero, b plus c is zero. From F one equal to one, b phi plus c psi is one, so b times phi minus psi is one. Since phi minus psi is root five, b is one over root five, and c is minus one over root five.

This gives Binet's formula: F sub k equals phi to the k minus psi to the k, all over root five. Every term is a whole number, even though the formula is full of square roots. Check it with k equal to two. Phi squared minus psi squared is phi plus psi, times phi minus psi, which is one times root five. Divided by root five, that is one, and indeed F two is one. And now the long run: what happens as k gets larger and larger? Psi is less than one in absolute value, so psi to the k shrinks to zero, and F sub k is very close to phi to the k over root five. In fact, it is the nearest whole number. For example, phi to the tenth over root five is about fifty five point zero zero four, and F ten is fifty five.

And as k grows, the ratio of neighbouring Fibonacci numbers tends to phi, the golden ratio. Just as with the matrix powers, the eigenvalue of largest absolute value takes over. To sum up. Powers of P D P inverse are P D to the k P inverse, and in a basis of eigenvectors each coordinate is scaled by its own eigenvalue. A Markov matrix always has the eigenvalue one, and a two state chain settles to its steady state at a speed set by the second eigenvalue. And a linear recurrence becomes a matrix power, with the roots of its polynomial as eigenvalues.

Before the next lecture, read section eight point four of the course book, try the problems on sheet ten about powers, Markov chains and recurrences, and do the lecture check on this lecture's page at Open Semester dot com. Next time, we meet matrices whose eigenvalues are not real at all, such as rotations, and we learn to work with them over the complex numbers. See you there.

Try it

Bike stations settle down

Try
Plot

p is the fraction of North bikes that move to South each day, q the fraction of South bikes that move to North. The plot shows the share of bikes at North (or, with Plot, at South), starting with all of them at North and with all of them at South. The dashed line is the steady state; the gap to it is multiplied by 1 − p − q every day.

Check yourself

3 questions, from warm-up to stretch

Work each one out on paper, type your answer and press Check. Stuck? Open a hint; the worked solution is there when you need it.

  1. Question 1 of 3 Warm-up

    Let . Diagonalise and use Theorem 8.4.1 to find the entry of in row , column , and the same entry of .

    Hint 1 of 2

    is triangular, so its eigenvalues are and . Find an eigenvector for each, put them as the columns of , and use with .

    Hint 2 of 2

    sends to , and sends to . So .

    Worked solution
    1. is upper triangular, so its eigenvalues are its diagonal entries and . sends to , and sends to .
    2. So with and . Here , so .
    3. By Theorem 8.4.1, . ( multiplies the first column of by and the second by .)
    4. So and .
    5. Check: gives , and multiplying out, and .
  2. Question 2 of 3 Core

    Two rooms of a museum: each minute, of the visitors in room 1 move to room 2, and of those in room 2 move to room 1; the others stay. So with . Find the first entry of the steady state and the second eigenvalue of . If all visitors start in room 1, , what fraction is in room 1 after minutes?

    Hint 1 of 2

    Read off and from the columns and , then use Theorem 8.4.10: the eigenvalues are and , , and .

    Hint 2 of 2

    Here and , so . The first entry of gives .

    Worked solution
    1. The columns of are and , so and , with (Theorem 8.4.10).
    2. The eigenvalues are and , and the steady state is . Check: .
    3. Write . The first entry gives , so , and .
    4. For : the first entry is .
    5. Check step by step: , , .
  3. Question 3 of 3 Stretch

    The sequence satisfies with and . By Theorem 8.4.14, . Find and , and then .

    Hint 1 of 2

    The polynomial of the recurrence is ; check that its roots are and . Then and come from the first two terms: put and into .

    Hint 2 of 2

    gives , and gives .

    Worked solution
    1. The polynomial of the recurrence is , with the distinct roots and . So by Theorem 8.4.14, .
    2. : . : . Substituting : , so , and .
    3. So , and .
    4. Check with the recurrence: , , , , .

Found a mistake, or something not working on this page? Report it and we'll fix it. See what we've corrected.