Skip to content

Advanced Linear Algebra

Linear transformations

Matrices as functions that move space

In Lesson 13 a matrix was a grid of numbers with a rule for multiplying. This lesson tells you what those numbers mean. A linear transformation is a function that takes the whole plane and re-draws it - but only in the tame, disciplined ways where grid lines stay straight, stay parallel, and stay evenly spaced, and the origin never budges. Every such re-drawing of 2-D space, no matter how twisted it looks, is captured by just four numbers: a matrix. Drag two arrows below and watch space itself bend to follow.

The one-line idea

A matrix is a verb, not a noun. It doesn't store data - it moves space. Tell me only where the two little arrows and land, and by "keep grid lines straight and evenly spaced" I can figure out where every other point in the plane has to go. Those two landing spots, written as columns, are the matrix.

Linear = grid lines stay straight and evenly spaced

Out of all the ways you could distort a rubber sheet, transformations earn the name linear when they obey two rules. First, they respect addition - transforming a sum is the same as transforming the parts and adding. Second, they respect scaling - stretching a vector then transforming equals transforming then stretching:

Geometrically these two algebraic rules cash out as a picture you can check by eye: lines stay lines (no curving), parallel lines stay parallel, evenly spaced tick marks stay evenly spaced, and - because - the origin is nailed in place. That last fact is why sliding the whole plane sideways (a translation) is not linear: it drags the origin along with it.

The matrix is just where and land

Here is the trick that makes those four numbers appear. Any vector is built from the two basis vectors and by scaling and adding: . Feed that through a linear map and the two rules let you pull the transformation inside the sum:

So the output is completely determined by the two landing spots and . Stack them as the columns of a matrix and you get exactly the machine from Lesson 13:

Four numbers pin down the fate of an infinite plane. In the demo, the two arrows you drag are the two columns: move 's tip and you rewrite the left column; move 's tip and you rewrite the right one.

Grid-warp: drag the tips of î and ĵ (or pick a preset). The two arrows are the two columns of the matrix.
îĵ
î - image of (1, 0)ĵ - image of (0, 1)sample shape (an “F”)unit square → area = |det|
[
1001
]
det = 1
Orientation preserved. Every area is scaled by 1× (shaded cell vs. dashed unit square).

The shaded cell is the image of the unit square; its area equals |det|. The dashed outline is the original square (area 1). Push ĵ around to the other side of î and the whole plane turns inside-out - the determinant goes negative and the little "F" reads backwards.

The aha: the determinant is that shaded area - with a sign

The number det is not bookkeeping. It is literally the area of the shaded parallelogram - the image of the unit square. If det , the transformation triples every area in the plane; if det , it halves them. And the sign carries the orientation: while stays counter-clockwise from the area is positive, but the instant you drag across to the clockwise side, the parallelogram's area sweeps through zero and comes out negative. That zero-crossing is the moment space folds over onto itself - and the "F" flips into its mirror image.

A small zoo of transformations

Every preset button above is a famous matrix. Once you read matrices as "where the basis lands," each one is memorable rather than mysterious:

Rotation and shear keep every area intact (); scaling multiplies area by ; reflection preserves area but reverses handedness (). To do one transformation then another, you compose them - and composition is exactly matrix multiplication: applying then is the single matrix . This is why Lesson 13 defined matmul the strange way it did, and why order matters (): spinning then stretching is not the same as stretching then spinning.

Determinant, kernel, and image

Because composing scales areas step by step, determinants multiply: . The really important case is : the shaded cell collapses to a line (or a point), so a whole line of vectors gets crushed onto the origin. That crushed set is the kernel (or null space), and the flattened output is the image (the column space from Lesson 13). When the kernel is just , no information is lost, and the map can be undone by the inverse matrix . When the transform is not invertible - you cannot un-flatten a pancake back into a plane.
import numpy as np

# columns are where î and ĵ land -- that IS the matrix
i_hat = np.array([1, 0])          # î stays put
j_hat = np.array([1, 1])          # ĵ slides right -> a shear
M = np.column_stack([i_hat, j_hat])   # [[1, 1], [0, 1]]

v  = np.array([2, 1])
Mv = M @ v                       # = 2*i_hat + 1*j_hat = [3, 1]

np.linalg.det(M)                 # 1.0  -> area unchanged, orientation kept

R = np.array([[-1, 0], [0, 1]])  # reflect across the y-axis
np.linalg.det(R)                 # -1.0 -> orientation flipped, space inside-out
The same idea in NumPy

Check yourself

A transformation's matrix has determinant -2. Applying it must:

Every linear transformation is forced to leave which point exactly where it is?

Recall: what the two columns of a transformation matrix mean, and what the size and sign of its determinant tell you.

Try to state it, then check.

Lock it in

  • A linear transformation redraws the plane keeping grid lines straight, parallel, and evenly spaced, with the origin nailed in place - which is why a translation is not linear.
  • The columns of its matrix are where the basis vectors land: , so .
  • The determinant is the signed area of the image of the unit square: is the area-scaling factor and a negative sign flips orientation.
  • collapses space onto a line (a nonzero kernel), so the map loses information and is not invertible.
  • Doing one transformation then another is matrix multiplication - apply then is - which is why order matters and .

Primary source

The single best way to feel a matrix as motion is 3Blue1Brown's Essence of Linear Algebra - the chapters on linear transformations and the determinant are the visual origin of this whole lesson. For the rigorous development (with free lectures, notes, and exams), work through Gilbert Strang's MIT 18.06 Linear Algebra, where column space, null space, and invertibility are built from the ground up.

Ask your teacher

This is the hidden shape of deep learning. Every layer of a neural network (Lesson 20) is a linear transformation - a matrix warping space - followed by a non-linear squish (the activation) that curves the grid lines the matrix kept straight. Likewise every Q/K/V projection (Lesson 32) is three such matrices reshaping each token's vector before attention compares them. Ask me why the non-linear squish is essential (stack pure linear maps and you only ever get one linear map back), how a "tall-then-wide" pair of matrices lets a layer project into a bigger space and back, or what the determinant of a weight matrix tells you about whether a network layer can be inverted.