write the coefficients in the same order (xx then yy) 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=bAx = b and use your GDC to find the exact price of one notebook.
£
Sort it
?Is each statement about 2×22 × 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?
Put the quantities in a matrix AA, the unknown prices in xx and the totals in bb, so Ax=bAx = b. If detA=0det A ≠ 0, multiplying on the left by A−1A⁻¹ gives every price at once: x=A−1bx = A⁻¹b.
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 vv is an eigenvector of MM if Mv=λvMv = λv: MM only scales it. The scale factor λλ is the eigenvalue.
Mn=PDnPMⁿ ≠ PDⁿP. Keep P−1P⁻¹ on the right, or the check at n=1n = 1 fails.
Calculate
?Use the formula for MnMⁿ from the previous example to find the element in row 1, column 1 of M4M⁴.
Number and algebra · matrices
Transition matrices and steady states
In a transition matrixTT, the element TijT_ij is the probability of moving from state jj to state ii, so each column adds to 1.
With a column state matrix s0s₀, the state after nn steps is sn=Tns0sₙ = Tⁿs₀.
A steady statess satisfies Ts=sTs = s with entries adding to 1: the eigenvector for eigenvalue 1.
For a regular chain (some power of TT has all entries positive), snsₙ tends to this steady state from any starting state.
Worked exampleNumber and algebra · matrices
A commuter's travel choices
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.
Two steps: Ts0=(0.70.3)Ts₀ = ( 0.7 ; 0.3 ), then T2s0=(0.610.39)T²s₀ = ( 0.61 ; 0.39 )
3
Steady state (bc)( b ; c ): Ts=sTs = s gives 0.3b=0.4c0.3b = 0.4c, with b+c=1b + c = 1
4
Solve: b=74b = 4/7, c=73c = 3/7
Answer
P(bus in 2 days)=0.61P(bus in 2 days) = 0.61; long-term P(bus)=74≈0.571P(bus) = 4/7 ≈ 0.571.
⚠️ Watch out
a TT whose rows add to 1 is the transpose of the IB convention and gives wrong answers with Tns0Tⁿ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?
The populations settle at the steady state ss with Ts=sTs = s, the eigenvector of T=(0.90.10.050.95)T = ( 0.9 , 0.05 ; 0.1 , 0.95 ) for eigenvalue 1. The flows balance when 0.1×city=0.05×country0.1 × city = 0.05 × country: one third in the city and two thirds in the country, whatever the starting 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
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×2 × the number of edges.
Term
Meaning
simple graph
no loops and no multiple edges between the same pair
complete graph KnKₙ
simple, every pair of the nn vertices adjacent
weighted graph
each edge carries a number (distance, cost, time)
directed graph
edges have directions; each vertex has an in degree and an out degree
connected
a route exists between any two vertices (directed: strongly connected if you can follow the arrows from any vertex to any other)
subgraph / tree
part of a graph / a connected graph with no cycles
Quick check
?How many edges does the complete graph K6K₆ have?
Graph theory · walks and adjacency matrices
Walks, trails, paths, Euler and Hamilton
Name
Rule
Closed version
walk
any sequence of adjacent edges
trail
no edge repeated
circuit
path
no vertex repeated
cycle
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 exampleGraph theory · walks and adjacency matrices
Is there an Eulerian trail?
Question
For the graph shown, with edges ABAB, ACAC, BCBC, BDBD, CDCD, CECE and DEDE, determine whether an Eulerian circuit or an Eulerian trail exists. If one does, write one down.
1
List the degrees: A=2A = 2, B=3B = 3, C=4C = 4, D=3D = 3, E=2E = 2 (sum 14, so 7 edges)
2
Count the odd vertices: BB and DD, exactly two, so no Eulerian circuit but an Eulerian trail exists
3
Start at one odd vertex and end at the other: BACBDCEDB A C B D C E D
4
Check: 7 edges, each used once
Answer
an Eulerian trail exists, for example BACBDCEDBACBDCED; there is no Eulerian circuit.
⚠️ Watch out
a trail must start and finish at the two odd vertices. Starting at AA 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
Adjacency matrixAA: entry aija_ij = number of edges from vertex ii to vertex jj.
The (i,j)(i, j)th entry of AkA^k = number of walks of length kk from ii to jj. For lengths up to kk, add the entries of A,A2,…,AkA, A², …, A^k.
A weighted adjacency table stores weights instead of 1s.
Transition matrixTT: TijT_ij = probability of moving from jj to ii, so column jj holds deg(j)11/(deg(j)) in each adjacent row and sums to 1.
Worked exampleGraph theory · walks and adjacency matrices
Counting walks with A3A³
Question
The graph has vertices PP, QQ, RR, SS and edges PQPQ, PRPR, QRQR, RSRS. Find the number of walks of length 3 from PP to RR.
1
Write the adjacency matrix in the order P,Q,R,SP, Q, R, S: A=0110101011010010A = ( 0 , 1 , 1 , 0 ; 1 , 0 , 1 , 0 ; 1 , 1 , 0 , 1 ; 0 , 0 , 1 , 0 )
Check by listing: PQPRPQPR, PRPRPRPR, PRQRPRQR, PRSRPRSR
Answer
4 walks of length 3.
⚠️ Watch out
walks may repeat vertices and edges, so PRPRPRPR counts. The (P,R)(P, R) entry of A2A² 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,ZV, W, X, Y, Z. A journey is a walk along routes. Use your GDC to find the number of journeys from VV to ZZ that use at most 3 flights.
?A random walker on the graph with edges PQPQ, PRPR, QRQR, RSRS moves at each step along one of the edges at its current vertex, each equally likely. It starts at PP. Using the transition matrix TT, find the probability that it is at RR after exactly two steps. Give your answer as a decimal.
Mission check
?Can you cross all seven bridges of Königsberg exactly once?
As a graph, the land masses are vertices with degrees 5, 3, 3 and 3. Every time you pass through a land mass you use two bridges, so only the start and finish can have an odd degree. Four odd vertices means no route crosses every bridge 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 nn vertices it has n−1n − 1 edges.
A spanning tree is a subgraph that is a tree containing every vertex. A minimum spanning tree (MST) has least total weight.
Algorithm
Method
Kruskal
List edges by weight. Add the smallest edge that does not form a cycle. Stop at n−1n − 1 edges.
Prim
Start at any vertex. Add the shortest edge from a vertex in the tree to one not yet in it.
Prim, table form
Cross out the new vertex's row; search the columns of all tree vertices for the smallest entry.
Worked exampleGraph theory · trees and algorithms
Kruskal's algorithm
Question
Use Kruskal's algorithm to find a minimum spanning tree for the network shown, and state its weight.
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 PP, to find the minimum total cost of connecting all five buildings.
P
Q
R
S
T
P
–
8
5
9
12
Q
8
–
4
7
6
R
5
4
–
10
11
S
9
7
10
–
3
T
12
6
11
3
–
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 exampleGraph theory · trees and algorithms
Four odd vertices
Question
For the network shown (total weight 47), find the length of the shortest route that starts and ends at AA and travels along every edge at least once.
1
Degrees: A=3A = 3, B=3B = 3, C=4C = 4, D=3D = 3, E=3E = 3, so the odd vertices are AA, BB, DD, EE
2
Pairing AB+DEAB + DE: 4+9=134 + 9 = 13 (DD to EE is shortest via CC: 5+45 + 4)
3
Pairing AD+BEAD + BE: 7+7=147 + 7 = 14 (BB to EE via CC: 3+43 + 4)
4
Pairing AE+BDAE + BD: 10+8=1810 + 8 = 18
5
Repeat the least pairing: 47+13=6047 + 13 = 60
Answer
60, repeating ABAB, DCDC and CECE.
⚠️ Watch out
use the shortest path, not the direct edge. The edge DEDE is 10, longer than D→C→E=9D → 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 AA. 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≤upperlower ≤ optimal ≤ upper.
Choosing: every edge → Chinese postman; every vertex once and back → travelling salesman; connect all vertices cheaply → MST.
Worked exampleGraph 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 AA, and a lower bound by deleting AA. | | 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
Nearest neighbour from AA: A→E→C→B→D→AA → E → C → B → D → A, with times 8, 11, 3, 7, 19
Add the two shortest edges from AA: AE=8AE = 8 and AC=10AC = 10, giving 21+18=3921 + 18 = 39
Answer
39≤optimal time≤4839 ≤ optimal time ≤ 48 minutes.
⚠️ Watch out
the nearest neighbour tour must return to AA. Forgetting DA=19DA = 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?
Find the junctions with odd degree. With none, the shortest route is just the total length. Otherwise pair the odd junctions up in the way that gives the least total shortest-path length, and walk those paths twice: every junction becomes even, so one closed route covers every street.
Recap
Big ideas
(m×n)(n×p)(m × n)(n × p) gives m×pm × p, row by column; matrix multiplication is associative and distributive but not commutative.
For a 2×22 × 2 matrix, detA=ad−bcdet A = ad − bc and A−1=ad−bc1(d−c−ba)A⁻¹ = 1/(ad − bc)( d , −b ; −c , a ); if detA=0det A = 0 there is no inverse.
A linear system is Ax=bAx = b, solved by x=A−1bx = A⁻¹b (by hand for 2×22 × 2, GDC for larger).
With distinct real eigenvalues, M=PDP−1M = PDP⁻¹ and Mn=PDnP−1Mⁿ = PDⁿP⁻¹.
In a transition matrix the columns are "from" and add to 1; sn=Tns0sₙ = Tⁿs₀, and the steady state solves Ts=sTs = s (eigenvalue 1).
Degree = edges at a vertex; the degree sum is twice the number of edges. KnKₙ has 2n(n−1)(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)(i, j)th entry of AkA^k counts walks of length kk from ii to jj; in a transition matrix, TijT_ij is the probability of moving from jj to ii.
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 nn vertices has n−1n − 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. 🎉
Mission 1Three receipts, three unknown prices: how does one matrix find them?
Mission 2The city loses 10% a year and gains 5% of the country. Final split?
Mission 3Can you cross all seven bridges of Königsberg exactly once?
Mission 4A postman must walk every street. What's the shortest route?
3 IB Mathematics: applications and interpretation guide (first assessment 2021), AHL 3.14, 3.15, 3.16 and AHL 4.19
4 IB Mathematics: applications and interpretation guide (first assessment 2021), AHL 3.14 and AHL 3.16 with guidance and Connections
5 Mathematical Association of America, "Leonard Euler's Solution to the Königsberg Bridge Problem" (T. Paoletti), Convergence, https://old.maa.org/node/116597