Scientia sine finibus

Linear Algebra / Unit 5, Eigenvalues and Eigenvectors / Topic 5.4

Units and Topics

Unit 5. Eigenvalues and Eigenvectors

5.4 Powers of a Matrix and Markov Chains

This topic studies what happens when the same map is applied many times. The eigenvalues decide whether the result grows, dies away, or settles at a steady state. The main application is the Markov chain, which describes a system that moves between states with fixed probabilities.

You need Topics 5.1 and 5.3 for this topic.

1. Repeated Steps

Many processes change in steps, and each step is the same linear map. If x₀ is the state at the start and A is the matrix of one step, then

x₁ = Ax₀ x₂ = Ax₁ = A²x₀ xk = Akx₀

The question is what xk looks like when k is large. Multiplying by A again and again answers it slowly. The eigenvalues answer it at once.

2. The Solution with Eigenvectors

Suppose that A is diagonalizable, with the eigenvectors v₁, …, vₙ and the eigenvalues λ₁, …, λₙ. Write the starting vector as a combination of the eigenvectors, x₀ = c₁v₁ + … + cₙvₙ. Each step multiplies each term by its eigenvalue, so after k steps

xk = c₁λ₁kv₁ + c₂λ₂kv₂ + … + cₙλₙkvₙ

This is the same statement as Ak = PDkP⁻¹ from Topic 5.3. The size of each eigenvalue decides what its term does.

EigenvalueIts term after many steps
Size greater than 1Grows without limit
λ = 1Stays the same
λ = −1Changes sign at each step and keeps its size
Size less than 1Dies away

After many steps, the term with the largest eigenvalue is much larger than the others. The vector xk then points along that eigenvector, and each further step multiplies it by that eigenvalue.

3. The Fibonacci Numbers

The Fibonacci numbers are 0, 1, 1, 2, 3, 5, 8, 13, 21, and so on. Each number is the sum of the two numbers before it: Fk+2 = Fk+1 + Fk. This rule is one step of a linear map, if the state holds two neighboring numbers.

Fk+2Fk+1 = 1110 Fk+1Fk

The matrix has the trace 1 and the determinant −1, so its characteristic equation is λ² − λ − 1 = 0.

λ₁ = (1 + √5)/2 ≈ 1.618 λ₂ = (1 − √5)/2 ≈ −0.618

The second eigenvalue has a size less than 1, so its term dies away. For large k, each Fibonacci number is about 1.618 times the number before it. The number 1.618 is called the golden ratio. For example, 21 / 13 ≈ 1.615.

4. Markov Chains

A Markov chain describes a system that is in one of several states and moves between them in steps. The probability of each move depends only on the present state.

For example, the people of a region live either in the city or in the suburbs. Each year, 10 percent of the people in the city move to the suburbs, and 20 percent of the people in the suburbs move to the city. Let the vector x hold the fraction of the people in the city and the fraction in the suburbs. One year is the map

xk+1 = Axk with A = 0.90.20.10.8

The first column says where the people of the city go: 0.9 stay and 0.1 move. The second column says where the people of the suburbs go: 0.2 move and 0.8 stay.

A matrix like this is called a Markov matrix, or a stochastic matrix. It has two properties.

  • No entry is negative.
  • The entries of each column add to 1, because the people who start in one place must all go somewhere.

Start with all of the people in the city, x₀ = (1, 0).

Year01231030
City10.90.830.7810.6760.667
Suburbs00.10.170.2190.3240.333

The fractions settle at 2/3 and 1/3.

5. The Steady State

The eigenvalues explain the table. The trace of A is 1.7 and the determinant is 0.7, so the eigenvalues are 1 and 0.7.

  • For λ = 1, the system (A − I)v = 0 gives −0.1x + 0.2y = 0, so v₁ = (2, 1).
  • For λ = 0.7, the system (A − 0.7I)v = 0 gives 0.2x + 0.2y = 0, so v₂ = (1, −1).

The starting vector is (1, 0) = (1/3)(2, 1) + (1/3)(1, −1). So

xk = 1/3 21 + (1/3)(0.7)k 1−1

The second term dies away, because 0.7k goes to 0. The first term does not change. It is the steady state, (2/3, 1/3). A steady state is a vector that one step leaves unchanged, Ax = x. It is an eigenvector with the eigenvalue 1, scaled so that its components add to 1.

The steady state does not depend on the starting vector. A different start changes only the coefficient of the term that dies away.

Try it: a Markov chain with two states

Move the sliders to set the fraction that leaves each state in one step and the fraction that starts in state 1. The blue curve is the fraction in state 1, and the red curve is the fraction in state 2. The dashed lines show the steady state.

6. Facts About Markov Matrices

  • A Markov matrix always has the eigenvalue 1. Each column of A − I adds to 0, so the rows of A − I add to the zero row. The rows are dependent, and the determinant of A − I is 0.
  • No eigenvalue of a Markov matrix has a size greater than 1. The fractions cannot grow, because they always add to 1.
  • If all of the entries of A are positive, then the eigenvalue 1 is not repeated, all of the other eigenvalues have a size less than 1, and the chain reaches the same steady state from any start.
  • If some entries are 0, the chain may not settle. The matrix with the rows 0, 1 and 1, 0 exchanges the two states at each step. Its eigenvalues are 1 and −1.

To find a steady state directly, solve (A − I)x = 0 and divide the solution by the sum of its components.

Markov chains are used wherever a system moves between states at random with fixed probabilities. One large example is the ranking of web pages by a search engine: a reader who follows links at random is a Markov chain, and the steady state gives the fraction of the time spent on each page. In physics, a chain of radioactive decays and the random walk of a molecule are Markov chains.

Common Mistakes

  • Writing the probabilities in the rows. In this course, each column holds the probabilities of leaving one state, so each column adds to 1.
  • Scaling the steady state to length 1. Its components must add to 1, because they are fractions of a whole.
  • Expecting the steady state to depend on the start. When all entries are positive, it does not.
  • Deciding growth or decay from the sign of an eigenvalue. The size of the eigenvalue decides, and the eigenvalue −2 gives growth.
  • Calculating a high power by repeated multiplication on paper. Use the eigenvalues.

Summary

FactStatement
After k stepsxk = c₁λ₁kv₁ + … + cₙλₙkvₙ
Long-run behaviorThe term with the largest eigenvalue dominates
Markov matrixNo negative entries, and each column adds to 1
Steady stateThe eigenvector with the eigenvalue 1, scaled so that its components add to 1
Speed of approachSet by the size of the second eigenvalue

Practice

Work each problem on paper first. Then open the answer to check your work.

1. A has the eigenvalues 0.5 and 1.2. Describe xk = Akx₀ for large k.

The term with 0.5k dies away. The term with 1.2k grows without limit.

For large k, xk points along the eigenvector of 1.2, unless the starting vector had no part along it.

2. Is 0.60.30.40.7 a Markov matrix? Find its eigenvalues.

Yes. No entry is negative, and the columns add to 1.

One eigenvalue is 1. The trace is 1.3, so the other eigenvalue is 0.3.

3. Find the steady state of the matrix in Problem 2.

−0.4x + 0.3y = 0from (A − I)x = 0x = (3, 4)one solution, an eigenvector3 + 4 = 7the sum of the componentssteady state = (3/7, 4/7)divide by the sum

4. Each day, a machine that works has a probability of 0.1 of breaking, and a broken machine has a probability of 0.6 of being repaired. Write the Markov matrix, with the working state first, and find the fraction of days on which the machine works in the long run.

A = 0.90.60.10.4.

−0.1x + 0.6y = 0from (A − I)x = 0x = (6, 1)one solution, an eigenvectorsteady state = (6/7, 1/7)divide by the sum 7

The machine works on 6/7 of the days, which is about 86 percent.

5. For the city and suburbs example, how many years pass before the term that dies away is less than 1 percent of its starting size?

The term is multiplied by 0.7 each year.

0.7¹² ≈ 0.0140.7¹³ ≈ 0.0097

It takes 13 years.

6. Use the matrix of Part 3 to explain why the ratio of neighboring Fibonacci numbers approaches 1.618.

After many steps, the state vector points along the eigenvector of the largest eigenvalue, 1.618.

Each further step multiplies the vector by 1.618, so each Fibonacci number is about 1.618 times the one before it.

Python Practice

Step 1. Take one step

The code below stores the Markov matrix of Part 4 and the starting vector (1, 0), and takes one step. The @ sign multiplies a matrix by a vector.

Python

The result is [0.9 0.1], the fractions after one year.

Step 2. Repeat a step

A line that starts with for tells Python to repeat the lines that follow it. The line for k in range(5): repeats them 5 times. Python repeats only the lines that are indented, which means that they start with four spaces. The colon at the end of the for line is required.

In the code below, each repeat replaces x by Ax and prints the new vector.

Python

The five results are the fractions after 1, 2, 3, 4, and 5 years. The first three agree with the table in Part 4.

In the next box, the print line is not indented, so it is not repeated. It runs once, after all of the steps. Change the number of steps from 5 to 50.

Python

Step 3. Use a power of the matrix

The instruction np.linalg.matrix_power calculates a power of a matrix. The code below prints A⁵⁰.

Python

Both columns are very close to (2/3, 1/3). The product of this matrix with any starting vector whose components add to 1 is the steady state, so the start does not matter.

Step 4. Find the steady state from an eigenvector

From Topic 5.1, np.linalg.eig gives the eigenvalues and a matrix whose columns are eigenvectors. The instruction np.argmax gives the position of the largest number in a list. For a Markov matrix the largest eigenvalue is 1, so this finds the column of the steady state. The last line divides the eigenvector by the sum of its components.

Python

The eigenvalues are 1 and 0.7, and the steady state is (2/3, 1/3).

Now change the matrix. Each year, 30 percent of the people in the city move to the suburbs, and 10 percent of the people in the suburbs move to the city. Each column must add to 1.

Python

Step 5. Calculate Fibonacci numbers

The powers of the matrix in Part 3 contain the Fibonacci numbers. The entry in row 1 and column 2 of the power k is the number F with the index k. Python counts from 0, so that entry is written [0, 1].

Python

The power 10 has the rows 89, 55 and 55, 34, and the Fibonacci number with the index 10 is 55.

Now find the Fibonacci number with the index 20.

Python

Step 6. The golden ratio

The code below prints the eigenvalues of the Fibonacci matrix and the ratio of two neighboring Fibonacci numbers.

Python

The eigenvalues are about 1.618 and −0.618. The ratio of the Fibonacci numbers with the indexes 21 and 20 is 1.618034, which agrees with the larger eigenvalue to six decimal places.

Quiz

This quiz has 5 questions on this topic. A question asks you either to choose one answer or to type numbers. The page grades your answers and explains each one. A number can be typed as a whole number, a decimal, a fraction such as 1/3, or a calculation such as sqrt(18)/2 or arccos(1/2). The page shows the value of a calculation next to the box. Angles in a calculation are in degrees. The Calculator button under each question opens a calculator. Your answers are saved in your browser, so they are still on the page when you come back to it.

Choose how your answers are checked

1. Which of these matrices is a Markov matrix?

2. Find the steady state of the Markov matrix 0.70.40.30.6. Its components add to 1. You can type fractions.

3. One eigenvalue of 0.70.40.30.6 is 1. Find the other eigenvalue.

4. A matrix A has the eigenvalues 1.5 and 0.2. The starting vector x₀ has a part along each eigenvector. What happens to xk = Akx₀ when k is large?

5. Let A = 0.80.30.20.7 and x₀ = (1, 0). Calculate x₂ = A²x₀.

Next: Topic 5.5, Systems of Differential Equations and the Matrix Exponential