High School Mathematics · Grades 10–12
30Matrices and Graphs
A matrix is a rectangular array of numbers, added and multiplied by rules designed so that matrix algebra represents the composition of linear transformations. Matrices solve linear systems, drive coupled recurrent sequences, and count walks in networks — the mathematics behind search engines and shortest-path algorithms.
30.1 Matrix algebra
Definition 30.1 (Matrix)
An matrix is a table of real numbers with rows and columns: , where is the entry in row , column . Two matrices of the same size are added entry by entry, and .
Definition 30.2 (Matrix product)
Let be and be . The product is the matrix whose entry is
(the “row of times column of ” rule).
Example 30.3
, while : matrix multiplication is not commutative.
Proposition 30.4 (Rules of matrix algebra)
Whenever the sizes make the products meaningful:
and the identity matrix (ones on the diagonal, zeros elsewhere) satisfies for of size .
Proof. All are entry-by-entry verifications from Definition 30.2; associativity, the only nontrivial one, amounts to exchanging two finite sums: . ∎
Definition 30.5 (Inverse)
A square matrix of size is invertible if there is a matrix with ; is then unique, written .
Proposition 30.6 (Inverse of a matrix)
Let and (the determinant). Then is invertible if and only if , in which case
Proof. A computation gives ; if , divide. Conversely, if , the columns of are proportional, and so are the columns of for any ; but the columns of are not proportional, so no can satisfy . ∎
Method 30.7 (Linear systems)
The system is the matrix equation with , . If , its unique solution is . The same formalism handles equations in unknowns.
30.2 Matrix powers and recurrent sequences
Definition 30.8
For a square matrix and , ( factors), with .
Method 30.9 (Diagonal-plus-nilpotent and diagonalizable cases)
Two standard ways to compute :
- If where , the binomial theorem (valid here since and commute) collapses to two terms: .
- If one finds an invertible with and diagonal, then , and is computed entry by entry. (Finding such a systematically is the theory of diagonalization, developed at university; at this level is given.)
Example 30.10 (Coupled sequences)
Let and . Setting and , we get , so . The auxiliary sequences and satisfy and , so , and
(Behind the scenes: and are eigenvector directions of .)
30.3 Graphs and walks
Definition 30.11 (Graph, adjacency matrix)
A graph consists of vertices and edges joining certain pairs of vertices (ordered pairs for a directed graph). Its adjacency matrix is the matrix with if there is an edge from to , and otherwise. A walk of length from to is a sequence of consecutive edges leading from to .
Theorem 30.12 (Counting walks)
The number of walks of length from vertex to vertex is the entry of .
Proof. Induction on . For this is the definition of . Assume the claim for . A walk of length from to is a walk of length from to some vertex , followed by an edge from to ; by the addition and multiplication principles, their number is
∎
Example 30.13
For the triangle graph ( vertices, all pairs joined), and : from each vertex there are walks of length back to itself (via either neighbor) and to each other vertex.
30.4 Exercises
Exercise 30.1 ★
Let and . Compute , , and .
Solution
Solution of Exercise 30.1.
Note .
Exercise 30.2 ★
Determine whether the following matrices are invertible, and compute the inverses when they exist:
Exercise 30.3 ★
Solve by matrix inversion the system
Exercise 30.4 ★★
Let with .
- Check that and that and commute.
- Deduce for all and verify the formula for by direct computation.
Solution
Solution of Exercise 30.4.
1. , and commutes with every matrix.
2. Since the two terms commute, the binomial theorem applies and all terms containing vanish:
Check for : , and the formula gives , . ✓
Exercise 30.5 ★★
Let and the Fibonacci sequence (, , ). Show by induction that for ,
and deduce the identity . (Hint: determinants multiply: , which you may check for matrices.)
Solution
Solution of Exercise 30.5.
Induction. For : . Assume the formula for ; then
Identity. For matrices, expanding shows ; hence , and . (This is Cassini’s identity.)
Exercise 30.6 ★★
A directed graph on vertices has edges , , and .
- Write the adjacency matrix and compute and .
- How many walks of length go from to ? List them.
Solution
Solution of Exercise 30.6.
1. Ordering vertices :
2. : exactly one closed walk of length at vertex , namely . (The walk has length only, and then then ends at .)
Exercise 30.7 ★★
A car-sharing company moves vehicles between two cities and . Each week, of the cars in stay in and move to ; of the cars in move to and stay. Let be the proportions of the fleet in each city.
- Write with and identify .
- Find the equilibrium proportions (solve with ).
- Show that satisfies , and conclude that the fleet distribution converges to the equilibrium.
Solution
Solution of Exercise 30.7.
1. , : .
2. gives , i.e. , so ; with : , .
3. Using : , so
Hence : and , whatever the initial distribution.
Exercise 30.8 ★★★
Let , .
- Compute , then , and check that is diagonal.
- Deduce a closed formula for and compare with Example 30.10.
Solution
Solution of Exercise 30.8.
1. , so . Then
2. From , an immediate induction gives with , so
Applying to reproduces exactly the formulas of Example 30.10.
30.5 Problem: The matrix that knows Fibonacci (and the weather)
Problem 30.1
Weekend problem — one matrix carries all of Fibonacci, a Markov matrix forecasts the long-run weather, and an eigenvector is worth a billion dollars
A matrix is a machine that eats a state and returns the next one — and its powers therefore hold entire futures. This problem opens with the astonishing matrix whose powers list the Fibonacci numbers (and prove their identities in one line each), then runs the weather as a Markov chain to its steady state, and closes with the eigenvector on which a search engine was built (Theorem 30.12, Method 30.9).
Part I — Fluency.
- With and : compute and . Verdict on commutativity?
- Invert (Proposition 30.6) and use the inverse to solve , .
- Let : compute , and deduce for every .
- The triangle graph (three vertices, all pairs joined): write its adjacency matrix , compute , and interpret the diagonal entries (Theorem 30.12).
- For : give and its behavior as .
Part II — The Fibonacci matrix. Let and let be the Fibonacci numbers of Problem 13.1.
- Compute , , and conjecture the general form of in terms of Fibonacci numbers.
- Prove the conjecture by induction.
- Take determinants of both sides (the determinant of a product is the product of the determinants — check it on matrices if you have never seen it): deduce Cassini’s identity — the vanishing-square engine, proved in one line.
From , read off the top-right entries and derive the addition formula
Check it for .
- Deduce from the addition formula (induction on ) that divides , and verify on and .
- To compute , one need not multiply matrices: square repeatedly () and combine. How many matrix multiplications suffice, and which ancient multiplication trick from the Middle School volume is this, promoted to matrices?
Part III — The weather machine. In a certain city: after a sunny day, the next is sunny with probability ; after a rainy day, sunny with probability . Encode the day’s distribution as a column and the evolution by
- Check that each column of sums to , and say why any weather machine must have this property.
- Today is sunny. Compute the forecast for tomorrow and for the day after.
- Find the steady state: the distribution with (and entries summing to ). What fraction of days is sunny in the long run?
- Start from a rainy day, , and apply four times, tracking the distance to the steady state at each step. By what factor does the gap shrink per step — and what kind of convergence is this?
- PageRank in miniature: three pages, with links , , , . A random surfer follows an outgoing link uniformly at random. Write the transition matrix, find the steady state, and rank the pages.
- Interpret the ranking: why does score as high as despite receiving links from fewer pages — what does the steady state actually measure? (Real PageRank adds a damping factor for dead ends and jumps; the eigenvector idea is exactly this one.)
Part IV — Diagonal dividends.
- Two coupled quantities obey , , i.e. the matrix of Exercise 30.8. Using that exercise’s diagonalization (), give the closed formula for when , , and check it against direct computation for .
- In one or two sentences: what does diagonalization do to a coupled system — and in what sense is the Markov steady state of question 14 an eigenvector story too?
- Finale — the matrix’s three faces this weekend: bookkeeping (systems and inverses), combinatorics (walks and links counted by powers), and evolution (Fibonacci, weather, the web — futures read off eigen-directions). One sentence each, plus the forward pointer: the university volumes’ linear algebra makes every one of these faces a theory.
Solution
Solution of Problem 30.1.
1. and : matrix multiplication is not commutative — swaps columns on the right, rows on the left.
2. Determinant : inverse . Applying it to : , .
3. . Then by induction: .
4. , and has diagonal entries : from each vertex, exactly two closed walks of length (the triangle walked clockwise or counterclockwise) — the counting theorem in action.
5. : one direction explodes, the other dies — diagonal fates are independent geometric sequences.
6. , , : Fibonacci everywhere; conjecture as stated.
7. If , then
heredity; the base case is itself, using the convention (which extends the recurrence backwards).
8. , so ; and directly : Cassini, one line. (The product rule for determinants is a pleasant five-minute expansion.)
9. Top-right of : ; top-right of : . For : .
10. For : trivial. If , the addition formula with : : both terms are multiples of . So for all : check divides and .
11. : seven squarings () plus two combinations — nine multiplications instead of ninety-nine. It is the doubling-table trick of the Egyptian scribes, lifted from numbers to matrices: write in binary, multiply the doublings you need.
12. and : tomorrow must be some weather — each column is a complete probability distribution, so probabilities are conserved.
13. Tomorrow: . Day after: .
14. with , : gives , : . In the long run, two days in three are sunny — whatever today looks like.
15. From : sunny components , , , ; gaps to : , , , — each step multiplies the gap by exactly (the machine’s second eigenvalue): geometric convergence to the steady state.
16. Columns (from , , ): . Steady state: , , ; summing to : . Ranking: and tie for first, last.
17. receives all of ’s traffic and half of ’s, and it funnels everything back to : the steady state measures where the surfer spends time, not how many links point in — one link from a popular page outweighs several from deserted ones. That recursive weighting is precisely Google’s founding idea; damping handles spider traps and dead ends.
18. gives (and ). Check: , , ; directly: : matching.
19. Diagonalization changes to coordinates in which the coupled system falls apart into independent geometric sequences — each eigenvalue runs its own race. The Markov steady state is the eigenvector of eigenvalue , and the convergence rate of question 15 is the next eigenvalue: the weather machine was an eigen-story all along.
20. Bookkeeping: a system is one matrix equation, solved by one inverse. Combinatorics: powers of the adjacency matrix count walks, links, connections. Evolution: powers of the machine carry states to their destinies, and the eigen-directions (Fibonacci’s golden direction, the weather’s steady state, the web’s ranking vector) are the destinies. Linear algebra, in the university volumes, is the science of exactly this.