A matrix is a rule that moves every point of the plane at once. Watch the grid and its two arrows glide to their new place.
A matrix moves the plane
The columns of A are where the unit arrows e_1 and e_2 land.
Before the matrix acts: the square grid, and the unit arrows e_1 and e_2.
Describe this picture
One panel: a faint square grid with the origin at its centre, and two unit arrows from the origin, pointing right and pointing up, with the unit square between them shaded. After a second’s rest the grid glides, over 5 s, from its square starting place to the place the matrix sends it, turning a little and stretching at the same time, and holds there. The arrow rides out to and to , and the shaded square becomes a parallelogram. The grid lines stay straight and evenly spaced the whole time, and the origin never moves. Readouts give the coordinates of the two arrow tips. When the clip has finished, a dashed ring marks each tip: either can be dragged, or moved with the arrow keys, in steps of half a unit, and the whole grid follows; the matrix is kept in the link.
Where the two arrows land
A point in the plane, say , is a set of instructions: take 3 steps along the first unit arrow and 2 steps along the second. You met this reading in Vectors and Linear combinations and span. I’ll call the two unit arrows and . A bold with a number under it always means one of these arrows on this site, never the number .
So what happens if I move the two arrows? Every point is built from them, so every point has to move with them. The point is still “3 steps along the first arrow and 2 along the second”, only the arrows are different now.
That is the whole idea of a matrix. It is the table of where the two arrows go. In the picture at the top of the page, lands on and lands on . I write those two landing places side by side, as columns:
The first column is where goes. The second column is where goes. I’ll call the columns and . To save space I write a column of numbers on one line, as ; it still means a column.
A common slip is to read the rows as the landing places. The first row here is , but lands on , the first column. I chose a matrix whose rows and columns differ, so the slip cannot go unnoticed.
After the clip, drag the tip of either arrow. The whole grid follows it, because every point is built from the two arrows.
Same steps, new arrows
Now follow one point. The point starts as 3 steps of followed by 2 steps of . Watch the same steps being taken with the new arrows.
The point rides along
x = (3, 2) as steps along e_1 and e_2, then the matrix moves the plane.
The point x = (3, 2) means 3 steps of e_1, then 2 steps of e_2.
Describe this picture
The square grid with the point drawn as a chain of arrows, tip to tail: three copies of , then two copies of . The grid then moves as in the first picture, and the chain moves with it: it becomes three copies of followed by two copies of , and it ends at . Then, in a corner of the panel, the two row sums appear one after the other, and . The picture has no control.
The chain keeps its instructions, 3 steps then 2 steps, and only the arrows change. So the point lands at
This is what “a matrix times a vector” means. For a vector ,
The numbers in are the weights, and the columns of are what they weigh. It is the linear combination of Linear combinations and span, with the columns as the arrows.
One row at a time
There is a second way to get the same answer, and it is the one most people compute by hand. Look at the top number of the answer, 4. It came from in the first column and in the second. Those are the first row of , , multiplied entry by entry with and added up.
Multiply matching entries and add: that is the dot product of the row with , which Length and the dot product studies on its own. So each number that comes out is one row’s dot product with .
To write this for any matrix I need names for the entries. The entry in row and column is , and both count from 1: here , , and . Entry of the answer is
where is the number of columns. The columns picture and the rows picture add up the same products, only in a different order. So they always agree.
What makes it linear
Watch the first picture again and look at the grid lines. They stay straight. Lines that were parallel stay parallel. Lines that were evenly spaced stay evenly spaced. And the origin stays where it is. That is what linear means for a map of the plane, and the column rule explains all of it.
The origin first. The point takes no steps along either arrow, so wherever the arrows go, it stays put:
Now a grid line. Its points are , , and so on, evenly spaced along a step . The column rule adds weights, so the matrix sends them to , , : again evenly spaced, along the new step . Every grid line in the same direction has the same step, so they stay parallel. Both facts come from one rule, which holds for any vectors , and numbers , :
The unit square shows it too. Its corners are , , and . They land at , at , at and at . That is the parallelogram in the first picture.
Numbers in, numbers out
A matrix does not have to be square. Its shape is written rows × columns: an matrix has rows and columns. There is one column for each number that goes in, so it takes numbers in. There is one row for each number that comes out, so it gives numbers out.
Here is a matrix:
It sends to and to , two arrows in space. So the point goes to . Two numbers go in and three come out. The whole flat plane lands on a tilted flat sheet in space, where the third number is the sum of the first two.
Worked example
Take and .
- By columns. .
- By rows. First row: . Second row: . The same .
- The second arrow. Where does land? It is , so it lands on the second column, .
- Another point. . By rows: and .
- The origin. . A matrix never moves the origin.
- Predict first. A matrix has columns and . Where does go? Guess from the picture of the two arrows, then check: .
- Shapes. The matrix above takes 2 numbers to 3: goes to .
Where you’ll meet this
A stereo crossfeed, which makes headphones sound more like speakers, mixes a little of each channel into the other. With the matrix , a sound on the left channel only, , comes out as : the first column.
A 3-D graphics program moves a model by applying one matrix to every corner of it, many times a second. Every layer of a neural network starts with a matrix times a vector. A phone turns the readings of its motion sensor with a matrix, so that “up” for the sensor matches “up” on the screen.
In signal processing · convolution
A filter in signal processing is a matrix too. Stack shifted copies of the impulse response as the columns of a matrix , and filtering the samples is , the column rule of this page. The page Discrete convolution shows that view. One difference in counting: matrix entries count from 1, while samples count from 0, so the vector’s entry is the sample . A coefficient with one subscript, like , is a filter coefficient there; two subscripts, , always mean a matrix entry.
Reference card
| Quantity | Formula | Notes |
|---|---|---|
| Unit arrows | , | bold, never the number |
| Columns | is where lands | read the columns, not the rows |
| By columns | the entries of are weights | |
| By rows | one dot product per row | |
| Entries | : row , column | both count from 1 |
| Linear | straight, parallel, evenly spaced lines | |
| Origin | never moves | |
| Shape | : numbers in, out | rows × columns |