Matrices: transformations and data
A matrix is a linear map — it moves the whole space at once — and its columns are where the basis vectors land.
A spreadsheet of students against subjects is a matrix. So is the weight table of a neural network layer, the covariance of a dataset, and a grayscale image. All of these really are just rectangular arrays of numbers, but the reading that unlocks linear algebra is different: a matrix is a function that takes a vector in and returns a vector out, moving the entire space at once.
A matrix is a verb, not a noun
The entries are not the point — the action is. A matrix bends, stretches, rotates and flips the plane. If you know where it sends the two basis vectors, you know where it sends every vector, because everything is a combination of those two.
Drag the four entries below and watch the grid deform. The two solid arrows are the columns — the destinations of the basis vectors and .
Move the four entries — the grid is the matrix
- det M
- 1.44
- area scale
- 1.44×
- M·(1,0)
- (1.0, -0.4)
- M·(0,1)
- (0.6, 1.2)
det > 0 — area is scaled by det, orientation preserved.
The two solid arrows are the columns of the matrix — where the basis vectors land. Because every point is a linear combination of them, knowing where the basis goes tells you where everything goes. The tinted square is the image of the unit square; its area is |det M|, which is why a zero determinant means information was destroyed, not merely rearranged.
The two readings of a matrix
A matrix can be read two ways, and fluency means being able to switch between them:
- Rows as measurements. Each of the rows is a weighting of the inputs. Multiplying computes inner products — a score per row. This is the reading of a classifier: row scores how much the input looks like class .
- Columns as directions. The columns are vectors in . The product is a weighted sum of those columns, with weights . This is the reading that explains span and rank.
The matrix–vector product costs : dot products, each over entries. A matrix–matrix product costs because each of the columns of is transformed separately — composition is just applying two maps in sequence.
Rank, span, and the column space
The set of all outputs as ranges over every input is the column space (or range) of . Its dimension is the rank. Rank is the amount of genuinely independent information the map can carry:
- An matrix has rank at most .
- Rank means distinct inputs give distinct outputs (the columns are independent; no information is collapsed).
- Rank means some non-zero is sent to zero. That input is in the null space, and it is unrecoverable.
This is why a determinant of zero matters. The determinant is the signed area (or volume) by which the map scales space; zero means the whole plane has been squashed onto a line. Volumes collapse, inverse maps stop existing, and a model built on such a matrix is not identifying its parameters.
Shapes are a contract
only makes sense when the number of columns of equals the number of entries of . In code this is where most shape bugs come from: an matrix times a length- vector is a length- vector, and . Write the shapes down before you write the expression.
Special matrices worth recognizing
- Identity — leaves every vector unchanged; the map that does nothing.
- Diagonal — stretches each axis independently; cheap to invert and multiply.
- Symmetric — the eigenvectors come out perpendicular with real eigenvalues, which is why covariance matrices are so well behaved.
- Orthogonal — a rotation or reflection; it preserves lengths and angles, so it never amplifies error.
- Positive definite — for every non-zero , ; these are the matrices that define genuine squared distances.
What matrices are not
Multiplying numbers is commutative; multiplying matrices is not. generally differs from , and that is not a technicality — it says that applying one transformation and then another depends on the order. A rotation followed by a stretch is a different map from the stretch followed by the rotation.
Illustrative vs real
The warp is drawn in 2-D so you can see it, but nothing above is about two dimensions. A transformer layer is a matrix over a few thousand coordinates; the determinant, rank and column-space statements hold verbatim. The picture is a lens, not a restriction.
Check yourself
Eduspheria wiki · Mathematics for AI, Linear algebra
0 / 5 answered
Where next: linear systems — when the equations have a solution, and what to do when they do not.