Linear Algebra / Unit 3, Matrices / Topic 3.1
Unit 3. Matrices
A matrix is a table of numbers. This topic shows that a matrix is also a rule that takes a vector and gives back a new vector. Seen this way, a matrix moves the whole plane: it can stretch the plane, turn it, flip it, or slant it.
You need Topics 1.1 and 2.1 for this topic.
A matrix is a rectangular table of numbers. This matrix has 2 rows and 2 columns:
A = 2101Read the matrix by its columns. The first column is the vector (2, 0), and the second column is the vector (1, 1). In this topic the columns matter more than the rows.
To multiply a matrix by a vector, use the components of the vector as the coefficients of a linear combination of the columns.
2101 32 = 3 20 + 2 113 times the first column plus 2 times the second column2101 32 = 6 + 20 + 2add the matching components2101 32 = 82the resultThe first component of the vector multiplies the first column. The second component multiplies the second column. Then the results are added.
There is also a quick rule for each entry of the answer. Take one row of the matrix and form its dot product with the vector:
abcd xy = ax + bycx + dyFor the example, the top entry is (2)(3) + (1)(2) = 8, and the bottom entry is (0)(3) + (1)(2) = 2. Both rules give the same answer.
This product is the column picture from Topic 2.1. The system 2x + y = 8 and y = 2 is the single equation Ax = b, with x = (x, y) and b = (8, 2). A system of linear equations is one matrix equation.
The product Ax takes a vector x and gives a new vector. A rule that takes an input and gives an output is a function. A matrix is a function whose inputs and outputs are vectors. Such a function is also called a map or a transformation.
To find what a map does, find where the map sends the two basic vectors from Topic 1.1, i = (1, 0) and j = (0, 1).
2101 10 = 20 2101 01 = 11The first column of a matrix is where the map sends i. The second column is where the map sends j. A matrix is a record of where the two basic vectors go.
This is enough to know where all other vectors go. The vector (3, 2) is 3i + 2j, and the map sends it to 3 times the first column plus 2 times the second column. The map moves the grid of the plane along with i and j.
Try it: a matrix moves the plane
The blue arrow is where the map sends i, and the red arrow is where the map sends j. Drag their tips to change the matrix, or choose a map below. The purple arrow is an input vector x, and the green arrow is the output Ax. Press Play to watch the plane move from its starting position.
| Map | Matrix | What it does |
|---|---|---|
| Identity | 1001 | Leaves each vector where it is |
| Stretch | 2001 | Doubles the x component |
| Rotation by 90° | 0−110 | Turns each vector counterclockwise by 90° |
| Reflection | 100−1 | Flips the plane across the x axis |
| Shear | 1101 | Slides each point sideways by its height |
| Projection | 1000 | Drops each point straight onto the x axis |
To write the matrix for a map, decide where i goes and where j goes, and write those two vectors as the columns. For a rotation by 90° counterclockwise, i = (1, 0) turns to (0, 1), and j = (0, 1) turns to (−1, 0). These are the two columns of the rotation matrix in the table.
A rotation by an angle θ sends i to (cos θ, sin θ) and sends j to (−sin θ, cos θ). The matrix is
cos θ−sin θsin θcos θThe maps that come from matrices are called linear maps. A linear map follows two rules, for all vectors u and v and all scalars c:
A(u + v) = Au + Av A(cu) = c(Au)The first rule says that adding first and then mapping gives the same result as mapping first and then adding. The second rule says the same for scaling. These are the two operations from Topic 1.1, so a linear map is a map that respects linear combinations.
In the drawing, the two rules have visible consequences.
A map that bends lines, or that moves the origin, is not linear and cannot be written as a matrix times a vector.
| Term | Meaning |
|---|---|
| Matrix | A rectangular table of numbers |
| Ax | The linear combination of the columns of A, with the components of x as the coefficients |
| Columns of A | Where the map sends i and j |
| Linear map | A map that respects addition and scalar multiplication |
Work each problem on paper first. Then open the answer to check your work.
2(1, 3) + 1(2, 4) = (2 + 2, 6 + 4)2 times the first column plus 1 times the second column2(1, 3) + 1(2, 4) = (4, 10)the result
The columns are (3, 0) and (0, 2), so the matrix is 3002.
The map stretches the plane by a factor of 3 in the x direction and by a factor of 2 in the y direction.
2(1, 0) + 3(1, 1) = (2 + 3, 0 + 3)2 times the first column plus 3 times the second column2(1, 0) + 3(1, 1) = (5, 3)the result
The height stays 3, and the point slides 3 units to the right.
The vector i = (1, 0) goes to (−1, 0), and the vector j = (0, 1) stays at (0, 1). The matrix is −1001.
2−114 xy = 36.
No. It sends the origin (0, 0) to (1, 0). A linear map leaves the origin where it is.
Python reads the code one line at a time, from the top to the bottom. The equals sign stores the value on its right under the name on its left, and print shows a result. The name np stands for NumPy, the part of Python that works with vectors and matrices.
A matrix is typed one row at a time. Each row goes inside its own square brackets, and all of the rows go inside one more pair of square brackets. The code below stores the matrix A from Part 1 of this topic. Its first row is 2, 1 and its second row is 0, 1.
Python
Python prints the two rows on two lines. Notice that the matrix is typed by its rows, although this topic reads a matrix by its columns. The first column of this matrix is (2, 0): the first number of the first row, and the first number of the second row.
The @ sign multiplies a matrix by a vector. The code below calculates the product from Part 2 of this topic.
Python
The result is [8 2], which agrees with Part 2.
Do not use the * sign for this product. With a matrix and a vector, the * sign multiplies matching entries, which is a different operation.
Now change the vector so that the code prints the first column of A. Part 3 of this topic shows which vector to use.
Python
From Part 3, the columns of a matrix are the vectors where (1, 0) and (0, 1) land. A rotation by 90 degrees counterclockwise moves (1, 0) to (0, 1), and it moves (0, 1) to (−1, 0).
In the next box, replace the zeros so that R is the matrix of this rotation. The first column of the matrix should be (0, 1), and the second column should be (−1, 0). Remember that a matrix is typed by its rows. The last line applies the rotation to the vector (2, 1).
Python
The rotation moves (2, 1) to (−1, 2). You can check that these two vectors are perpendicular, because their dot product is (2)(−1) + (1)(2) = 0.
Part 4 gives the matrix for a rotation by any angle θ. Python calculates a cosine with np.cos and a sine with np.sin. Both of them need the angle in radians, so the code first changes the angle from degrees to radians with np.radians.
Python
The result is about [1.73 1.], which is the vector (2, 0) turned by 30 degrees.
Now change the angle so that the vector (2, 0) is turned by 180 degrees.
Python
The second component is printed as a number such as 2.4492936e-16. The ending e-16 means that the number is multiplied by 10⁻¹⁶. This is a very small rounding error, and the value is 0.
Part 5 states that a matrix map satisfies A(u + v) = Au + Av. The code below calculates the two sides of this equation for one pair of vectors.
Python
Both lines print [9 1]. Change u and v to any other vectors and run the code again. The two lines agree each time.
This quiz has 5 questions on this topic. A question asks you either to choose one answer or to type numbers. The page grades your answers and explains each one. A number can be typed as a whole number, a decimal, a fraction such as 1/3, or a calculation such as sqrt(18)/2 or arccos(1/2). The page shows the value of a calculation next to the box. Angles in a calculation are in degrees. The Calculator button under each question opens a calculator. Your answers are saved in your browser, so they are still on the page when you come back to it.
Choose how your answers are checked
1. Let A = 2103. Calculate A times the vector (1, 2).
1(2, 0) + 2(1, 3) = (2 + 2, 0 + 6)1 times the first column plus 2 times the second column1(2, 0) + 2(1, 3) = (4, 6)
2. A linear map sends (1, 0) to (2, 5) and sends (0, 1) to (−1, 3). Write the four entries of its matrix.
The columns of the matrix are the vectors that (1, 0) and (0, 1) are sent to. The first column is (2, 5), and the second column is (−1, 3).
3. Which matrix rotates each vector counterclockwise by 90°?
The rotation turns (1, 0) to (0, 1) and turns (0, 1) to (−1, 0). These two vectors are the columns of the matrix.
4. What does the matrix 100−1 do to the plane?
The matrix sends (x, y) to (x, −y). The x component stays the same and the y component changes sign, which flips the plane across the x axis.
5. A matrix A sends (1, 0) to (3, 1) and sends (0, 1) to (1, 2). Find A times the vector (2, −1).
The vector (2, −1) is 2(1, 0) − 1(0, 1). A linear map keeps this combination.2(3, 1) − 1(1, 2) = (6 − 1, 2 − 2)the same combination of the two results2(3, 1) − 1(1, 2) = (5, 0)