Vectors and matrices
On this page
The instruction "go 3 steps east and 4 steps north" is two numbers that belong together. A vector is such a list of numbers, drawn as an arrow with a length and a direction. A matrix is a table of numbers that turns one vector into another, and it is how a machine stretches, turns and combines quantities.
See it
A matrix has the rows 2, 0 and 0, 3. It turns the vector (2, 1) into (4, 3). Now the top right entry changes from 0 to 1. What happens to the output?
The dark arrow is the input and never moves. The gold arrow is what the matrix makes of it. The slider changes one of the four entries. With 0 there, the matrix only stretches: 2 times along x and 3 times along y.
The idea
A vector holds quantities that have no meaning apart: the two parts of a force, the three readings of a tilt sensor, the temperatures of four rooms. Its length is found as for the long side of a right angle triangle: the vector (3, 4) has length √(9 + 16) = 5.
A matrix A turns an input vector x into an output vector y, written y = A x. Each row of the matrix makes one number of the output: multiply each entry of the row by the matching number of x, then add.
y2 = c x1 + d x2
a and b are the first row of the matrix, c and d the second row, x1 and x2 the numbers of the input vector
Depending on its entries, a matrix stretches an arrow, turns it, flips it or flattens it. A rotation matrix is the kind that only turns. One limit: a matrix keeps straight lines straight and leaves the zero vector at zero, so it cannot shift or bend.
One worked number
The matrix A has the rows 2, 0 and 0, 3. The input vector is x = (2, 1). What is the output y = A x, and how long is it?
Show the worked solution, 3 steps
- Use the first row
y1 = 2 × 2 + 0 × 1 = 4.
- Use the second row
y2 = 0 × 2 + 3 × 1 = 3. The output is y = (4, 3).
- Find the length
√(42 + 32) = √25 = 5. The input had length √5 = 2.24, so the arrow is longer and it also points in a new direction. The figure opens on this case.
The mistake to avoid
A second trap: the order of two matrices matters. B A means that A acts first and B second, and A B is in general a different result.
Check yourself
A matrix has the rows 1, 2 and 3, 4. What does it make of the vector (1, 1)?
A matrix has the rows 1, 0 and 0, 0. It acts on the vector (5, 2). What is the output, and can you find the input again from the output alone?
Matrix S stretches x by 2 (rows 2, 0 and 0, 1). Matrix T turns an arrow by 90° counterclockwise (rows 0, −1 and 1, 0). Start with the arrow (1, 0). Is "stretch, then turn" the same as "turn, then stretch"?
Where you meet it
- A vibration or tilt sensor on a machineEach reading is a vector of three numbers, one for each axis of the sensor.
- A robot armEach joint is one matrix, and the position of the tool is the product of all of them.
- A weighing platform on four load cellsA calibration matrix combines the four readings into one weight and the place where the load sits.
- A model fitted to dataEach layer of the model is a matrix times a vector, repeated thousands of times for one prediction.
- A vector is a list of numbers that belong together, drawn as an arrow with a length and a direction.
- A matrix turns one vector into another: y = A x.
- Each row of the matrix, times the whole vector, makes one number of the output.
- The order of two matrices matters. B A means A first.
Discussion
No comments yet. Questions, results from your own build, a better way to explain it: all welcome.
My notes on this page
Kept on this device only. Nothing is sent anywhere.
Tip: select words in the lesson, or tap a figure or an equation, to put a note right there.
Notes on earlier wording
The lesson has changed and these words are no longer in it. Your notes are kept, with the words you chose.