← IB Mathematics: Applications & Interpretation · HL · IB Maths AI revision
⭐ 0
IB Diploma Mathematics: Applications & Interpretation HL · Matrices & Graph Theory
Mini-Lesson

Matrices & Graph Theory (AI HL)

4 missions. Guess, learn, then check. Your place is saved.

  1. Mission 1Three receipts, three unknown prices: how does one matrix find them?
  2. Mission 2The city loses 10% a year and gains 5% of the country. Final split?
  3. Mission 3Can you cross all seven bridges of Königsberg exactly once?
  4. Mission 4A postman must walk every street. What's the shortest route?
Mission 1

Three receipts, three unknown prices: how does one matrix find them?

Make a guess: Three receipts, three unknown prices: how does one matrix find them?

Number and algebra · matrices

Matrices and multiplication

  • A matrix with m rows and n columns has order m × n. The element a_ij is in row i, column j.
  • Add, subtract or compare same-order matrices element by element. kA multiplies every element by k.
  • Multiply row by column: row i of A times column j of B, summed, gives element ij of AB.
  • AB exists only if columns of A = rows of B: (m × n)(n × p) gives m × p.
  • I is the identity matrix (AI = IA = A); 0 is the zero matrix.
Worked example Number and algebra · matrices

Multiplying in both orders

One entry of a matrix product2103142−1×=7ABAB2×4+1×(−1)=7
Question
A = ( 2 , 1 ; 0 , 3 ) and B = ( 1 , 4 ; 2 , −1 ). Find AB and BA.
  1. 1
    Row 1 of A with each column of B: 2 × 1 + 1 × 2 = 4 and 2 × 4 + 1 × (−1) = 7
  2. 2
    Row 2 of A with each column of B: 0 × 1 + 3 × 2 = 6 and 0 × 4 + 3 × (−1) = −3
  3. 3
    So AB = ( 4 , 7 ; 6 , −3 )
  4. 4
    The same method the other way round gives BA = ( 2 , 13 ; 4 , −1 )
Answer
AB = ( 4 , 7 ; 6 , −3 ) and BA = ( 2 , 13 ; 4 , −1 ), so AB ≠ BA.
⚠️ Watch out
matrix multiplication is not commutative. Multiplying matching elements (giving ( 2 , 4 ; 0 , −3 )) is not matrix multiplication.
Quick check
?P has order 2 × 3 and Q has order 3 × 4. What is the order of PQ?
Number and algebra · matrices

Determinant and inverse of a 2 × 2 matrix

  • For A = ( a , b ; c , d ), the determinant is det A = |A| = ad − bc.
  • If det A ≠ 0, the inverse is A⁻¹ = 1/(ad − bc)( d , −b ; −c , a ), and AA⁻¹ = A⁻¹A = I.
  • Swap a and d, change the signs of b and c, divide by the determinant.
  • If det A = 0 the matrix is singular: it has no inverse.
  • For 3 × 3 and larger matrices, find determinants and inverses with your GDC.
Calculate
?A = ( 5 , 3 ; 4 , 2 ). Find the element in row 1, column 2 of A⁻¹, as a decimal.
Number and algebra · matrices

Systems of equations as Ax = b

  • A system of linear equations can be written as Ax = b: A holds the coefficients, x the unknowns, b the constants.
  • If A is invertible, multiply both sides on the left by A⁻¹: x = A⁻¹b.
  • Order matters: bA⁻¹ is not the same (and here is not even defined).
  • For three or more unknowns, enter A and b in your GDC and calculate A⁻¹b.
Worked example Number and algebra · matrices

A 2 × 2 system by hand

Question
Use an inverse matrix to solve 3x + 2y = 12 and x + 4y = 14.
  1. 1
    Write in matrix form: ( 3 , 2 ; 1 , 4 )( x ; y ) = ( 12 ; 14 )
  2. 2
    Determinant: 3 × 4 − 2 × 1 = 10
  3. 3
    Inverse: A⁻¹ = 1/10( 4 , −2 ; −1 , 3 )
  4. 4
    Multiply: 1/10( 4 × 12 − 2 × 14 ; −1 × 12 + 3 × 14 ) = 1/10( 20 ; 30 )
Answer
x = 2, y = 3. Check: 3(2) + 2(3) = 12 and 2 + 4(3) = 14.
⚠️ Watch out
write the coefficients in the same order (x then y) in every row.
Calculate
?A shop sells pens, notebooks and folders. Three receipts show: 3 pens, 2 notebooks and 1 folder cost £12.40; 1 pen, 4 notebooks and 2 folders cost £18.80; 5 pens, 1 notebook and 3 folders cost £19.90. Write the system as Ax = b and use your GDC to find the exact price of one notebook.
£
Sort it
?Is each statement about 2 × 2 matrices always true?

Tap a statement, then tap the group it belongs in. Then press Check.

Mission check

?Three receipts, three unknown prices: how does one matrix find them?
Mission 2

The city loses 10% a year and gains 5% of the country. Final split?

Make a guess: The city loses 10% a year and gains 5% of the country. Final split?

Number and algebra · matrices

Eigenvalues and eigenvectors

  • A non-zero vector v is an eigenvector of M if Mv = λv: M only scales it. The scale factor λ is the eigenvalue.
  • Eigenvalues solve the characteristic polynomial: det (M − λ I) = 0.
  • For M = ( a , b ; c , d ) this is λ² − (a + d)λ + (ad − bc) = 0.
  • For each λ, solve (M − λ I)v = 0 to find an eigenvector (any non-zero multiple also works).
Worked example Number and algebra · matrices

Eigenvalues and eigenvectors of a 2 × 2 matrix

Question
Find the eigenvalues and corresponding eigenvectors of M = ( 4 , 1 ; 2 , 3 ).
  1. 1
    Characteristic polynomial: λ² − 7λ + (12 − 2) = λ² − 7λ + 10 = 0
  2. 2
    Factorise: (λ − 5)(λ − 2) = 0, so λ = 5 or λ = 2
  3. 3
    For λ = 5: ( −1 , 1 ; 2 , −2 )( x ; y ) = 0 gives y = x, so v = ( 1 ; 1 )
  4. 4
    For λ = 2: ( 2 , 1 ; 2 , 1 )( x ; y ) = 0 gives y = −2x, so v = ( 1 ; −2 )
Answer
λ = 5 with ( 1 ; 1 ); λ = 2 with ( 1 ; −2 ). Check: M( 1 ; −2 ) = ( 2 ; −4 ).
⚠️ Watch out
the two equations in each step are multiples of each other. That is expected: it is why det (M − λ I) = 0.
Calculate
?Find the larger eigenvalue of ( 5 , 4 ; 1 , 2 ).
Number and algebra · matrices

Diagonalisation and powers

  • If M has distinct real eigenvalues λ₁, λ₂ with eigenvectors v₁, v₂, then M = PDP⁻¹.
  • P = ( v₁ , v₂ ) has the eigenvectors as columns; D = ( λ₁ , 0 ; 0 , λ₂ ), in the same order.
  • Powers: Mⁿ = PDⁿP⁻¹, and Dⁿ = ( λ₁ⁿ , 0 ; 0 , λ₂ⁿ ). The inner P⁻¹P pairs cancel.
  • This gives a formula for Mⁿ for every n, not just one power.
Worked example Number and algebra · matrices

A formula for Mⁿ

Question
For M = ( 4 , 1 ; 2 , 3 ), find an expression for Mⁿ.
  1. 1
    From the eigenvectors: P = ( 1 , 1 ; 1 , −2 ) and D = ( 5 , 0 ; 0 , 2 )
  2. 2
    Invert P: det P = −3, so P⁻¹ = 1/3( 2 , 1 ; 1 , −1 )
  3. 3
    Multiply PDⁿ: ( 5ⁿ , 2ⁿ ; 5ⁿ , −2 · 2ⁿ )
  4. 4
    Multiply by P⁻¹: Mⁿ = 1/3( 2 · 5ⁿ + 2ⁿ , 5ⁿ − 2ⁿ ; 2 · 5ⁿ − 2 · 2ⁿ , 5ⁿ + 2 · 2ⁿ )
Answer
Mⁿ = 1/3( 2 · 5ⁿ + 2ⁿ , 5ⁿ − 2ⁿ ; 2 · 5ⁿ − 2ⁿ⁺¹ , 5ⁿ + 2ⁿ⁺¹ ). Check n = 1: 1/3( 12 , 3 ; 6 , 9 ) = M.
⚠️ Watch out
Mⁿ ≠ PDⁿP. Keep P⁻¹ on the right, or the check at n = 1 fails.
Calculate
?Use the formula for Mⁿ from the previous example to find the element in row 1, column 1 of M⁴.
Number and algebra · matrices

Transition matrices and steady states

  • In a transition matrix T, the element T_ij is the probability of moving from state j to state i, so each column adds to 1.
  • With a column state matrix s₀, the state after n steps is sₙ = Tⁿs₀.
  • A steady state s satisfies Ts = s with entries adding to 1: the eigenvector for eigenvalue 1.
  • For a regular chain (some power of T has all entries positive), sₙ tends to this steady state from any starting state.
Worked example Number and algebra · matrices

A commuter's travel choices

Bus and cycle transition diagram0.70.6BusCycle0.30.4
Question
Each day a commuter takes the bus or cycles. After a bus day, the next day is a bus day with probability 0.7. After a cycling day, the next day is a bus day with probability 0.4. Today they took the bus. Find the probability they take the bus in 2 days' time, and the long-term probability of a bus day.
  1. 1
    Columns are "from": T = ( 0.7 , 0.4 ; 0.3 , 0.6 ) (bus first), s₀ = ( 1 ; 0 )
  2. 2
    Two steps: Ts₀ = ( 0.7 ; 0.3 ), then T²s₀ = ( 0.61 ; 0.39 )
  3. 3
    Steady state ( b ; c ): Ts = s gives 0.3b = 0.4c, with b + c = 1
  4. 4
    Solve: b = 4/7, c = 3/7
Answer
P(bus in 2 days) = 0.61; long-term P(bus) = 4/7 ≈ 0.571.
⚠️ Watch out
a T whose rows add to 1 is the transpose of the IB convention and gives wrong answers with Tⁿs₀.
Calculate
?Each year 20% of the people in town A move to town B, and 10% of the people in town B move to town A. Nobody else arrives or leaves. Today 6,000 people live in A and 4,000 in B. Find the population of town A after 2 years.
Mission check

?The city loses 10% a year and gains 5% of the country. Final split?
Mission 3

Can you cross all seven bridges of Königsberg exactly once?

Make a guess: Can you cross all seven bridges of Königsberg exactly once?

Graph theory · walks and adjacency matrices

Graph vocabulary

Bridges as a graphNSWENSWE
  • A graph is a set of vertices joined by edges. Two vertices joined by an edge are adjacent; two edges sharing a vertex are adjacent edges.
  • The degree of a vertex is the number of edges meeting it. Each edge adds 2 to the total, so the sum of degrees is 2 × the number of edges.
TermMeaning
simple graphno loops and no multiple edges between the same pair
complete graph Kₙsimple, every pair of the n vertices adjacent
weighted grapheach edge carries a number (distance, cost, time)
directed graphedges have directions; each vertex has an in degree and an out degree
connecteda route exists between any two vertices (directed: strongly connected if you can follow the arrows from any vertex to any other)
subgraph / treepart of a graph / a connected graph with no cycles
Quick check
?How many edges does the complete graph K₆ have?
Graph theory · walks and adjacency matrices

Walks, trails, paths, Euler and Hamilton

NameRuleClosed version
walkany sequence of adjacent edges
trailno edge repeatedcircuit
pathno vertex repeatedcycle
  • An Eulerian trail uses every edge exactly once; an Eulerian circuit does so and ends where it starts.
  • In a connected graph: all degrees even means an Eulerian circuit exists; exactly two odd vertices means an Eulerian trail exists, starting at one odd vertex and ending at the other. Otherwise, neither.
  • A Hamiltonian path visits every vertex exactly once; a Hamiltonian cycle also returns to the start. There is no simple degree test for these.
Worked example Graph theory · walks and adjacency matrices

Is there an Eulerian trail?

Graph with five verticesABCDE
Question
For the graph shown, with edges AB, AC, BC, BD, CD, CE and DE, determine whether an Eulerian circuit or an Eulerian trail exists. If one does, write one down.
  1. 1
    List the degrees: A = 2, B = 3, C = 4, D = 3, E = 2 (sum 14, so 7 edges)
  2. 2
    Count the odd vertices: B and D, exactly two, so no Eulerian circuit but an Eulerian trail exists
  3. 3
    Start at one odd vertex and end at the other: B A C B D C E D
  4. 4
    Check: 7 edges, each used once
Answer
an Eulerian trail exists, for example BACBDCED; there is no Eulerian circuit.
⚠️ Watch out
a trail must start and finish at the two odd vertices. Starting at A leaves you stuck with an edge unused.
Sort it
?Each graph is connected. Sort it by what it contains.

Tap a statement, then tap the group it belongs in. Then press Check.

Graph theory · walks and adjacency matrices

Adjacency matrices

Graph and adjacency matrixPQRS0110101011010010PQRSPQRS
  • Adjacency matrix A: entry a_ij = number of edges from vertex i to vertex j.
  • The (i, j)th entry of A^k = number of walks of length k from i to j. For lengths up to k, add the entries of A, A², …, A^k.
  • A weighted adjacency table stores weights instead of 1s.
  • Transition matrix T: T_ij = probability of moving from j to i, so column j holds 1/(deg(j)) in each adjacent row and sums to 1.
Worked example Graph theory · walks and adjacency matrices

Counting walks with A³

Question
The graph has vertices P, Q, R, S and edges PQ, PR, QR, RS. Find the number of walks of length 3 from P to R.
  1. 1
    Write the adjacency matrix in the order P, Q, R, S: A = ( 0 , 1 , 1 , 0 ; 1 , 0 , 1 , 0 ; 1 , 1 , 0 , 1 ; 0 , 0 , 1 , 0 )
  2. 2
    Use your GDC to find A³ = ( 2 , 3 , 4 , 1 ; 3 , 2 , 4 , 1 ; 4 , 4 , 2 , 3 ; 1 , 1 , 3 , 0 )
  3. 3
    Read row P, column R: the entry is 4
  4. 4
    Check by listing: PQPR, PRPR, PRQR, PRSR
Answer
4 walks of length 3.
⚠️ Watch out
walks may repeat vertices and edges, so PRPR counts. The (P, R) entry of A² is 1, which counts walks of length 2 only.
Calculate
?An airline flies both ways on the routes shown by the adjacency matrix, with airports in the order V, W, X, Y, Z. A journey is a walk along routes. Use your GDC to find the number of journeys from V to Z that use at most 3 flights.
M = ( 0 , 1 , 1 , 0 , 0 ; 1 , 0 , 1 , 1 , 0 ; 1 , 1 , 0 , 1 , 1 ; 0 , 1 , 1 , 0 , 1 ; 0 , 0 , 1 , 1 , 0 )
Calculate
?A random walker on the graph with edges PQ, PR, QR, RS moves at each step along one of the edges at its current vertex, each equally likely. It starts at P. Using the transition matrix T, find the probability that it is at R after exactly two steps. Give your answer as a decimal.
Mission check

?Can you cross all seven bridges of Königsberg exactly once?
Mission 4

A postman must walk every street. What's the shortest route?

Make a guess: A postman must walk every street. What's the shortest route?

Graph theory · trees and algorithms

Minimum spanning trees

  • A tree is a connected graph with no cycles; on n vertices it has n − 1 edges.
  • A spanning tree is a subgraph that is a tree containing every vertex. A minimum spanning tree (MST) has least total weight.
AlgorithmMethod
KruskalList edges by weight. Add the smallest edge that does not form a cycle. Stop at n − 1 edges.
PrimStart at any vertex. Add the shortest edge from a vertex in the tree to one not yet in it.
Prim, table formCross out the new vertex's row; search the columns of all tree vertices for the smallest entry.
Worked example Graph theory · trees and algorithms

Kruskal's algorithm

Weighted network754689356ABCDEF
Question
Use Kruskal's algorithm to find a minimum spanning tree for the network shown, and state its weight.
  1. 1
    Order the edges: DE 3, BC 4, AC 5, DF 5, BD 6, EF 6, AB 7, CD 8, CE 9
  2. 2
    Add DE, BC, AC and DF: no cycles are formed
  3. 3
    Add BD (6): it joins {A, B, C} to {D, E, F}
  4. 4
    Stop: 6 vertices need 6 − 1 = 5 edges. (EF would have closed the cycle DEF.)
Answer
MST edges DE, BC, AC, DF, BD; total weight 3 + 4 + 5 + 5 + 6 = 23.
⚠️ Watch out
rejecting an edge that only touches the tree is wrong. Reject it only when both its ends are already connected.
Calculate
?The table gives the costs, in thousands of dollars, of laying cable between five buildings. Use Prim's algorithm, starting at P, to find the minimum total cost of connecting all five buildings.
PQRST
P–85912
Q8–476
R54–1011
S9710–3
T126113–
Graph theory · trees and algorithms

The Chinese postman problem

  • Goal: the shortest closed route using every edge at least once.
  • All vertices even: an Eulerian circuit exists; the answer is the total weight.
  • Two odd vertices: add the shortest path between them; those edges are walked twice.
  • Four odd vertices: list the 3 pairings, total the shortest paths for each, and repeat the least.
  • Why it works: repeating a path adds 1 to the degree of each end, so every vertex becomes even and an Eulerian circuit exists.
Worked example Graph theory · trees and algorithms

Four odd vertices

Network of five vertices467385410ABCDE
Question
For the network shown (total weight 47), find the length of the shortest route that starts and ends at A and travels along every edge at least once.
  1. 1
    Degrees: A = 3, B = 3, C = 4, D = 3, E = 3, so the odd vertices are A, B, D, E
  2. 2
    Pairing AB + DE: 4 + 9 = 13 (D to E is shortest via C: 5 + 4)
  3. 3
    Pairing AD + BE: 7 + 7 = 14 (B to E via C: 3 + 4)
  4. 4
    Pairing AE + BD: 10 + 8 = 18
  5. 5
    Repeat the least pairing: 47 + 13 = 60
Answer
60, repeating AB, DC and CE.
⚠️ Watch out
use the shortest path, not the direct edge. The edge DE is 10, longer than D → C → E = 9.
Calculate
?Return to the network from the Kruskal example, whose edges have total weight 53. A road inspector must drive along every road at least once, starting and finishing at A. Find the length of the shortest possible route.
Graph theory · trees and algorithms

The travelling salesman problem

  • Goal: the least-weight Hamiltonian cycle in a weighted complete graph. First make a table of least distances.
  • Nearest neighbour (upper bound): always go to the nearest unvisited vertex, then return to the start.
  • Deleted vertex (lower bound): MST of the other vertices, plus the two shortest edges from the deleted one.
  • lower ≤ optimal ≤ upper.
  • Choosing: every edge → Chinese postman; every vertex once and back → travelling salesman; connect all vertices cheaply → MST.
Worked example Graph theory · trees and algorithms

Bounds for a delivery round

Question
The table gives the least travel times, in minutes, between five towns. Find an upper bound using nearest neighbour from A, and a lower bound by deleting A.
| | A | B | C | D | E |
|---|---|---|---|---|---|
| A | – | 12 | 10 | 19 | 8 |
| B | 12 | – | 3 | 7 | 13 |
| C | 10 | 3 | – | 9 | 11 |
| D | 19 | 7 | 9 | – | 14 |
| E | 8 | 13 | 11 | 14 | – |
  1. 1
    Nearest neighbour from A: A → E → C → B → D → A, with times 8, 11, 3, 7, 19
  2. 2
    Upper bound: 8 + 11 + 3 + 7 + 19 = 48
  3. 3
    Delete A; MST of B, C, D, E: BC 3, BD 7, CE 11, weight 21
  4. 4
    Add the two shortest edges from A: AE = 8 and AC = 10, giving 21 + 18 = 39
Answer
39 ≤ optimal time ≤ 48 minutes.
⚠️ Watch out
the nearest neighbour tour must return to A. Forgetting DA = 19 gives 29, which is not a tour.
Sort it
?Which algorithm fits each task? Justify it by asking what must be covered.

Tap a statement, then tap the group it belongs in. Then press Check.

Mission check

?A postman must walk every street. What's the shortest route?
Recap

Big ideas

  • (m × n)(n × p) gives m × p, row by column; matrix multiplication is associative and distributive but not commutative.
  • For a 2 × 2 matrix, det A = ad − bc and A⁻¹ = 1/(ad − bc)( d , −b ; −c , a ); if det A = 0 there is no inverse.
  • A linear system is Ax = b, solved by x = A⁻¹b (by hand for 2 × 2, GDC for larger).
  • Eigenvalues solve det (M − λ I) = 0; an eigenvector satisfies Mv = λv.
  • With distinct real eigenvalues, M = PDP⁻¹ and Mⁿ = PDⁿP⁻¹.
  • In a transition matrix the columns are "from" and add to 1; sₙ = Tⁿs₀, and the steady state solves Ts = s (eigenvalue 1).
  • Degree = edges at a vertex; the degree sum is twice the number of edges. Kₙ has (n(n−1))/2 edges.
  • Connected graph: all degrees even means an Eulerian circuit; exactly two odd means an Eulerian trail between them; otherwise neither.
  • The (i, j)th entry of A^k counts walks of length k from i to j; in a transition matrix, T_ij is the probability of moving from j to i.
  • Kruskal: cheapest edges first, skip any that make a cycle. Prim: grow one tree, adding the cheapest edge to a new vertex. An MST on n vertices has n − 1 edges.
  • Chinese postman: total weight plus the least-weight pairing of odd vertices by shortest paths (up to four odd vertices).
  • Travelling salesman: nearest neighbour gives an upper bound; deleted vertex (MST of the rest plus the two shortest edges) gives a lower bound.
🏆

Mini-lesson complete!

⭐⭐⭐

You've worked through Matrices & Graph Theory (AI HL) for IB Diploma Mathematics: Applications & Interpretation HL. 🎉

  1. Mission 1Three receipts, three unknown prices: how does one matrix find them?
  2. Mission 2The city loses 10% a year and gains 5% of the country. Final split?
  3. Mission 3Can you cross all seven bridges of Königsberg exactly once?
  4. Mission 4A postman must walk every street. What's the shortest route?

Your stars: 0 / 0

Next: more IB Mathematics: Applications & Interpretation · HL lessons and games on the IB Mathematics: Applications & Interpretation · HL page.

📣 Smashed it? Share your score

Challenge a mate to beat your stars, or show a parent how you got on.

→ Back to IB Mathematics: Applications & Interpretation · HL

Specification points and sources for this lesson are listed at the bottom of the page.

Sources (6)

The specification points and sources behind this lesson.

  1. 1 IB Mathematics: applications and interpretation guide (first assessment 2021), AHL 1.14
  2. 2 IB Mathematics: applications and interpretation guide (first assessment 2021), AHL 1.15, AHL 4.19
  3. 3 IB Mathematics: applications and interpretation guide (first assessment 2021), AHL 3.14, 3.15, 3.16 and AHL 4.19
  4. 4 IB Mathematics: applications and interpretation guide (first assessment 2021), AHL 3.14 and AHL 3.16 with guidance and Connections
  5. 5 Mathematical Association of America, "Leonard Euler's Solution to the Königsberg Bridge Problem" (T. Paoletti), Convergence, https://old.maa.org/node/116597
  6. 6 Wikipedia, "Seven Bridges of Königsberg", https://en.wikipedia.org/wiki/Seven_Bridges_of_K%C3%B6nigsberg