Skip to main content
© 2026 ePowerAI. All rights reserved.
CoursesContact
eAI
CoursesContact
Week 10: Diagonalization and Markov Matrices
Linear Algebra
01Week 1: Vectors and Linear Combinations
02Week 2: Linear Transformations and Matrices
03Week 3: Elimination and LU Factorization
04Week 4: Determinants
05Week 5: Vector Spaces, Independence, and Basis
06Week 6: The Four Fundamental Subspaces
07Week 7: Orthogonality and Projections
08Week 8: Least Squares and QR
09Week 9: Eigenvalues and Eigenvectors
10Week 10: Diagonalization and Markov Matrices
11Week 11: Differential Equations
12Week 12: Symmetric and Positive Definite Matrices
13Week 13: The SVD and Complex Matrices
14Week 14: The Fourier Matrix, FFT, and PCA
Week 10· Linear Algebra20 min read

Week 10: Diagonalization and Markov Matrices

✦Learning Outcomes
  • Diagonalize a matrix as A=SΛS−1A = S\Lambda S^{-1}A=SΛS−1 when possible
  • Use diagonalization to compute matrix powers AkA^kAk efficiently
  • Explain the structure of a Markov matrix and find its steady-state vector
  • Determine the long-run behavior of a Markov chain from its eigenvalues
◆Prerequisites

Background knowledge assumed:

  • Eigenvalues and eigenvectors

Recommended: Review Week 9: Eigenvalues and Eigenvectors before starting.

Diagonalization#

Week 9 produced eigenvalues λ\lambdaλ and eigenvectors vvv from Av=λvAv = \lambda vAv=λv. This week assembles those pieces into a factorization of AAA itself.

Suppose AAA is n×nn \times nn×n and has nnn linearly independent eigenvectors v1,…,vnv_1, \ldots, v_nv1​,…,vn​ with eigenvalues λ1,…,λn\lambda_1, \ldots, \lambda_nλ1​,…,λn​. Form the matrix SSS whose columns are those eigenvectors, and the diagonal matrix Λ\LambdaΛ of the matching eigenvalues:

S=(∣∣v1⋯vn∣∣),Λ=(λ1⋱λn).S = \begin{pmatrix} | & & | \\ v_1 & \cdots & v_n \\ | & & | \end{pmatrix}, \qquad \Lambda = \begin{pmatrix} \lambda_1 & & \\ & \ddots & \\ & & \lambda_n \end{pmatrix}.S=​∣v1​∣​⋯​∣vn​∣​​,Λ=​λ1​​⋱​λn​​​.

The eigen-equations Avj=λjvjA v_j = \lambda_j v_jAvj​=λj​vj​ stack column by column into a single matrix identity:

AS=SΛ.AS = S\Lambda.AS=SΛ.

Because the columns of SSS are independent, SSS is invertible. Multiply on the right by S−1S^{-1}S−1:

A=SΛS−1.A = S\Lambda S^{-1}.A=SΛS−1.

This is the diagonalization (or eigen-decomposition) of AAA. In the eigenbasis, AAA acts as pure scaling: Λ\LambdaΛ stretches each coordinate axis by its own λj\lambda_jλj​, and SSS / S−1S^{-1}S−1 change coordinates into and out of that basis.

Worked example. Continue with

A=(4123)A = \begin{pmatrix} 4 & 1 \\ 2 & 3 \end{pmatrix}A=(42​13​)

from Week 9. Eigenvalues were λ1=5\lambda_1 = 5λ1​=5, λ2=2\lambda_2 = 2λ2​=2 with eigenvectors v1=(1,1)⊤v_1 = (1,1)^\topv1​=(1,1)⊤ and v2=(1,−2)⊤v_2 = (1,-2)^\topv2​=(1,−2)⊤. So

S=(111−2),Λ=(5002).S = \begin{pmatrix} 1 & 1 \\ 1 & -2 \end{pmatrix}, \qquad \Lambda = \begin{pmatrix} 5 & 0 \\ 0 & 2 \end{pmatrix}.S=(11​1−2​),Λ=(50​02​).

Then det⁡(S)=−2−1=−3≠0\det(S) = -2 - 1 = -3 \neq 0det(S)=−2−1=−3=0, so SSS is invertible. You can check AS=SΛAS = S\LambdaAS=SΛ by multiplying both sides, or reconstruct A=SΛS−1A = S\Lambda S^{-1}A=SΛS−1 with

S−1=−13(−2−1−11)=13(211−1).S^{-1} = -\frac{1}{3}\begin{pmatrix} -2 & -1 \\ -1 & 1 \end{pmatrix} = \frac{1}{3}\begin{pmatrix} 2 & 1 \\ 1 & -1 \end{pmatrix}.S−1=−31​(−2−1​−11​)=31​(21​1−1​).

When diagonalization fails. Not every matrix has nnn independent eigenvectors. Week 9's defective example

J=(1101)J = \begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix}J=(10​11​)

has a repeated eigenvalue λ=1\lambda = 1λ=1 of algebraic multiplicity 222, but only a one-dimensional eigenspace. You cannot form an invertible SSS of eigenvectors, so JJJ is not diagonalizable. The precise criterion:

A is diagonalizable  ⟺  A has n linearly independent eigenvectors  ⟺  for every eigenvalue, geometric multiplicity = algebraic multiplicity.A \text{ is diagonalizable} \iff A \text{ has } n \text{ linearly independent eigenvectors} \iff \text{for every eigenvalue, geometric multiplicity = algebraic multiplicity}.A is diagonalizable⟺A has n linearly independent eigenvectors⟺for every eigenvalue, geometric multiplicity = algebraic multiplicity.

Distinct eigenvalues always give independent eigenvectors, so a matrix with nnn different eigenvalues is always diagonalizable. A repeated eigenvalue is the dangerous case: you must check whether the eigenspace is large enough.

Complex eigenvalues. A real matrix can have complex conjugate eigenvalues (and complex eigenvectors). The same algebra A=SΛS−1A = S\Lambda S^{-1}A=SΛS−1 still holds over C\mathbb{C}C. Real normal forms (block-diagonal with 2×22 \times 22×2 rotation-scaling blocks) exist but are not needed for the Markov applications below.


Powers of a Matrix#

Once A=SΛS−1A = S\Lambda S^{-1}A=SΛS−1, powers of AAA collapse to powers of a diagonal matrix. Compute

A2=(SΛS−1)(SΛS−1)=SΛ(S−1S)ΛS−1=SΛ2S−1.A^2 = (S\Lambda S^{-1})(S\Lambda S^{-1}) = S\Lambda (S^{-1}S)\Lambda S^{-1} = S\Lambda^2 S^{-1}.A2=(SΛS−1)(SΛS−1)=SΛ(S−1S)ΛS−1=SΛ2S−1.

By induction,

Ak=SΛkS−1A^k = S\Lambda^k S^{-1}Ak=SΛkS−1

for every positive integer kkk. And Λk\Lambda^kΛk is trivial:

Λk=(λ1k⋱λnk).\Lambda^k = \begin{pmatrix} \lambda_1^k & & \\ & \ddots & \\ & & \lambda_n^k \end{pmatrix}.Λk=​λ1k​​⋱​λnk​​​.

You raise nnn numbers to the kkk-th power — no matrix multiplications of growing size.

Cost contrast. Computing AkA^kAk by repeated multiplication (AAA, then A2=A⋅AA^2 = A\cdot AA2=A⋅A, then A3=A2⋅AA^3 = A^2\cdot AA3=A2⋅A, …) costs O(k)O(k)O(k) multiplications of n×nn \times nn×n matrices, each O(n3)O(n^3)O(n3) in naive arithmetic — total O(kn3)O(k n^3)O(kn3). Diagonalization pays a one-time eigen-decomposition cost, after which each power is O(n)O(n)O(n) for the diagonal entries plus O(n3)O(n^3)O(n3) for the two multiplications by SSS and S−1S^{-1}S−1. When many powers are needed, or kkk is huge, the eigen route wins.

Negative powers. If AAA is invertible (equivalently, no λj=0\lambda_j = 0λj​=0), then A−1=SΛ−1S−1A^{-1} = S\Lambda^{-1}S^{-1}A−1=SΛ−1S−1 with Λ−1=diag⁡(1/λ1,…,1/λn)\Lambda^{-1} = \operatorname{diag}(1/\lambda_1,\ldots,1/\lambda_n)Λ−1=diag(1/λ1​,…,1/λn​), and A−k=SΛ−kS−1A^{-k} = S\Lambda^{-k}S^{-1}A−k=SΛ−kS−1.

Determinant of a power. Because det⁡(A)=det⁡(S)det⁡(Λ)det⁡(S−1)=det⁡(Λ)=λ1⋯λn\det(A) = \det(S)\det(\Lambda)\det(S^{-1}) = \det(\Lambda) = \lambda_1\cdots\lambda_ndet(A)=det(S)det(Λ)det(S−1)=det(Λ)=λ1​⋯λn​, we get

det⁡(Ak)=det⁡(A)k=λ1k⋯λnk.\det(A^k) = \det(A)^k = \lambda_1^k \cdots \lambda_n^k.det(Ak)=det(A)k=λ1k​⋯λnk​.

That identity is a quick check without forming AkA^kAk at all.

Worked power. For the same AAA with λ1=5\lambda_1 = 5λ1​=5, λ2=2\lambda_2 = 2λ2​=2,

Ak=S(5k002k)S−1.A^k = S\begin{pmatrix} 5^k & 0 \\ 0 & 2^k \end{pmatrix}S^{-1}.Ak=S(5k0​02k​)S−1.

In particular det⁡(A3)=53⋅23=125⋅8=1000\det(A^3) = 5^3 \cdot 2^3 = 125 \cdot 8 = 1000det(A3)=53⋅23=125⋅8=1000, matching det⁡(A)3=103=1000\det(A)^3 = 10^3 = 1000det(A)3=103=1000.

Exercise · Fill in the blank

A = [[4,1],[2,3]] has eigenvalues 5 and 2. Using det(A^3) = product of the eigenvalues cubed, what is det(A^3)?


Markov Matrices#

A Markov matrix (also called a stochastic matrix or transition matrix) encodes one step of a discrete-time chain on nnn states. The standard linear-algebra convention here is:

  • every entry of AAA is nonnegative: aij≥0a_{ij} \ge 0aij​≥0;
  • every column sums to 111: ∑i=1naij=1\sum_{i=1}^{n} a_{ij} = 1∑i=1n​aij​=1 for each jjj.

Entry aija_{ij}aij​ is the probability of moving from state jjj to state iii in one step. Column jjj is therefore a probability distribution over the next state given that you start in jjj. A state vector xxx is a column vector of nonnegative entries that sum to 111; after one transition the new distribution is AxAxAx.

Why λ=1\lambda = 1λ=1 is always an eigenvalue. The column-sum condition is equivalent to

1⊤A=1⊤,\mathbf{1}^\top A = \mathbf{1}^\top,1⊤A=1⊤,

where 1=(1,…,1)⊤\mathbf{1} = (1,\ldots,1)^\top1=(1,…,1)⊤ is the all-ones vector. Taking the transpose, A⊤1=1A^\top \mathbf{1} = \mathbf{1}A⊤1=1, so A⊤A^\topA⊤ has eigenvalue 111 with eigenvector 1\mathbf{1}1. Eigenvalues of AAA and A⊤A^\topA⊤ coincide, so AAA also has eigenvalue 111. We state without full spectral proof that for a nonnegative matrix with column sums 111, every eigenvalue satisfies ∣λ∣≤1|\lambda| \le 1∣λ∣≤1, and λ=1\lambda = 1λ=1 is always present. Under mild extra conditions (the chain is irreducible and aperiodic — “you can eventually reach any state from any other, and periods do not trap you”), λ=1\lambda = 1λ=1 is simple and every other eigenvalue obeys ∣λ∣<1|\lambda| < 1∣λ∣<1.

Example.

A=(0.90.20.10.8)A = \begin{pmatrix} 0.9 & 0.2 \\ 0.1 & 0.8 \end{pmatrix}A=(0.90.1​0.20.8​)

has nonnegative entries; column sums are 0.9+0.1=10.9+0.1 = 10.9+0.1=1 and 0.2+0.8=10.2+0.8 = 10.2+0.8=1. This is a two-state Markov matrix: state 1 tends to stay put (probability 0.90.90.9), and state 2 returns to state 1 with probability 0.20.20.2.


Steady State#

A steady-state (or stationary) distribution x∞x_\inftyx∞​ is a probability vector that does not change under the transition:

Ax∞=x∞.A x_\infty = x_\infty.Ax∞​=x∞​.

That is exactly the eigenvector equation for λ=1\lambda = 1λ=1. So find any eigenvector for λ=1\lambda = 1λ=1, then normalize so the components sum to 111 (and are nonnegative — which they will be for a Markov matrix under the conditions above).

Convergence from any start. Suppose AAA is diagonalizable with eigenvalues λ1=1\lambda_1 = 1λ1​=1, λ2,…,λn\lambda_2, \ldots, \lambda_nλ2​,…,λn​ and ∣λj∣<1|\lambda_j| < 1∣λj​∣<1 for j≥2j \ge 2j≥2. Write the initial distribution in the eigenbasis:

x0=c1v1+c2v2+⋯+cnvn,x_0 = c_1 v_1 + c_2 v_2 + \cdots + c_n v_n,x0​=c1​v1​+c2​v2​+⋯+cn​vn​,

with v1v_1v1​ the steady-state eigenvector (or any multiple, before normalization). Then

xk=Akx0=c1(1)kv1+c2λ2kv2+⋯+cnλnkvn.x_k = A^k x_0 = c_1 (1)^k v_1 + c_2 \lambda_2^k v_2 + \cdots + c_n \lambda_n^k v_n.xk​=Akx0​=c1​(1)kv1​+c2​λ2k​v2​+⋯+cn​λnk​vn​.

As k→∞k \to \inftyk→∞, every term with ∣λj∣<1|\lambda_j| < 1∣λj​∣<1 dies: λjk→0\lambda_j^k \to 0λjk​→0. The limit is c1v1c_1 v_1c1​v1​, and because each xkx_kxk​ is a probability vector (nonnegative entries summing to 111), the limit is the unique steady-state distribution. Diagonalization explains the long-run behavior: repeated multiplication by AAA is dominated by the eigenvalue of largest magnitude, which for a Markov matrix is 111.

Worked steady state. For

A=(0.90.20.10.8),A = \begin{pmatrix} 0.9 & 0.2 \\ 0.1 & 0.8 \end{pmatrix},A=(0.90.1​0.20.8​),

solve (A−I)x=0(A - I)x = 0(A−I)x=0:

A−I=(−0.10.20.1−0.2).A - I = \begin{pmatrix} -0.1 & 0.2 \\ 0.1 & -0.2 \end{pmatrix}.A−I=(−0.10.1​0.2−0.2​).

The two rows are multiples; the single equation is −0.1 x1+0.2 x2=0-0.1\, x_1 + 0.2\, x_2 = 0−0.1x1​+0.2x2​=0, so x1=2x2x_1 = 2 x_2x1​=2x2​. With x1+x2=1x_1 + x_2 = 1x1​+x2​=1,

2x2+x2=1⇒x2=13,x1=23.2x_2 + x_2 = 1 \quad\Rightarrow\quad x_2 = \tfrac{1}{3},\quad x_1 = \tfrac{2}{3}.2x2​+x2​=1⇒x2​=31​,x1​=32​.

Thus x∞=(2/3, 1/3)⊤x_\infty = (2/3,\ 1/3)^\topx∞​=(2/3, 1/3)⊤. Starting from any initial probability vector and iterating x↦Axx \mapsto Axx↦Ax drives the state toward this same pair. The browser lab below runs 50 steps and compares the result to the normalized eigenvector for λ=1\lambda = 1λ=1.

Link forward. The same eigen-decoupling that turns AkA^kAk into Λk\Lambda^kΛk reappears in Week 11 for systems of differential equations u′=Auu' = Auu′=Au: solutions are linear combinations of eλjtvje^{\lambda_j t} v_jeλj​tvj​. Diagonalization is the bridge between discrete powers and continuous exponentials.


Knowledge check#

Question 1 of 3

A^k can be computed efficiently as:

S Λ^k S^{-1}
S^k Λ S^{-1}
Λ^k
S Λ S^{-k}

Browser lab#

Simulate a Markov chain converging to its steady state, and compare to the eigenvector for λ=1\lambda = 1λ=1.

python · runs in browser
import numpy as np

A = np.array([[0.9, 0.2],
              [0.1, 0.8]])

x0 = np.array([1.0, 0.0])
x = x0.copy()
for _ in range(50):
    x = A @ x

eigvals, eigvecs = np.linalg.eig(A)
steady_idx = np.argmin(np.abs(eigvals - 1))
steady_state = eigvecs[:, steady_idx]
steady_state = steady_state / steady_state.sum()

print("x after 50 steps =", x)
print("eigenvector steady state (normalized) =", steady_state.real)
← Previous
Week 9: Eigenvalues and Eigenvectors
Next →
Week 11: Differential Equations
On this page
  • Diagonalization
  • Powers of a Matrix
  • Markov Matrices
  • Steady State
  • Knowledge check
  • Browser lab