Lecture 02
Matrices as Transformations
A matrix is a machine that moves every point of space at once. Its columns say everything about it, and some machines destroy information.
47 slides / MIT 18.06, Lectures 1–3 / Strang §1.3–1.4, §8.1

The idea in one sentence
A matrix is a machine: a vector goes in, a moved vector comes out, and the columns of the matrix tell you everything the machine will ever do.
One multiplication, two readings
Start with the numbers:
There are two ways to compute , and they teach two different things.
Read by columns. Then is the move from Lecture 1, a linear combination, with the entries of as the scalars:
Read by rows. Then each entry of the answer is a dot product: the first entry is , and so on down.
One product, two readings. The orange columns get mixed. The green row gets dotted with . Both land on the same blue answer, always.
Both readings matter, for different reasons. The row reading is how you compute by hand. The column reading answers the deeper question: since is always a mix of the columns, the outputs a matrix can produce are exactly the span of its columns. Reachability, the question Lecture 1 ended on, is a question about columns.
A machine that moves every point at once
Now change the point of view. Fix and let vary. The matrix becomes a function: feed it any vector, it returns a moved vector. To see what the machine does, you do not need to test every input. Two are enough. Watch and :
The columns of a matrix are the landing spots of the basis vectors. Every other input follows along, because forces . Grid lines stay straight, parallel lines stay parallel, and the origin stays put. That is what the word linear means, drawn.
The machine with columns and . The orange dashed unit square lands on the green parallelogram, and the blue arrows are where the two basis vectors go. Watch the corners: they are the landing spots.
Every 2 by 2 matrix is one of these machines. Rotations, shears, reflections, scalings: each is four numbers, and the four numbers are just the two landing spots written side by side. Try it:
det A = ad − bc = 2.0
The orange arrow is where e₁ lands, the green arrow is where e₂ lands, and the yellow patch is where the unit square lands. Press Collapse and watch the plane flatten to a line: that is a singular matrix.
The machine view is what AI runs on. A language model stores words as vectors, and in word2vec those vectors did combination arithmetic: king minus man plus woman landed near queen. Subtract one vector, add another, and you have walked from one word to another.
Four words placed by hand in two invented dimensions, royal and female, so the arithmetic can be drawn. Start at king, subtract man in orange, add woman in green, and land on the blue dot. Queen sits one short dashed miss away. The dashed arrow from man to woman is the same step, which is the whole reason the walk works. Real embeddings have hundreds of dimensions and never close exactly, and that gap is why the result is always stated as lands near queen.
The operations inside every neural network layer are the two moves of this lecture, a matrix multiplication and an addition, repeated at scale.
The machine that destroys information
Here is a machine with a story. Three cities sit on a ring road, with altitudes . The machine reports the climbs between them, one number for each stretch of road:
The cyclic difference machine. The blue arrows are the three climbs it reports. Walk the ring and every climb you gain you must give back: the three outputs always cancel.
Now raise all three cities by one meter. The climbs do not change: applied to gives . Two different inputs, one output. The machine cannot see the direction , and what a machine cannot see, no one can recover from its output. destroys information, and a machine that destroys information cannot be undone. Matrices like this are called singular.
Singularity also limits the outputs. Add the three rows of and everything cancels, so any output this machine can produce must satisfy . That one equation sorts every right-hand side into one of two endings:
- sums to zero. Solvable, with altitudes , and once you have one answer, adding gives another. Infinitely many solutions.
- sums to six. No altitudes on earth produce these climbs. No solution.
Walking the ring shows why.
Walk the ring and add the climbs as you go. On the left they cancel, so you arrive back at the altitude you started from. On the right they add to six, so the walk ends six meters above its own starting point. The pink bar is the contradiction, and no set of altitudes can close it.
A singular machine never gives the clean ending: exactly one answer. The machines that do, for every , are called invertible, and telling the two kinds apart quickly is where this course goes next.
import numpy as np
A = np.array([[1., 2.], [3., 4.], [5., 6.]])
x = np.array([7., 8.])
print(A @ x) # [23. 53. 83.]
print(7 * A[:, 0] + 8 * A[:, 1]) # the same: Ax mixes the columns
C = np.array([[1., 0., -1.], [-1., 1., 0.], [0., -1., 1.]])
print(C @ np.array([1., 1., 1.])) # [0. 0. 0.] the invisible direction
print(np.linalg.det(C)) # 0.0 singular
b = np.array([1., 2., 3.]) # climbs that don't cancel
best = np.linalg.pinv(C) @ b # the best possible attempt
print(C @ best - b) # [-2. -2. -2.] misses: no solution
b = np.array([1., 1., -2.]) # climbs that cancel
print(C @ (np.linalg.pinv(C) @ b)) # [ 1. 1. -2.] reached exactlyimport torch
A = torch.tensor([[1., 2.], [3., 4.], [5., 6.]])
x = torch.tensor([7., 8.])
print(A @ x) # tensor([23., 53., 83.])
print(7 * A[:, 0] + 8 * A[:, 1]) # the same: Ax mixes the columns
C = torch.tensor([[1., 0., -1.], [-1., 1., 0.], [0., -1., 1.]])
print(C @ torch.ones(3)) # tensor([0., 0., 0.]) invisible direction
print(torch.linalg.det(C)) # tensor(0.) singular
b = torch.tensor([1., 2., 3.]) # climbs that don't cancel
best = torch.linalg.pinv(C) @ b # the best possible attempt
print(C @ best - b) # tensor([-2., -2., -2.]) no solution
b = torch.tensor([1., 1., -2.]) # climbs that cancel
print(C @ (torch.linalg.pinv(C) @ b)) # tensor([ 1., 1., -2.]) reachedimport jax.numpy as jnp
A = jnp.array([[1., 2.], [3., 4.], [5., 6.]])
x = jnp.array([7., 8.])
print(A @ x) # [23. 53. 83.]
print(7 * A[:, 0] + 8 * A[:, 1]) # the same: Ax mixes the columns
C = jnp.array([[1., 0., -1.], [-1., 1., 0.], [0., -1., 1.]])
print(C @ jnp.ones(3)) # [0. 0. 0.] the invisible direction
print(jnp.linalg.det(C)) # 0.0 singular
b = jnp.array([1., 2., 3.]) # climbs that don't cancel
best = jnp.linalg.pinv(C) @ b # the best possible attempt
print(C @ best - b) # [-2. -2. -2.] misses: no solution
b = jnp.array([1., 1., -2.]) # climbs that cancel
print(C @ (jnp.linalg.pinv(C) @ b)) # [ 1. 1. -2.] reached exactlyimport tensorflow as tf
A = tf.constant([[1., 2.], [3., 4.], [5., 6.]])
x = tf.constant([[7.], [8.]])
print(A @ x) # [[23.] [53.] [83.]]
print(7 * A[:, 0] + 8 * A[:, 1]) # the same: Ax mixes the columns
C = tf.constant([[1., 0., -1.], [-1., 1., 0.], [0., -1., 1.]])
print(C @ tf.ones([3, 1])) # zeros: the invisible direction
print(tf.linalg.det(C)) # 0.0 singular
b = tf.constant([[1.], [2.], [3.]]) # climbs that don't cancel
best = tf.linalg.pinv(C) @ b # the best possible attempt
print(C @ best - b) # [[-2.] [-2.] [-2.]] no solution
b = tf.constant([[1.], [1.], [-2.]]) # climbs that cancel
print(C @ (tf.linalg.pinv(C) @ b)) # [[ 1.] [ 1.] [-2.]] reachedWhere this is going
You now know what a matrix does: it mixes its columns, it moves the whole space, and sometimes it flattens the space and cannot be undone. What you do not have yet is a procedure. Given a big system , how do you decide which ending you are in, and find fast? The answer is elimination, the algorithm inside every solver, and it is the next lecture.