Scientia sine finibus

Linear Algebra / Unit 3, Matrices / Topic 3.3

Units and Topics

Unit 3. Matrices

3.3 The Transpose and Special 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.

1. Matrices of Any Size

A matrix with m rows and n columns is called an m by n matrix. This matrix is 2 by 3:

A = 123456

The 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 result

The size rule for a product

The 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 products

The 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.

2. The Transpose

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 = 142536

The transpose of an m by n matrix is an n by m matrix. Taking the transpose twice gives the original matrix.

Rules for the transpose

(AT)T = A (A + B)T = AT + BT (cA)T = cAT (AB)T = BT AT (A⁻¹)T = (AT)⁻¹

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 matrix

The 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.

3. The Dot Product as a Matrix Product

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 · v

This 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).

  • Ax = (−2, −2), so (Ax) · y = −6 − 2 = −8.
  • ATy = (7, 11, 15), so x · (ATy) = 7 + 0 − 15 = −8.

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.

4. Symmetric Matrices

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 = 210134045

For 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 matrix

For the 2 by 3 matrix A of Part 1,

A AT = 14323277 AT A = 172227222936273645

A 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−30

Symmetric 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.

5. Diagonal, Triangular, Identity, and Zero Matrices

NameExampleDefinition
Diagonal200030005All entries off the main diagonal are 0
Upper triangular214037005All entries below the main diagonal are 0
Lower triangular200130475All entries above the main diagonal are 0
Identity100010001Diagonal, with each diagonal entry equal to 1
Zero000000000All 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.

  • The product Dx multiplies the first component of x by 2, the second by 3, and the third by 5.
  • The product DA multiplies the rows of A by 2, 3, and 5. The product AD multiplies the columns of A by 2, 3, and 5.
  • The inverse of D is the diagonal matrix with the entries 1/2, 1/3, and 1/5. A diagonal matrix has an inverse when none of its diagonal entries is 0.
  • The square of D is the diagonal matrix with the entries 4, 9, and 25.

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.

6. Permutation Matrices

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 = 010001100

The 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 = 345612

The 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.

A =

Common Mistakes

  • Multiplying two matrices whose sizes do not match. The number of columns of the first matrix must be equal to the number of rows of the second matrix.
  • Writing the column number first. In aij, the first subscript is the row.
  • Keeping the order in the transpose of a product. (AB)T is BT AT, not AT BT.
  • Keeping the order in the inverse of a product. (AB)⁻¹ is B⁻¹A⁻¹.
  • Calling a matrix that is not square symmetric. Only a square matrix can be equal to its transpose.
  • Assuming that AT A and A AT are the same matrix. Both are symmetric, but they usually have different sizes.

Summary

TermMeaning
m by n matrixA matrix with m rows and n columns
Transpose ATThe matrix whose rows are the columns of A
SymmetricAT = A
Skew-symmetricAT = −A
DiagonalAll entries off the main diagonal are 0
TriangularAll entries on one side of the main diagonal are 0
Permutation matrixThe identity matrix with its rows in a different order

Practice

Work each problem on paper first. Then open the answer to check your work.

1. A is a 3 by 4 matrix and B is a 4 by 2 matrix. Which of the products AB and BA are defined, and what are their sizes?

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.

2. Write the transpose of 2−10354.

The rows become the columns: 205−134.

3. Calculate 123456 1−1.

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

4. Find the values of a and b that make 1a425b4−36 symmetric.

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.

5. For A = 1201, calculate AT A and A AT.

AT = 1021.

AT A = 1225 and A AT = 5221. Both are symmetric, and they are different.

6. Write the 3 by 3 permutation matrix that exchanges rows 1 and 3 and leaves row 2 in place. What is its inverse?

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.

Python Practice

Step 1. Find the size of a matrix

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.

Step 2. Take a transpose

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

Step 3. Multiply matrices of different sizes

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

Step 4. Check the rule for the transpose of a product

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

Step 5. Test whether a matrix is symmetric

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

Step 6. Build identity and diagonal matrices

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

Quiz

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?

2. Let A = 123456. Find the entry in row 3 and column 2 of AT.

3. Which rule is correct for the transpose of a product?

4. For which value of a is the matrix 2a73 symmetric?

5. Which of these matrices is a permutation matrix?

Next: Topic 3.4, Determinants