Linear Algebra / Unit 3, Matrices / Topic 3.3
Unit 3. Matrices
This topic extends matrices from 2 by 2 tables to tables of any size. It then introduces the transpose of a matrix and several kinds of matrices that have their own names, because they appear often in the rest of the course.
You need Topics 1.4, 3.1, and 3.2 for this topic.
A matrix with m rows and n columns is called an m by n matrix. This matrix is 2 by 3:
A = 123456The entry in row i and column j is written aij. For this matrix, a12 = 2 and a21 = 4. The row number is always written first.
The column rule from Topic 3.1 still gives the product of a matrix and a vector. The vector must have one component for each column. A 2 by 3 matrix takes a vector in ℝ³ and gives a vector in ℝ².
123456 10−1 = 1 14 + 0 25 − 1 36each component of the vector multiplies one column= 1 + 0 − 34 + 0 − 6add the matching components= −2−2the resultThe product AB is defined only when the number of columns of A is equal to the number of rows of B. Each entry of AB is the dot product of a row of A with a column of B, as in Topic 3.2, and the two vectors in a dot product must have the same number of components.
(m by n)(n by p) gives (m by p)For example, with the 2 by 3 matrix A above and a 3 by 2 matrix B, the product AB is 2 by 2.
B = 102103a 3 by 2 matrixAB = 1 + 4 + 00 + 2 + 94 + 10 + 00 + 5 + 18each entry is a row of A times a column of BAB = 5111423add the productsThe product BA is also defined, but it is a 3 by 3 matrix. For matrices that are not square, AB and BA do not even have the same size.
The transpose of a matrix A is written AT. Its rows are the columns of A, and its columns are the rows of A. The entry in row i and column j of AT is aji.
A = 123456 AT = 142536The transpose of an m by n matrix is an n by m matrix. Taking the transpose twice gives the original matrix.
In the rule for a product, the order reverses. Check it with the matrices of Part 1.
(AB)T = 5141123the transpose of the product ABBT AT = 120013 142536the transposes in the reverse orderBT AT = 5141123the same matrixThe inverse of a product follows the same pattern: (AB)⁻¹ = B⁻¹A⁻¹. The product AB does B first and A second. To undo it, undo A first and undo B second.
A vector in ℝⁿ can be treated as a matrix with n rows and 1 column. Its transpose is a matrix with 1 row. The product of a row and a column is a 1 by 1 matrix, which is a number, and that number is the dot product.
uT v = u₁u₂u₃ v₁v₂v₃ = u₁v₁ + u₂v₂ + u₃v₃ = u · vThis way of writing the dot product gives an important rule. A matrix can be moved from one side of a dot product to the other side if it is replaced by its transpose.
(Ax) · y = x · (AT y)The reason is that (Ax)T y = xT AT y, by the product rule for transposes. Check the rule with the 2 by 3 matrix A, x = (1, 0, −1), and y = (3, 1).
This rule returns in Unit 8. In quantum mechanics, the same rule with complex numbers defines the Hermitian matrices, which represent the quantities that can be measured.
A square matrix is called symmetric when it is equal to its transpose, AT = A. The entries are mirror images across the main diagonal, which runs from the upper left to the lower right: aij = aji.
S = 210134045For any matrix A, of any size, the products AT A and A AT are symmetric. The reason is the product rule:
(AT A)T = AT (AT)Tthe transpose of a product, in the reverse order(AT A)T = AT Athe transpose of a transpose is the original matrixFor the 2 by 3 matrix A of Part 1,
A AT = 14323277 AT A = 172227222936273645A square matrix is called skew-symmetric when AT = −A. Its diagonal entries must be 0, because each one is equal to its own negative.
K = 02−1−2031−30Symmetric matrices appear throughout physics. The moment of inertia of a rigid body in three dimensions is a symmetric 3 by 3 matrix, and so is the stress inside a solid. Unit 7 shows why symmetric matrices are easier to work with than other matrices.
| Name | Example | Definition |
|---|---|---|
| Diagonal | 200030005 | All entries off the main diagonal are 0 |
| Upper triangular | 214037005 | All entries below the main diagonal are 0 |
| Lower triangular | 200130475 | All entries above the main diagonal are 0 |
| Identity | 100010001 | Diagonal, with each diagonal entry equal to 1 |
| Zero | 000000000 | All entries are 0 |
A diagonal matrix is the simplest kind of matrix to work with. Let D be the diagonal matrix with the entries 2, 3, and 5.
Triangular matrices are the next simplest. A system whose matrix of coefficients is upper triangular is solved by back substitution, as in Topic 2.2. The row echelon form of a square matrix is upper triangular. The product of two upper triangular matrices is upper triangular, and the same is true for lower triangular matrices.
The identity matrix of size n is written I, or In when the size matters. For an m by n matrix A, Im A = A and A In = A.
A permutation matrix has the rows of the identity matrix in a different order. Each row and each column contains exactly one 1, and all other entries are 0.
P = 010001100The product PA has the rows of A in a new order. Row 1 of this P has its 1 in column 2, so row 1 of PA is row 2 of A.
P 123456 = 345612The inverse of a permutation matrix is its transpose, P⁻¹ = PT. A row exchange in Topic 2.2 is a multiplication by a permutation matrix. Topic 3.6 uses this fact.
Try it: kinds of matrices
Type numbers into the matrix, or choose an example. The readout shows the transpose and lists the names that apply to the matrix. A matrix can have more than one name.
| Term | Meaning |
|---|---|
| m by n matrix | A matrix with m rows and n columns |
| Transpose AT | The matrix whose rows are the columns of A |
| Symmetric | AT = A |
| Skew-symmetric | AT = −A |
| Diagonal | All entries off the main diagonal are 0 |
| Triangular | All entries on one side of the main diagonal are 0 |
| Permutation matrix | The identity matrix with its rows in a different order |
Work each problem on paper first. Then open the answer to check your work.
AB is defined, because A has 4 columns and B has 4 rows. Its size is 3 by 2.
BA is not defined, because B has 2 columns and A has 3 rows.
The rows become the columns: 205−134.
result = 1(1, 3, 5) − 1(2, 4, 6)1 times the first column minus 1 times the second columnresult = (−1, −1, −1)subtract the matching components
The entry in row 1 and column 2 must be equal to the entry in row 2 and column 1, so a = 2.
The entry in row 2 and column 3 must be equal to the entry in row 3 and column 2, so b = −3.
AT = 1021.
AT A = 1225 and A AT = 5221. Both are symmetric, and they are different.
P = 001010100.
Exchanging rows 1 and 3 a second time restores the original order, so P⁻¹ = P. This agrees with P⁻¹ = PT, because this P is symmetric.
A matrix is typed one row at a time, with each row inside its own square brackets. The code below stores the 2 by 3 matrix A from Part 1 of this topic. The expression A.shape gives the size of the matrix: the number of rows, and then the number of columns.
Python
The result is (2, 3), so the matrix has 2 rows and 3 columns.
The expression A.T gives the transpose of the matrix A.
Python
The rows of the result are the columns of A. Now change the last line so that it prints the size of the transpose.
Python
The @ sign multiplies two matrices. The code below calculates AB and BA for the matrices of Part 1.
Python
The first product is 2 by 2, and the second product is 3 by 3.
Python reports an error when the sizes do not match. The next box tries to multiply A by itself. A has 3 columns and 2 rows, so the product AA is not defined. Press Run to see the error. Then change the last line so that it prints the product of A and its transpose, which is defined.
Python
The code below stores (AB)T under the name left. The name right should hold the other side of the rule, but the two transposes are in the wrong order. Correct the third line so that both results are the same.
Python
The instruction np.array_equal compares two matrices. It gives True when all of their entries are equal, and False when they are not. A matrix is symmetric when it is equal to its transpose.
Python
The result is True, so S is symmetric.
The matrix in the next box is not symmetric. Change one entry so that the code prints True.
Python
The instruction np.eye(3) builds the 3 by 3 identity matrix. The instruction np.diag builds a diagonal matrix from a list of its diagonal entries.
Python
The product DM multiplies the rows of M by 2, 3, and 5. The product MD multiplies the columns of M by 2, 3, and 5.
In the next box, change the diagonal entries so that D is the inverse of the diagonal matrix with the entries 2, 4, and 5. The last line multiplies the two matrices, so the result should be the identity matrix. Python writes a fraction as a decimal number or with the / sign, as in 1 / 2.
Python
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. A is a 2 by 4 matrix, and B is a 4 by 3 matrix. What is the size of the product AB?
The product is defined because A has 4 columns and B has 4 rows. The product has as many rows as A and as many columns as B, so it is 2 by 3.
2. Let A = 123456. Find the entry in row 3 and column 2 of AT.
The transpose exchanges the rows and the columns. The entry in row 3 and column 2 of AT is the entry in row 2 and column 3 of A, which is 6.
3. Which rule is correct for the transpose of a product?
In the transpose of a product, the order of the two matrices reverses.
4. For which value of a is the matrix 2a73 symmetric?
A symmetric matrix is equal to its transpose, so the entry in row 1 and column 2 must be equal to the entry in row 2 and column 1.
5. Which of these matrices is a permutation matrix?
A permutation matrix has exactly one 1 in each row and in each column, and all of its other entries are 0. The last matrix is the identity matrix with its first two rows exchanged.
Next: Topic 3.4, Determinants