Session 24 · Unit 2

Markov Matrices; Fourier Series


Two applications of the chapter's big ideas. Markov matrices — nonnegative entries, columns summing to one — always have eigenvalue 1, and its eigenvector is the steady state that powers of the matrix approach; a two-state population model shows the whole machine at work. Then projection onto an orthonormal basis, pushed to infinite dimensions: Fourier series is exactly an expansion in an orthonormal basis of functions, with integrals playing the role of dot products.

What makes a matrix Markov

This lecture is about applications of eigenvalues, and the star is the Markov matrix. Strang just invents one:

A=[.1.01.3.2.99.3.70.4]A = \begin{bmatrix} .1 & .01 & .3 \\ .2 & .99 & .3 \\ .7 & 0 & .4 \end{bmatrix}

Why those two properties? Markov matrices are connected to probability, and probabilities are never negative; the columns add to one because probabilities of all the possibilities add to one. And since we’ll be interested in the powers AkA^k, it matters that the properties persist.

The question that drives everything is steady state. Last time, with differential equations, a steady state came from an eigenvalue λ=0\lambda = 0 — the e0te^{0t} term sat still while the others moved. With powers of a matrix it’s different: a zero eigenvalue dies immediately. For powers, it’s an eigenvalue of one that’s all-important. The two key facts about Markov matrices:

  1. λ=1\lambda = 1 is an eigenvalue — always, and you can know it without computing a single determinant.
  2. All other eigenvalues have λ<1|\lambda| \lt 1 (with possible exceptional cases where another eigenvalue has magnitude equal to one — but never larger).

Recall the general formula for powers. If uk=Aku0u_{k} = A^k u_0 and AA has a complete set of eigenvectors (Strang: “my conscience always makes me say at least once per lecture” that this is required), then

uk=Aku0=c1λ1kx1+c2λ2kx2+u_k = A^k u_0 = c_1 \lambda_1^k \mathbf{x}_1 + c_2 \lambda_2^k \mathbf{x}_2 + \cdots

Now watch what the two key facts do. Take λ1=1\lambda_1 = 1: the first term is c1x1c_1 \mathbf{x}_1 forever. Every other λi\lambda_i is smaller than one in magnitude, so λik0\lambda_i^k \to 0 — those terms die as we iterate. The steady state is c1x1c_1 \mathbf{x}_1: the steady state is the eigenvector for λ=1\lambda = 1, scaled by however much of it was in the initial condition. And there’s one more special fact: that eigenvector x1\mathbf{x}_1 has all components 0\geq 0 — no negative components — so the steady state is positive if the start was. (Strang states this without proof.)

Why one is an eigenvalue

If 11 is an eigenvalue of AA, then AIA - I should be singular — the eigenvalues are exactly the shifts that make the matrix singular. Subtract the identity from the example:

AI=[.9.01.3.2.01.3.70.6]A - I = \begin{bmatrix} -.9 & .01 & .3 \\ .2 & -.01 & .3 \\ .7 & 0 & -.6 \end{bmatrix}

What happened to the columns? They added to one; now all columns of AIA - I add to zero. Why does that force singularity? This could be a theoretical quiz question, and we’re at a point in the course with several ways to see it. We don’t want the determinant. Singular means the columns are dependent — but it’s the rows that are easier here. What combination of the three rows gives the zero row? Just add them: one times each row, and every column sums to zero. So the rows are dependent, the matrix is singular, done.

That combination (1,1,1)(1, 1, 1) is multiplying the rows, so it lives in the left null space: (1,1,1)(1,1,1) is in N(ATI)N(A^T - I) — it’s an eigenvector of ATA^T with eigenvalue 1. And who is in the null space of AIA - I itself? Some combination of the columns gives zero, and the three numbers in that combination are exactly the eigenvector x1\mathbf{x}_1 — the steady state.

So the reasoning chain: columns of AA add to one \Rightarrow columns of AIA - I add to zero \Rightarrow (1,1,1)(1,1,1) kills the rows \Rightarrow ATA^T has eigenvalue 1 \Rightarrow so does AA.

Where Markov matrices come from: California and Massachusetts

The equation being studied is uk+1=Auku_{k+1} = A u_k with AA Markov. Strang’s example: two states — literally, California and Massachusetts — and the populations in each. Every year, some fraction of each population stays and some fraction moves:

[uCaluMass]k+1=[.9.2.1.8][uCaluMass]k\begin{bmatrix} u_{\text{Cal}} \\ u_{\text{Mass}} \end{bmatrix}_{k+1} = \begin{bmatrix} .9 & .2 \\ .1 & .8 \end{bmatrix} \begin{bmatrix} u_{\text{Cal}} \\ u_{\text{Mass}} \end{bmatrix}_{k}

Read column one: of the people in California at time kk, nine tenths stay and one tenth move to Massachusetts — the column adds to one because all Californians are accounted for. Column two: after the Red Sox fail again, only 80 percent of Massachusetts stays and 20 percent moves to California. Entries 0\geq 0 because they’re probabilities; columns summing to one because nobody is gained or lost. The Markov chain conserves total population. (One severe limitation of the model: the same matrix, the same probabilities, act at every time step, forever.)

Start everyone in Massachusetts: u0=(0,1000)u_0 = (0, 1000). After one step, multiply once by AA: a thousand times column two gives (200,800)(200, 800). Next step, more move west, twenty come back — California ends up above 200, the total still 1000. What about step 100? For any question like that, we need eigenvalues and eigenvectors.

Eigenvalues. One of them is λ1=1\lambda_1 = 1 — free of charge, it’s a Markov matrix. The trace is .9+.8=1.7.9 + .8 = 1.7, so λ2=.7\lambda_2 = .7. (Check with the determinant: .72.02=.7.72 - .02 = .7.) Notice λ2<1|\lambda_2| \lt 1, as promised.

Eigenvectors. For λ1=1\lambda_1 = 1: the null space of AI=[.1.2.1.2]A - I = \begin{bmatrix} -.1 & .2 \\ .1 & -.2 \end{bmatrix} is spanned by x1=[21]\mathbf{x}_1 = \begin{bmatrix} 2 \\ 1 \end{bmatrix} — positive, as the theory says. For λ2=.7\lambda_2 = .7: subtract .7.7 from the diagonal to get [.2.2.1.1]\begin{bmatrix} .2 & .2 \\ .1 & .1 \end{bmatrix} — certainly singular, so the calculation checks — with null space x2=[11]\mathbf{x}_2 = \begin{bmatrix} -1 \\ 1 \end{bmatrix}.

We can jump to infinity right now. The steady state is a multiple of (2,1)(2, 1), and the multiple is decided by the thousand people: the components must add to 1000, so the populations approach (20003,10003)\left(\tfrac{2000}{3}, \tfrac{1000}{3}\right) — two thirds of everyone in California, one third in Massachusetts, forever.

For finite times, write out the full solution and match u0u_0:

uk=c1(1)k[21]+c2(.7)k[11],u0=[01000]    c1=10003,  c2=20003u_k = c_1 (1)^k \begin{bmatrix} 2 \\ 1 \end{bmatrix} + c_2 (.7)^k \begin{bmatrix} -1 \\ 1 \end{bmatrix}, \qquad u_0 = \begin{bmatrix} 0 \\ 1000 \end{bmatrix} \;\Rightarrow\; c_1 = \frac{1000}{3},\; c_2 = \frac{2000}{3}

Check k=0k = 0: 2000320003=0\tfrac{2000}{3} - \tfrac{2000}{3} = 0 and 10003+20003=1000\tfrac{1000}{3} + \tfrac{2000}{3} = 1000. The (.7)k(.7)^k term is the part that’s disappearing; what’s left is the steady state.

One comment for other courses: many applications (you’ll meet Markov matrices in electrical engineering) prefer row vectors, multiplying vector times matrix from the left. That uses the transpose of our matrix, so in other textbooks you’ll see rows adding to one instead of columns. Same theory, transposed conventions.

Projection onto an orthonormal basis

Now the bridge to Fourier. Suppose q1,,qn\mathbf{q}_1, \ldots, \mathbf{q}_n is an orthonormal basis for Rn\mathbb{R}^n. Any vector v\mathbf{v} can be expanded in the basis:

v=x1q1+x2q2++xnqn\mathbf{v} = x_1 \mathbf{q}_1 + x_2 \mathbf{q}_2 + \cdots + x_n \mathbf{q}_n

What are the amounts x1,x2,x_1, x_2, \ldots? We could grind through the normal equations, but orthonormality gives the answer instantly. To get x1x_1, take the inner product of the whole equation with q1\mathbf{q}_1. Every term q1Tqi\mathbf{q}_1^T \mathbf{q}_i with i1i \neq 1 is zero; the term q1Tq1\mathbf{q}_1^T \mathbf{q}_1 is one. A bunch of zeros and a single survivor:

q1Tv=x1\mathbf{q}_1^T \mathbf{v} = x_1

In matrix language the expansion says Qx=vQ\mathbf{x} = \mathbf{v}, so x=Q1v\mathbf{x} = Q^{-1}\mathbf{v} — and the whole point of the letter QQ is that no work is needed to invert it: Q1=QTQ^{-1} = Q^T. The first component of x=QTv\mathbf{x} = Q^T\mathbf{v} is the first row of QTQ^T times v\mathbf{v}, which is exactly q1Tv\mathbf{q}_1^T \mathbf{v}. Same conclusion, seen twice.

Fourier series: an orthonormal basis for functions

Joseph Fourier realized: I could work in function space. Instead of a vector v\mathbf{v}, a function f(x)f(x); instead of orthogonal vectors q1,q2,\mathbf{q}_1, \mathbf{q}_2, \ldots, orthogonal functions — and infinitely many, because the space is infinite-dimensional:

f(x)=a0+a1cosx+b1sinx+a2cos2x+b2sin2x+f(x) = a_0 + a_1 \cos x + b_1 \sin x + a_2 \cos 2x + b_2 \sin 2x + \cdots

This is the moment the course leaves finite-dimensional vector spaces. The vectors are now functions; the basis is 1,cosx,sinx,cos2x,sin2x,1, \cos x, \sin x, \cos 2x, \sin 2x, \ldots And the reason Fourier series is a success is that this basis is orthogonal. But orthogonal in what sense? We know vTw=v1w1++vnwn\mathbf{v}^T\mathbf{w} = v_1 w_1 + \cdots + v_n w_n for vectors. A function doesn’t have nn components — it has a whole continuum of values.

Check one orthogonality: 02πsinxcosxdx=12sin2x02π=0\int_0^{2\pi} \sin x \cos x \, dx = \tfrac{1}{2}\sin^2 x \big|_0^{2\pi} = 0. The same holds — with some trig identities to help out — for every other pair in the list. So we have an orthogonal infinite basis for function space, and all we want to do is expand a function in that basis.

How much cosx\cos x is in ff? Exactly as in the vector case: take the inner product of everything with cosx\cos x — in ordinary calculus words, multiply by cosx\cos x and integrate. On the right, a whole lot of zeros; the only term that survives is the a1a_1 term:

02πf(x)cosxdx=a102πcos2xdx=a1πa1=1π02πf(x)cosxdx\int_0^{2\pi} f(x) \cos x \, dx = a_1 \int_0^{2\pi} \cos^2 x \, dx = a_1 \pi \qquad\Longrightarrow\qquad a_1 = \frac{1}{\pi} \int_0^{2\pi} f(x)\cos x \, dx

The cos2\cos^2 integral is not zero, of course — it’s the squared length of the basis function — and an easy calculation gives π\pi. That is Euler’s famous formula (or maybe Fourier found it) for the coefficients of a Fourier series, and you can now see it for what it is: exactly an expansion in an orthonormal basis. (The constant term is even easier: a0a_0 comes out to be the average value of ff.)

Problems

Everything here runs on the lecture’s two engines: the eigenvalue 1 of a Markov matrix, and coefficients by inner products.

Problem 24.1 Steady state of a Markov chain

Rain follows sun: if today is sunny, tomorrow is sunny with probability .8.8 and rainy with probability .2.2; if today is rainy, tomorrow is sunny with probability .4.4 and rainy with probability .6.6. Write the Markov matrix, find both eigenvalues, and find the long-run fraction of sunny days.

Show solution

With uk=(sunny,rainy)u_k = (\text{sunny}, \text{rainy}) probabilities,

A=[.8.4.2.6]A = \begin{bmatrix} .8 & .4 \\ .2 & .6 \end{bmatrix}

(columns add to one). One eigenvalue is λ1=1\lambda_1 = 1 automatically; the trace is 1.41.4, so λ2=.4\lambda_2 = .4.

Steady state: null space of AI=[.2.4.2.4]A - I = \begin{bmatrix} -.2 & .4 \\ .2 & -.4 \end{bmatrix}, which is spanned by [21]\begin{bmatrix} 2 \\ 1 \end{bmatrix}. Scale so the components add to 11: the steady state is (23,13)\left(\tfrac{2}{3}, \tfrac{1}{3}\right). In the long run, two thirds of days are sunny — regardless of today’s weather, since the (.4)k(.4)^k term dies.

Problem 24.2 Powers of a Markov matrix

For the lecture’s matrix A=[.9.2.1.8]A = \begin{bmatrix} .9 & .2 \\ .1 & .8 \end{bmatrix}, with eigenvalues 1,.71, .7 and eigenvectors (2,1)(2,1) and (1,1)(-1,1), start from u0=[3000]u_0 = \begin{bmatrix} 300 \\ 0 \end{bmatrix}. Find uku_k exactly, and give the populations at k=k = \infty.

Show solution

Expand u0=c1[21]+c2[11]u_0 = c_1 \begin{bmatrix} 2 \\ 1 \end{bmatrix} + c_2 \begin{bmatrix} -1 \\ 1 \end{bmatrix}: the components give 2c1c2=3002c_1 - c_2 = 300 and c1+c2=0c_1 + c_2 = 0, so c2=c1c_2 = -c_1 and 3c1=3003c_1 = 300: c1=100c_1 = 100, c2=100c_2 = -100.

uk=100[21]100(.7)k[11]=[200+100(.7)k100100(.7)k]u_k = 100 \begin{bmatrix} 2 \\ 1 \end{bmatrix} - 100\,(.7)^k \begin{bmatrix} -1 \\ 1 \end{bmatrix} = \begin{bmatrix} 200 + 100(.7)^k \\ 100 - 100(.7)^k \end{bmatrix}

Check k=0k=0: (300,0)(300, 0). ✓ The total is 300300 at every step (conserved). As kk \to \infty, the (.7)k(.7)^k term vanishes: u=(200,100)u_\infty = (200, 100) — the multiple of the eigenvector (2,1)(2,1) that accounts for all 300300 people.

Problem 24.3 Columns add to zero, so singular

Suppose MM is any n×nn \times n matrix in which every column adds to zero. Without using determinants, prove that MM is singular, and explain where the eigenvector for the eigenvalue 00 of MM lives.

Show solution

Add all the rows of MM: since each column sums to zero, the sum is the zero row. So the combination 1(row1)++1(rown)=01 \cdot (\text{row}_1) + \cdots + 1 \cdot (\text{row}_n) = \mathbf{0} — the rows are linearly dependent, hence MM is singular. Equivalently, (1,1,,1)(1, 1, \ldots, 1) is in the left null space: MTM^T has (1,,1)(1,\ldots,1) as an eigenvector with eigenvalue 00.

Since MM is singular, its own null space is nonzero: some combination of the columns gives the zero column, and that combination is an eigenvector of MM with eigenvalue 00. It lives in N(M)N(M), which is generally a different space from N(MT)N(M^T)MM and MTM^T share eigenvalues, not eigenvectors. (Applied to M=AIM = A - I with AA Markov, this eigenvector is the steady state.)

Problem 24.4 Coefficients from orthonormality

Let q1=12[11]\mathbf{q}_1 = \frac{1}{\sqrt{2}}\begin{bmatrix} 1 \\ 1 \end{bmatrix} and q2=12[11]\mathbf{q}_2 = \frac{1}{\sqrt{2}}\begin{bmatrix} 1 \\ -1 \end{bmatrix}, an orthonormal basis for R2\mathbb{R}^2. Expand v=[51]\mathbf{v} = \begin{bmatrix} 5 \\ 1 \end{bmatrix} as x1q1+x2q2x_1 \mathbf{q}_1 + x_2 \mathbf{q}_2 using inner products only — no elimination.

Show solution

Orthonormality gives each coefficient directly:

x1=q1Tv=5+12=62=32,x2=q2Tv=512=22x_1 = \mathbf{q}_1^T \mathbf{v} = \frac{5 + 1}{\sqrt{2}} = \frac{6}{\sqrt{2}} = 3\sqrt{2}, \qquad x_2 = \mathbf{q}_2^T \mathbf{v} = \frac{5 - 1}{\sqrt{2}} = 2\sqrt{2}

Check: 3212[11]+2212[11]=[33]+[22]=[51]3\sqrt{2} \cdot \frac{1}{\sqrt{2}}\begin{bmatrix} 1 \\ 1 \end{bmatrix} + 2\sqrt{2} \cdot \frac{1}{\sqrt{2}}\begin{bmatrix} 1 \\ -1 \end{bmatrix} = \begin{bmatrix} 3 \\ 3 \end{bmatrix} + \begin{bmatrix} 2 \\ -2 \end{bmatrix} = \begin{bmatrix} 5 \\ 1 \end{bmatrix}. ✓ This is x=QTv\mathbf{x} = Q^T\mathbf{v} in action.

Problem 24.5 A Fourier coefficient

Using the inner product 02πf(x)g(x)dx\int_0^{2\pi} f(x) g(x)\, dx, find the coefficient b1b_1 of sinx\sin x in the Fourier series of a 2π2\pi-periodic function ff, following the lecture’s method. Then compute b1b_1 for the square wave f(x)=1f(x) = 1 on (0,π)(0, \pi) and f(x)=1f(x) = -1 on (π,2π)(\pi, 2\pi).

Show solution

Multiply the series f(x)=a0+a1cosx+b1sinx+f(x) = a_0 + a_1 \cos x + b_1 \sin x + \cdots by sinx\sin x and integrate over [0,2π][0, 2\pi]. By orthogonality every term on the right integrates to zero except the b1b_1 term:

02πf(x)sinxdx=b102πsin2xdx=b1πb1=1π02πf(x)sinxdx\int_0^{2\pi} f(x) \sin x \, dx = b_1 \int_0^{2\pi} \sin^2 x \, dx = b_1 \pi \quad\Longrightarrow\quad b_1 = \frac{1}{\pi} \int_0^{2\pi} f(x) \sin x \, dx

For the square wave:

b1=1π(0πsinxdxπ2πsinxdx)=1π([cosx]0π[cosx]π2π)=1π(2(2))=4πb_1 = \frac{1}{\pi}\left( \int_0^{\pi} \sin x \, dx - \int_{\pi}^{2\pi} \sin x \, dx \right) = \frac{1}{\pi}\left( [-\cos x]_0^{\pi} - [-\cos x]_{\pi}^{2\pi} \right) = \frac{1}{\pi}(2 - (-2)) = \frac{4}{\pi}

So the square wave contains 4πsinx\frac{4}{\pi} \sin x as its first harmonic.