Lesson overview
Use matrix operations in computing contexts such as graphics, data and networks.
Starter: make the model explicit
Before reading the worked example, write down the objects involved, the claim being made and the notation you expect to use. This prevents the common error of calculating before modelling.
Learning objectives
- Add compatible matrices.
- Multiply matrices where dimensions permit.
- Connect matrix operations to a computing application.
Learning outcomes
- By the end of this lesson, you can add compatible matrices.
- By the end of this lesson, you can multiply matrices where dimensions permit.
- By the end of this lesson, you can connect matrix operations to a computing application.
Key vocabulary
What this lesson is about
Matrix operations include addition, scalar multiplication and matrix multiplication. Each operation has dimension rules that decide whether it is valid.
In computing, matrices can store images, graphs, transformations, transition systems and datasets. For an adjacency matrix A, entries of A² can count or reveal two-step paths through a graph, so multiplication has a structural meaning beyond arithmetic.
Understanding the operation means understanding both the calculation and the model it represents.
Terms, acronyms and named methods
These are the phrases and named techniques used in this lesson. Read this section before the worked example so the notation and examples have a clear meaning.
Formal notation and definitions
How to read the symbols
Use matrix dimension rules to decide which operations are valid. The model should explain what the rows and columns represent.
Degree-level reasoning
Vectors and matrices encode structure. The dimensions, units and component meanings are part of the model, not incidental presentation.
A correct matrix calculation should also say what the transformed vector or product represents.
Do not stop at a correct-looking answer. State why the method is valid, whether the result depends on a hidden assumption, and what would count as a counterexample.
Worked formal model
This section shows the model, notation, calculation and interpretation as one worked answer. The notation is part of the reasoning, not decoration.
1. Context and objects
An adjacency matrix stores graph connections, and matrix reasoning can reveal paths through a network.
Objects: matrices A and B, their dimensions, corresponding entries for addition, rows/columns for multiplication, and adjacency-matrix entries for path counts.
Model cue: Use an adjacency matrix for a small directed graph. Rows represent starting vertices and columns represent destination vertices.
2. Mathematical working
Plain text version
A = [[1, 2], [0, 1]], B = [[3, 1], [4, 2]] A + B = [[4, 3], [4, 3]] AB = [[11, 5], [4, 2]] Adjacency C = [[0,1,1], [0,0,1], [0,0,0]] gives C^2[1,3] = 0*1 + 1*1 + 1*0 = 1 two-step route
3. How to read the working
- Check the dimensions first. Addition needs matrices of exactly the same size; multiplication needs the number of columns of the first matrix to equal the number of rows of the second.
- For addition, work entry by entry: the top-left entry of A + B is the top-left entry of A plus the top-left entry of B, and so on.
- For multiplication, use row-by-column products. The top-left entry of AB is row 1 of A dotted with column 1 of B.
- For an adjacency matrix C, read (C²)ij as a two-step path count from vertex i to vertex j. This is why multiplication has a computing meaning, not just an arithmetic procedure.
- Interpret the operation. Addition combines matching measurements; multiplication composes transformations or relationships.
4. Computing meaning and check
Matrix addition combines like-position data, while matrix multiplication composes relationships or transformations. The same numbers can support different computing meanings depending on the operation.
Now check: Add two compatible 2 by 2 matrices by entries. Then use a small adjacency matrix to compute one entry of A^2 and interpret it as a two-step path count.
Worked example
From scenario to formal reasoning
Scenario: An adjacency matrix stores graph connections, and matrix reasoning can reveal paths through a network.
Method: Use the definitions and notation introduced above, then state what the result means in this computing scenario.
Reveal model answer
For matrix addition, add corresponding entries: [[1, 2], [0, 1]] + [[3, 1], [4, 2]] = [[4, 3], [4, 3]]. For multiplication, row-by-column gives [[1, 2], [0, 1]][[3, 1], [4, 2]] = [[11, 5], [4, 2]]. If A is an adjacency matrix, the entry (A^2)ij counts two-step routes from vertex i to vertex j, so multiplication composes relationships rather than simply combining matching entries.
Worked solution structure
How a strong answer should be written
- Define: State the domain and the objects under discussion. For this lesson, begin from Matrix addition requires equal dimensions.
- Apply: Use the relevant definition from vectors and matrices; do not rely on the diagram, wording or intuition alone.
- Check: Test a boundary case, counterexample candidate or representation limit.
- Conclude: Write one sentence that connects the formal result back to the computing scenario.
Common misconception
A common mistake is assuming matrix multiplication is commutative. In general, AB and BA are different or one may not even be defined.
Guided practice
- Add two compatible 2 by 2 matrices entry by entry and name what each entry represents.
- Multiply A = [[0,1],[1,0]] by itself and interpret the result as two-step movement in a two-node graph.
- Explain why AB and BA may answer different computing questions.
- Use an adjacency matrix to count whether there is a two-edge path between two vertices.
Quick checks
1. In an adjacency matrix, what can A² reveal?
2. Why is AB generally not the same as BA?
Digital exam practice
Example exam task
For adjacency matrix C = [[0,1,1],[0,0,1],[0,0,0]], calculate (C²)₁,₃ and explain how matrix multiplication reveals two-step paths. Contrast this with matrix addition.
Notation toolkit
Means: entry-by-entry matrix addition
How to use: Use it only when matrices have the same dimensions.
Means: matrix multiplication by row-column products
How to use: Use it to compose transformations or relationships.
Means: the i,j entry of A squared
How to use: Use it for two-step path counts in an adjacency matrix.
What a good answer is expected to show
A strong answer for this lesson defines matrices A and B, their dimensions, corresponding entries for addition, rows/columns for multiplication, and adjacency-matrix entries for path counts, applies the vectors and matrices method with visible working, and finishes by interpreting the result in the computing scenario.
How to solve it
- Check the dimensions first. Addition needs matrices of exactly the same size; multiplication needs the number of columns of the first matrix to equal the number of rows of the second.
- For addition, work entry by entry: the top-left entry of A + B is the top-left entry of A plus the top-left entry of B, and so on.
- For multiplication, use row-by-column products. The top-left entry of AB is row 1 of A dotted with column 1 of B.
- For an adjacency matrix C, read (C²)ij as a two-step path count from vertex i to vertex j. This is why multiplication has a computing meaning, not just an arithmetic procedure.
- Interpret the operation. Addition combines matching measurements; multiplication composes transformations or relationships.
Model answer
Reveal model answer
For C = [[0,1,1],[0,0,1],[0,0,0]], the entry (C²)₁,₃ is row 1 of C dotted with column 3 of C: 0·1 + 1·1 + 1·0 = 1. This means there is one two-step route from vertex 1 to vertex 3. Matrix addition would combine matching edge data; multiplication composes relationships.
Practise next
- Add two compatible 2 by 2 matrices entry by entry and name what each entry represents.
- Multiply A = [[0,1],[1,0]] by itself and interpret the result as two-step movement in a two-node graph.
Self-marking criteria
- States what rows and columns represent.
- Uses row-by-column multiplication.
- Interprets an A² entry as a count or existence of two-step paths.
- Explains why addition answers a different question.
- Mentions that AB need not equal BA.
Extension
Change one assumption in the worked scenario and decide whether the same method still applies. If it does not, name the exact point where the reasoning breaks.
Study route
Save one clean worked answer from this lesson. Include the problem statement, notation, working, final answer and a short note explaining the computing meaning of the result.
Next lesson: Counting Principles and the Product Rule.
