Math for CS and ML · 15 min

Matrices move space

Read a matrix by its columns: where î and ĵ land decides where every vector goes, and the determinant scales area.

01Why it matters

A grid of numbers that moves the whole plane

A 2×22 \times 2 matrix is four numbers. It is easy to learn the rule for multiplying it by a vector and never see what it does. Here is what it does: it picks up the entire plane and moves it, stretching, turning, shearing or flipping it, while keeping every grid line straight.

By the end of this lesson you will be able to look at a matrix like [2101]\begin{bmatrix} 2 & 1 \\ 0 & 1 \end{bmatrix} and picture its effect before doing any arithmetic.

02Key parts

The pieces you will see

î and ĵ
The basis vectors (1,0)(1, 0) and (0,1)(0, 1): one step right, one step up. Every vector is built from them.
v = x·î + y·ĵ
A vector's coordinates are a recipe: xx steps along î, then yy steps along ĵ.
columns
The first column of a matrix is where î lands; the second is where ĵ lands.
det A
The determinant, ad−bcad - bc: how much the matrix scales areas, with a minus sign if it flips the plane over.

03See it work

Watch a matrix move the grid

First î lands on the first column, then ĵ on the second, then the whole grid follows. Step with → and read each line.

Because every vector is xx steps along î plus yy steps along ĵ, it must land on xx steps along where î went plus yy steps along where ĵ went:

A[xy]=x[ac]+y[bd]A\begin{bmatrix} x \\ y \end{bmatrix} = x \begin{bmatrix} a \\ c \end{bmatrix} + y \begin{bmatrix} b \\ d \end{bmatrix}

04Predict

Your turn: where does it land?

Before each step, predict where î, ĵ and vv will land under a quarter turn, and what happens to the area.

Make 4 predictions: step forward and answer each question before the next step plays.

0 of 4 made

05Try it

Drag the columns yourself

Drag the tips of î and ĵ (or focus one and use the arrow keys) and watch the grid, AvAv and det⁡A\det A follow. Try these:

  • Put ĵ on top of î's line. The plane collapses onto a line and det⁡A=0\det A = 0.
  • Swap the two arrows' places. The grid flips over and the determinant turns negative.
  • Make a shear: leave î at (1,0)(1, 0) and move ĵ to (1,1)(1, 1). The square leans, but its area stays 1.

06Check yourself

Check yourself

  1. Question 1 of 4

    A = [[3, 0], [1, 2]]. Where does î = (1, 0) land?

    Your answer comes back in Review in a few days, so it sticks.

  2. Question 2 of 4

    A sends î to (2, 0) and ĵ to (1, 1). Where does v = (1, 2) land?

  3. Question 3 of 4

    A matrix has determinant −2. What does it do to the unit square?

  4. Question 4 of 4

    Which matrix squashes the plane onto a line?

07Explain it back

Say it in your own words

Why does knowing where î and ĵ land tell you where every vector goes, and what does the determinant add?

08Recap

What to remember

  • A matrix moves the whole plane; its columns are where î and ĵ land.
  • A(xı^+yȷ^)=x(Aı^)+y(Aȷ^)A(x\hat{\imath} + y\hat{\jmath}) = x(A\hat{\imath}) + y(A\hat{\jmath}): knowing two arrows tells you everything.
  • det⁡A=ad−bc\det A = ad - bc scales area; negative flips the plane, zero squashes it and can't be undone.
  • Next: eigenvectors, the special directions a matrix only stretches.
Back to path