What a matrix is
A matrix is a rectangular grid of numbers, described by its shape: an m × n matrix has m rows and n columns. On its own it is just a table. Its power is what it does, and the cleanest way to see that is to read a matrix by its columns.
The most useful first fact: the columns of a matrix are vectors, and multiplying the matrix by a vector builds a linear combination of those columns. Hold onto that — it turns the strange multiplication rule below into something obvious.
Adding and scaling matrices
These are exactly what you would guess. To add two matrices of the same shape, add matching entries. To scale a matrix, multiply every entry by the scalar. Two matrices of different shapes cannot be added at all.
Nothing surprising happens here because addition and scaling are still the only two operations in play — a matrix is, in this respect, just a vector written in a rectangle.
Matrix × vector: the operation that matters
Multiplying a matrix by a vector produces a new vector. The rule: each entry of the result is the dot product of a row of the matrix with the vector.
But the deeper reading is by columns. For a 2×2 matrix with columns c₁ and c₂, the product with [x, y] is x·c₁ + y·c₂ — a linear combination of the columns, weighted by the components of the input. This is why matrices and linear combinations are the same story told twice.
Matrix × matrix: do one thing, then another
Multiplying two matrices is multiplying the first by each column of the second, in turn. Entry (i, j) of the product is the dot product of row i of the left matrix with column j of the right.
The shapes must line up: an (m × n) times an (n × p) gives an (m × p) — the inner numbers must match, and they vanish. The single most important warning in the whole topic: matrix multiplication is not commutative. AB and BA are usually different, and often only one of them is even a legal shape.
AB ≠ BA, and it is not a quirk
In the next lesson a matrix becomes a transformation — a rotation, a stretch. AB then means "do B, then A". Rotating and then stretching is genuinely not the same as stretching and then rotating, so of course the matrices differ. The order rule is geometry, not bookkeeping.
The identity, and special shapes
The identity matrix I has 1s down the diagonal and 0s elsewhere. It is the "do nothing" matrix: I·v = v and A·I = A. It plays the role that 1 plays for ordinary numbers.
A square matrix has as many rows as columns — only square matrices can have inverses or eigenvalues later. The transpose Aᵀ flips a matrix across its diagonal, turning rows into columns; it appears whenever dot products and matrices meet.
A worked example
Let A = [[1, 2], [0, 3]] and v = [4, 1]. Compute A·v, then A·A.
- A·v: top row [1, 2]·[4, 1] = 4 + 2 = 6; bottom row [0, 3]·[4, 1] = 0 + 3 = 3.Each output entry is a row of A dotted with v.
- So A·v = [6, 3].Equivalently 4·[1,0] + 1·[2,3] = [4,0]+[2,3] = [6,3] — the column reading agrees.
- A·A: multiply A by each column of A. First column [1,0] → [1, 0]; second column [2,3] → [1·2+2·3, 0·2+3·3] = [8, 9].Column j of the product is A times column j of the right matrix.
- So A·A = [[1, 8], [0, 9]].Assemble the two output columns side by side.
A·v = [6, 3] and A² = [[1, 8], [0, 9]]. Reading by columns turned both products into familiar linear combinations.