Survey of Mathematics

2.5 Matrices as maps, multiplication, change of basis

A matrix is the list of where a linear map sends the basis vectors. Multiplying matrices is composing maps, and changing basis changes the matrix but not the map.

Taught in 375/376Apostol, not taughtBeyond the courseApostol 2.10 to 2.16 and 4.9Spagnolie, Lectures 10, 11 and 17MATH 375 HW6 and HW7

Chapter 2.3 showed that a linear map is decided by what it does to a basis, and 2.4 showed that you may choose those values freely. This chapter writes that information down as a rectangular table of numbers, a matrix, so it can be computed with. Then it asks three questions. How do you read what a matrix does? Why does multiplying two matrices use that strange row-times-column rule? And what happens to the table when you describe the same map using a different basis?

Before you start

2.3: linear maps. 2.4: composition, inverses, isomorphisms, and prescribing values on a basis. 2.2: basis and coordinates.

Quick checkA linear map TT of the plane has T(1,0)=(2,3)T(1, 0) = (2, 3) and T(0,1)=(0,1)T(0, 1) = (0, 1). What is T(1,1)T(1, 1)?
Quick checkSS and TT are invertible maps. Which is the inverse of STST?
Quick checkWhat are the coordinates of (3,1)(3, 1) in the basis b1=(1,1)b_1 = (1, 1), b2=(1,−1)b_2 = (1, -1)?

The picture

This is the visualizer from 2.3 with one new reading. The two arrows ı^\hat\imath and ȷ^\hat\jmath are the standard basis vectors. Drag their tips anywhere. The numbers in the corner, the matrix AA, are the coordinates of where the two arrows landed: first column where ı^\hat\imath went, second column where ȷ^\hat\jmath went. Look at the purple vector vv. It is v1ı^+v2ȷ^v_1\hat\imath + v_2\hat\jmath, so it lands at v1v_1 times the first column plus v2v_2 times the second column. That sentence is the whole of matrix-times-vector.

Try the following. Pick “Rotate 90°” and read off the matrix: ı^\hat\imath goes to (0,1)(0, 1) and ȷ^\hat\jmath goes to (−1,0)(-1, 0), so the columns are (0,1)(0,1) and (−1,0)(-1,0). Then pick “Reflect” and “Stretch” and do the same. In every case you can write the matrix down by looking at two arrows.

The idea, in words

A linear map TT from an nn-dimensional space to an mm-dimensional space is decided by the nn vectors T(e1),…,T(en)T(e_1), \dots, T(e_n) (2.3). Each is a vector in the target, so each is a list of mm coordinates. Stand those nn lists side by side as columns, and you have a table with mm rows and nn columns: the matrix of TT. Two things then happen.

Reading the table. The image of any vector is a combination of the columns, with the vector’s own coordinates as the weights. That is the 3Blue1Brown way to see a matrix, and Spagnolie’s ‘triple-starred’ picture in Lecture 10.

Chaining. If you chain two maps, the columns of the chain are the second matrix applied to the columns of the first. Writing that out gives the row-times-column rule. It looks arbitrary only if you forget that it came from composition.

Why· Why the table depends on the basis, and why that is fine

The columns are coordinates, and coordinates depend on the basis (2.2). The same map has different tables in different bases. That is no problem: the map is the real object, and a matrix is a description of it in a chosen language. The last section of the chapter shows how to translate between two descriptions, and why a good choice of basis can make a table far simpler.

Definitions and theorems

Matrices as arrays

Definition T

Matrix

An m×nm \times n matrix is a rectangular array of numbers with mm rows and nn columns, written A=(aij)A = (a_{ij}) where aija_{ij} is the entry in row ii and column jj. The first subscript is the row. A matrix with one column is a column vector. A matrix with m=nm = n is square. The set of all real m×nm \times n matrices is Rm×n\mathbb R^{m \times n} (Apostol: Mm,nM_{m,n}).

In one lineA rectangular array of numbers with mm rows and nn columns; aija_{ij} is the entry in row ii and column jj.

Why it existsIt is the compact table that records a linear map once bases are chosen, and also an object you can add and multiply in its own right.

Matrices of the same size are added, and scaled, entry by entry. This is the vector space Rm×n\mathbb R^{m \times n} of 2.1.

Theorem A Apostol 2.13

Matrix space has dimension mn

Let EijE_{ij} be the m×nm \times n matrix with a 11 in row ii, column jj, and 00 everywhere else. The mnmn matrices EijE_{ij} form a basis of Rm×n\mathbb R^{m \times n}, so dim⁡Rm×n=mn\dim \mathbb R^{m \times n} = mn.

In one lineThe space of m×nm \times n matrices has dimension mnmn.

Why it is trueA matrix is mnmn free numbers, and the matrices with a single 11 record each number separately.

ProofApostol 2.13
The idea: Spanning: any matrix is the sum of its entries times the E's. Independence: a combination of the E's has the coefficients as its entries.
Spanning: for any A=(aij)A = (a_{ij}), A=∑i,jaijEijA = \sum_{i,j} a_{ij}E_{ij}.
The (i,j)(i,j) entry of ∑p,qapqEpq\sum_{p,q} a_{pq}E_{pq} is aija_{ij}, because only EijE_{ij} has a nonzero entry there.
Independence: suppose ∑cijEij\sum c_{ij}E_{ij} is the zero matrix.
Same computation: the combination has entry cijc_{ij} at position (i,j)(i,j).
Then each cij=0c_{ij} = 0. So the EijE_{ij} are independent and span: they are a basis, and there are mnmn of them.
Every entry of the zero matrix is 00.

The matrix of a linear map

Definition T

Matrix of a linear map

Let T:V→WT: V \to W be linear. Choose ordered bases (e1,…,en)(e_1, \dots, e_n) of VV and (w1,…,wm)(w_1, \dots, w_m) of WW. Write each image in the basis of WW:

T(ek)=∑i=1mtik wi,k=1,…,n.T(e_k) = \sum_{i=1}^m t_{ik}\, w_i, \qquad k = 1, \dots, n.

The matrix of TT relative to these bases is the m×nm \times n matrix m(T)=(tik)m(T) = (t_{ik}). Its kkth column is the coordinates of T(ek)T(e_k). Call the two bases E=(e1,…,en)\mathcal E = (e_1, \dots, e_n) and W=(w1,…,wm)\mathcal W = (w_1, \dots, w_m). When the bases need naming we write mE→W(T)m_{\mathcal E \to \mathcal W}(T) (Spagnolie’s Ae→wA_{e \to w}). For a vector xx we write [x]E[x]_{\mathcal E} for the column of its coordinates in the basis E\mathcal E.

In one lineWith bases chosen, the matrix whose column kk is the coordinates of T(ek)T(e_k).

Why it existsIt stores everything about TT in a table, because TT is decided by its values on a basis.

A warning about notation. The letter mm now has two jobs: it is the number of rows, and (following Apostol) it is the name of the function T↦m(T)T \mapsto m(T) that produces the matrix. When mm is followed by a map in brackets, as in m(T)m(T), it is the matrix of that map.

A tip on shape: the shape is (dimension of the target) by (dimension of the source). A map from R3\mathbb R^3 to R2\mathbb R^2 has a 2×32 \times 3 matrix: it takes in columns of height 3, so it must have 3 columns, and it puts out columns of height 2.

Quick checkA linear map of the plane has T(e1)=(1,2)T(e_1) = (1, 2) and T(e2)=(3,4)T(e_2) = (3, 4). What is its matrix in the standard basis?
Worked example Apostol 2.10 Ex. 2; Spagnolie Lecture 10
Find the matrix of differentiation DD from P3P_3 to P2P_2 in the standard bases, and again in the bases (x, 12x2, 13x3, 1)(x,\ \tfrac12 x^2,\ \tfrac13 x^3,\ 1) and (1, x, x2)(1,\ x,\ x^2)

Solution.

  1. Fix the bases. For the source P3P_3 (cubics, dimension 4) take e=(1,x,x2,x3)e = (1, x, x^2, x^3). For the target P2P_2 (dimension 3) take w=(1,x,x2)w = (1, x, x^2). The matrix needs an ordered basis on each side. The matrix will be 3×43 \times 4: target dimension by source dimension.
  2. Differentiate each source basis vector and write the answer in ww. D(1)=0=(0,0,0)D(1) = 0 = (0,0,0), D(x)=1=(1,0,0)D(x) = 1 = (1,0,0), D(x2)=2x=(0,2,0)D(x^2) = 2x = (0,2,0), D(x3)=3x2=(0,0,3)D(x^3) = 3x^2 = (0,0,3). Column kk is the coordinates of T(ek)T(e_k) in the target basis.
  3. Place the four columns side by side.
m(D)=[010000200003].m(D) = \begin{bmatrix}0&1&0&0\\0&0&2&0\\0&0&0&3\end{bmatrix}.

Columns, not rows: each image becomes a column. 4. Now change the bases. Take e′=(x,12x2,13x3,1)e' = (x, \tfrac12 x^2, \tfrac13 x^3, 1) and keep ww. Then D(x)=1=(1,0,0)D(x) = 1 = (1,0,0), D(12x2)=x=(0,1,0)D(\tfrac12x^2) = x = (0,1,0), D(13x3)=x2=(0,0,1)D(\tfrac13x^3) = x^2 = (0,0,1), D(1)=0D(1) = 0. We chose source vectors that DD sends exactly onto the target basis vectors, and the last one from the null space. 5. Write the new matrix.

m(D)=[100001000010].m(D) = \begin{bmatrix}1&0&0&0\\0&1&0&0\\0&0&1&0\end{bmatrix}.Same map, much simpler table. The ones form an identity block of size 3, the rank of DD, and the zero column is the null space.

Answer. The two matrices above. Same map, different bases, different tables.

Step 4 is a special case of a general fact, stated later in the chapter as the ‘diagonal form’ theorem. First, the central result: how to compute with a matrix.

Theorem T Apostol Thm 2.13; Spagnolie Lecture 10

Matrix times vector

Let m(T)=(tik)m(T) = (t_{ik}) be the matrix of TT relative to bases E=(ek)\mathcal E = (e_k) and W=(wi)\mathcal W = (w_i). If x=∑kxkekx = \sum_k x_k e_k then T(x)=∑iyiwiT(x) = \sum_i y_i w_i with

yi=∑k=1ntik xk(i=1,…,m),that is,[T(x)]W=m(T) [x]E,y_i = \sum_{k=1}^n t_{ik}\,x_k \quad (i = 1, \dots, m), \qquad \text{that is,} \qquad [T(x)]_{\mathcal W} = m(T)\,[x]_{\mathcal E},

where the matrix-times-column on the right is defined by the displayed formula. Equivalently, [T(x)]W=x1F1+⋯+xnFn[T(x)]_{\mathcal W} = x_1 F_1 + \dots + x_n F_n, where FkF_k is column kk of m(T)m(T).

In one lineIf xx has coordinates xkx_k, then T(x)T(x) has coordinates yi=∑ktikxky_i = \sum_k t_{ik}x_k, which is x1⋅(column 1)+⋯+xn⋅(column n)x_1 \cdot (\text{column }1) + \dots + x_n \cdot (\text{column }n).

Why it is trueExpand xx in the basis, push TT through, and read the coefficient of each wiw_i.

ProofApostol 2.10; Spagnolie Lecture 10
The idea: Write x in the basis, apply T term by term, expand each T(e_k), and collect the coefficient of each w_i.
Let x=∑k=1nxkekx = \sum_{k=1}^n x_k e_k.
Coordinates of xx in the basis (ek)(e_k).
T(x)=∑kxk T(ek)T(x) = \sum_k x_k\, T(e_k).
Linearity: TT passes through sums and multiples (2.3).
T(x)=∑kxk∑itik wiT(x) = \sum_k x_k \sum_i t_{ik}\, w_i.
Definition of the matrix: T(ek)=∑itikwiT(e_k) = \sum_i t_{ik}w_i.
T(x)=∑i(∑ktikxk)wiT(x) = \sum_i \Big(\sum_k t_{ik}x_k\Big) w_i.
Swap the order of the two finite sums, and collect the coefficient of each wiw_i.
So yi=∑ktikxky_i = \sum_k t_{ik}x_k.
Coordinates in a basis are unique (2.2), so the coefficient of wiw_i is the iith coordinate.
This is the column form y=x1F1+⋯+xnFny = x_1F_1 + \dots + x_nF_n.
Read the same formula column by column: the iith entry of x1F1+⋯+xnFnx_1F_1 + \dots + x_nF_n is ∑kxktik\sum_k x_k t_{ik}.

In the picture. In the visualizer above, the purple vector vv has coordinates (v1,v2)(v_1, v_2). The caption says it lands at ‘column 1 times v1v_1 plus column 2 times v2v_2’. That is the last step of this proof, in two dimensions. Dragging ı^\hat\imath and ȷ^\hat\jmath changes the columns, and AvAv moves with them.

Quick checkFor a 3×23 \times 2 matrix AA, which statement is right?
Your answerLet A=[2−10134]A = \begin{bmatrix}2&-1&0\\1&3&4\end{bmatrix} and x=(1,2,−1)x = (1, 2, -1). Compute AxAx as 1⋅(column 1)+2⋅(column 2)−1⋅(column 3)1\cdot(\text{column }1) + 2\cdot(\text{column }2) - 1\cdot(\text{column }3). What is the SECOND entry of AxAx?
Worked example
Find the matrix of T(x,y,z)=(x+2y, 3z−y)T(x, y, z) = (x + 2y,\ 3z - y) and of S(u,v)=(u+v, u−v)S(u, v) = (u + v,\ u - v). Then find the matrix of STST and check it on (2,1,4)(2, 1, 4)

Solution.

  1. Read off the shapes. TT takes 3 numbers in and gives 2 out, so its matrix is 2×32 \times 3. SS is R2→R2\mathbb R^2 \to \mathbb R^2, so its matrix is 2×22 \times 2. Shape is (target dimension) by (source dimension).
  2. Find the columns of TT. T(1,0,0)=(1,0)T(1,0,0) = (1, 0), T(0,1,0)=(2,−1)T(0,1,0) = (2, -1), T(0,0,1)=(0,3)T(0,0,1) = (0, 3). So m(T)=[1200−13]m(T) = \begin{bmatrix}1&2&0\\0&-1&3\end{bmatrix}. Column kk is T(ek)T(e_k). Equivalently the coefficients of x,y,zx, y, z in each output formula, one output per row.
  3. Find the columns of SS. S(1,0)=(1,1)S(1,0) = (1, 1) and S(0,1)=(1,−1)S(0,1) = (1, -1), so m(S)=[111−1]m(S) = \begin{bmatrix}1&1\\1&-1\end{bmatrix}. Same rule.
  4. Multiply, with TT acting first. m(ST)=m(S) m(T)=[111−1][1200−13]=[11313−3]m(ST) = m(S)\,m(T) = \begin{bmatrix}1&1\\1&-1\end{bmatrix}\begin{bmatrix}1&2&0\\0&-1&3\end{bmatrix} = \begin{bmatrix}1&1&3\\1&3&-3\end{bmatrix}. The product of matrices is the matrix of the composition, with the first map on the right. Shapes: (2×2)(2×3)=2×3(2\times2)(2\times3) = 2\times3.
  5. Check on (2,1,4)(2, 1, 4). Directly: T(2,1,4)=(4, 11)T(2,1,4) = (4,\ 11) and S(4,11)=(15,−7)S(4, 11) = (15, -7). By the matrix: (2+1+12, 2+3−12)=(15,−7)(2 + 1 + 12,\ 2 + 3 - 12) = (15, -7). Both routes must agree, since the matrix describes the composition.

Answer. m(ST)=[11313−3]m(ST) = \begin{bmatrix}1&1&3\\1&3&-3\end{bmatrix}, and both routes give (15,−7)(15, -7).

Worked example Apostol 2.12 #5; MATH 375 HW6
A linear map TT of R3\mathbb R^3 has T(k)=(2,3,5)T(k) = (2, 3, 5), T(j+k)=(1,0,0)T(j + k) = (1, 0, 0) and T(i+j+k)=(0,1,−1)T(i + j + k) = (0, 1, -1). Find its matrix in the standard bases, and compute T(i+2j+3k)T(i + 2j + 3k)

Solution. Here i=(1,0,0)i = (1,0,0), j=(0,1,0)j = (0,1,0) and k=(0,0,1)k = (0,0,1) are the standard basis vectors of R3\mathbb R^3 (Apostol’s names for e1,e2,e3e_1, e_2, e_3).

  1. Find T(j)T(j). T(j)=T(j+k)−T(k)=(1,0,0)−(2,3,5)=(−1,−3,−5)T(j) = T(j + k) - T(k) = (1,0,0) - (2,3,5) = (-1,-3,-5). Linearity lets us subtract values: j=(j+k)−kj = (j + k) - k.
  2. Find T(i)T(i). T(i)=T(i+j+k)−T(j)−T(k)=(0,1,−1)−(−1,−3,−5)−(2,3,5)=(−1,1,−1)T(i) = T(i + j + k) - T(j) - T(k) = (0,1,-1) - (-1,-3,-5) - (2,3,5) = (-1, 1, -1). Same idea: i=(i+j+k)−j−ki = (i + j + k) - j - k.
  3. Write the images as columns. The columns are T(i),T(j),T(k)T(i), T(j), T(k):
m(T)=[−1−121−33−1−55].m(T) = \begin{bmatrix}-1&-1&2\\1&-3&3\\-1&-5&5\end{bmatrix}.

The matrix in the standard bases has columns T(ek)T(e_k), with coordinates read off as the entries themselves. 4. Check against the data. The matrix times (0,0,1)(0,0,1) is column 3, (2,3,5)(2,3,5). Times (0,1,1)(0,1,1) it gives column 2 plus column 3, (1,0,0)(1, 0, 0). Times (1,1,1)(1,1,1) it gives (−1−1+2, 1−3+3, −1−5+5)=(0,1,−1)(-1-1+2,\ 1-3+3,\ -1-5+5) = (0, 1, -1). The matrix must reproduce all three given values. 5. Compute T(i+2j+3k)T(i + 2j + 3k). 1⋅(−1,1,−1)+2⋅(−1,−3,−5)+3⋅(2,3,5)=(−1−2+6, 1−6+9, −1−10+15)=(3,4,4)1\cdot(-1,1,-1) + 2\cdot(-1,-3,-5) + 3\cdot(2,3,5) = (-1-2+6,\ 1-6+9,\ -1-10+15) = (3, 4, 4). Matrix times vector is a combination of columns, with the coordinates 1,2,31, 2, 3 as weights.

Answer. The matrix above, and T(i+2j+3k)=(3,4,4)T(i + 2j + 3k) = (3, 4, 4). (The posted answer key made an elimination slip when finding the null space of this map; the correct null space is {O}\{O\}, since the three columns are independent.)

Matrices are the maps

Fix the bases and write m(T)m(T) for the matrix of each map T∈L(V,W)T \in L(V,W). This gives a function Φ:L(V,W)→Rm×n\Phi: L(V, W) \to \mathbb R^{m \times n}, Φ(T)=m(T)\Phi(T) = m(T). It turns out to be an isomorphism, which is the idea behind Spagnolie’s remark in Lecture 11.

Theorem T Apostol Thm 2.15 (the isomorphism theorem); Spagnolie Lecture 11

Maps and matrices are the same thing

Let dim⁡V=n\dim V = n and dim⁡W=m\dim W = m, with fixed bases. Then the function Φ:L(V,W)→Rm×n\Phi: L(V, W) \to \mathbb R^{m \times n} defined by Φ(T)=m(T)\Phi(T) = m(T) is linear, one-to-one and onto. In particular dim⁡L(V,W)=mn\dim L(V, W) = mn.

In one lineFor fixed bases, the function T↦m(T)T \mapsto m(T) is an isomorphism from L(V,W)L(V, W) onto Rm×n\mathbb R^{m \times n}.

Why it is trueAdding maps adds their columns, a map is decided by its columns, and any table of columns is the table of some map.

ProofApostol 2.14
The idea: Linear because images add and scale; one-to-one because a map is decided by its values on a basis; onto by prescribing the columns.
Linear: column kk of m(S+T)m(S + T) is column kk of m(S)m(S) plus column kk of m(T)m(T), so m(S+T)=m(S)+m(T)m(S + T) = m(S) + m(T). In the same way m(cT)=c m(T)m(cT) = c\,m(T).
(S+T)(ek)=S(ek)+T(ek)(S + T)(e_k) = S(e_k) + T(e_k), and coordinates of a sum are the sums of coordinates.
One-to-one: suppose m(S)=m(T)m(S) = m(T). Then S(ek)=T(ek)S(e_k) = T(e_k) for every kk.
If m(S)=m(T)m(S) = m(T), both maps send each eke_k to the same vector.
So S=TS = T. Hence Φ\Phi is one-to-one.
Two linear maps that agree on a basis are equal (2.3).
Onto: given any matrix (tik)(t_{ik}), there is a linear map TT with T(ek)=∑itikwiT(e_k) = \sum_i t_{ik}w_i.
'Prescribed values on a basis' from 2.4: you may choose the images of the eke_k freely.
Then m(T)=(tik)m(T) = (t_{ik}). So mm is an isomorphism, and dim⁡L(V,W)=dim⁡Rm×n=mn\dim L(V,W) = \dim \mathbb R^{m \times n} = mn.
By construction its columns are the given ones.
Your answerWhat is dim⁡L(R3,R4)\dim L(\mathbb R^3, \mathbb R^4), the dimension of the space of all linear maps from R3\mathbb R^3 to R4\mathbb R^4?

Matrix multiplication is composition

Let T:U→VT: U \to V and S:V→WS: V \to W be linear, with dim⁡U=n\dim U = n, dim⁡V=p\dim V = p, dim⁡W=m\dim W = m, and bases (uj)(u_j), (vk)(v_k), (wi)(w_i). Then m(T)m(T) is p×np \times n and m(S)m(S) is m×pm \times p, and ST:U→WST: U \to W has an m×nm \times n matrix. What is it in terms of m(S)m(S) and m(T)m(T)? Do not guess a rule. Compute it, one column at a time.

Theorem T Apostol Thm 2.16; Spagnolie Lecture 11

Matrix of a composition

With m(S)=(sik)m(S) = (s_{ik}) and m(T)=(tkj)m(T) = (t_{kj}) as above, m(ST)m(ST) is the m×nm \times n matrix with

(m(ST))ij=∑k=1psik tkj.\big(m(ST)\big)_{ij} = \sum_{k=1}^p s_{ik}\,t_{kj}.

In words: column jj of m(ST)m(ST) is m(S)m(S) applied to column jj of m(T)m(T).

In one lineThe (i,j)(i, j) entry of m(ST)m(ST) is ∑ksiktkj\sum_{k} s_{ik}t_{kj}: row ii of m(S)m(S) times column jj of m(T)m(T).

Why it is trueColumn jj of m(ST)m(ST) is the coordinates of S(T(uj))S(T(u_j)). Those are m(S)m(S) times the coordinates of T(uj)T(u_j), which is column jj of m(T)m(T).

ProofApostol 2.15; Spagnolie Lecture 11 page 2
The idea: Take the j-th basis vector of U. Send it through T, then through S, and record coordinates at each stage. The first stage gives column j of m(T); the second stage is 'Matrix times vector'.
Column jj of m(ST)m(ST) is the coordinates, in (wi)(w_i), of ST(uj)=S(T(uj))ST(u_j) = S(T(u_j)).
Column jj of any matrix is the coordinates of the image of the jjth basis vector.
T(uj)=∑ktkjvkT(u_j) = \sum_k t_{kj}v_k. So the coordinate column of T(uj)T(u_j) in the basis (vk)(v_k) is column jj of m(T)m(T).
Definition of m(T)m(T): its jjth column lists the coordinates of T(uj)T(u_j) in the basis (vk)(v_k).
The coordinate column of S(T(uj))S(T(u_j)) in the basis (wi)(w_i) is m(S)m(S) times the coordinate column of T(uj)T(u_j) in the basis (vk)(v_k). This is the second claim: column jj of m(ST)m(ST) is m(S)m(S) times column jj of m(T)m(T).
'Matrix times vector', applied to the map SS and the vector x=T(uj)x = T(u_j) of VV.
The iith entry of that column is ∑k=1psiktkj\sum_{k=1}^p s_{ik}t_{kj}. That is the (i,j)(i, j) entry of m(ST)m(ST).
The formula for matrix times vector: the iith entry of m(S) ym(S)\,y is ∑ksikyk\sum_k s_{ik}y_k, with yk=tkjy_k = t_{kj}.
Proof workshopRebuild the proof that the matrix of a composition is the product

Tap the lines in the order a proof would write them. Each line can only use what is already above it.

    So the row-times-column rule is not a definition somebody invented. It is forced: it is the only table that describes ‘do TT, then SS’. We therefore use the formula to define the product of two matrices.

    Definition T

    Matrix multiplication

    Let A=(aik)A = (a_{ik}) be m×pm \times p and B=(bkj)B = (b_{kj}) be p×np \times n. The product ABAB is the m×nm \times n matrix whose (i,j)(i, j) entry is

    (AB)ij=∑k=1paik bkj=(row i of A)⋅(column j of B).(AB)_{ij} = \sum_{k=1}^p a_{ik}\,b_{kj} = (\text{row } i \text{ of } A)\cdot(\text{column } j \text{ of } B).

    It is defined only when the number of columns of AA equals the number of rows of BB. Equivalently, column jj of ABAB is AA times column jj of BB. With this definition, the theorem reads m(ST)=m(S) m(T)m(ST) = m(S)\,m(T).

    In one lineFor AA of size m×pm \times p and BB of size p×np \times n, ABAB is the m×nm \times n matrix with (AB)ij=∑kaikbkj(AB)_{ij} = \sum_k a_{ik}b_{kj}.

    Why it existsIt makes the matrix of a composition equal to the product of the matrices: m(ST)=m(S) m(T)m(ST) = m(S)\,m(T).

    Shapes: (m by p) times (p by n) is (m by n). The two inside numbers must match and then vanish. Read the product right to left as maps, exactly like STST: ABAB means ‘apply BB, then AA’.

    Where this came from· Cayley and the matrix

    In 1850 James Joseph Sylvester introduced the word ‘matrix’ (Latin for womb) for a rectangular array from which determinants can be taken. People had long written coefficients of linear substitutions in arrays, and by the 1840s Gauss and Eisenstein had noticed that substitutions can be multiplied like numbers, except that the order matters. Arthur Cayley’s 1858 ‘Memoir on the Theory of Matrices’ gave the array itself an abstract definition and an algebra: sum, product and inverse. Both men worked on invariant theory, where one constantly performs a linear substitution of variables and then another, which is exactly the situation of the rule derived above. In the same memoir Cayley stated that a matrix satisfies its own characteristic equation. He proved it for 2×22 \times 2 matrices and said he had checked 3×33 \times 3; Frobenius gave the first proof for every size in 1878. Spagnolie’s Lecture 17 proves a special case of this Cayley–Hamilton theorem.

    Worked example Spagnolie Lecture 11 page 2
    Compute ABAB for A=[111012]A = \begin{bmatrix}1&1&1\\0&1&2\end{bmatrix} and B=[010110011]B = \begin{bmatrix}0&1&0\\1&1&0\\0&1&1\end{bmatrix}, column by column, and check it on a vector

    Solution.

    Answer. AB=[131132]AB = \begin{bmatrix}1&3&1\\1&3&2\end{bmatrix}.

    Quick checkAA is 2×32 \times 3 and BB is 3×43 \times 4. Which products exist?
    Your answerLet A=[1234]A = \begin{bmatrix}1&2\\3&4\end{bmatrix} and B=[5678]B = \begin{bmatrix}5&6\\7&8\end{bmatrix}. What is the entry in row 2, column 1 of ABAB?

    Matrix multiplication does not commute

    Spagnolie’s 2D example (Lecture 11). Let A=[0−110]A = \begin{bmatrix}0&-1\\1&0\end{bmatrix}, which sends (x,y)(x, y) to (−y,x)(-y, x), a quarter turn counterclockwise, and B=[−1001]B = \begin{bmatrix}-1&0\\0&1\end{bmatrix}, which sends (x,y)(x, y) to (−x,y)(-x, y), a mirror in the yy-axis. Then

    AB=[0−1−10],BA=[0110].AB = \begin{bmatrix}0&-1\\-1&0\end{bmatrix}, \qquad BA = \begin{bmatrix}0&1\\1&0\end{bmatrix}.

    ABAB means ‘mirror, then turn’: (1,0)(1, 0) goes to (−1,0)(-1, 0), then to (0,−1)(0, -1), which is column 1 of ABAB. BABA means ‘turn, then mirror’: (1,0)(1, 0) goes to (0,1)(0, 1) and stays, which is column 1 of BABA. The matrix BA=[0110]BA = \begin{bmatrix}0&1\\1&0\end{bmatrix} is exactly the “Reflect” preset of the visualizer: turning then mirroring in the yy-axis is the same as mirroring in the line y=xy = x. Spagnolie’s note labelled AA as ‘clockwise’. It is counterclockwise, since ı^=(1,0)\hat\imath = (1,0) goes to (0,1)(0, 1); the formula is right and the label is not.

    Two more ways products fail to commute. The sizes can differ: for AA of size 2×32 \times 3 and BB of size 3×23 \times 2, ABAB is 2×22 \times 2 and BABA is 3×33 \times 3. And a product can be zero while neither factor is.

    Worked example Apostol 2.16 #1; MATH 375 HW7
    For A=[1−42−14−2]A = \begin{bmatrix}1&-4&2\\-1&4&-2\end{bmatrix}, B=[12−135−2]B = \begin{bmatrix}1&2\\-1&3\\5&-2\end{bmatrix} and C=[221−11−3]C = \begin{bmatrix}2&2\\1&-1\\1&-3\end{bmatrix}, compute ABAB, BABA, ACAC and CACA

    Solution.

    1. Check the shapes first. AA is 2×32 \times 3, BB and CC are 3×23 \times 2. So ABAB, ACAC are 2×22 \times 2, while BABA, CACA are 3×33 \times 3. The inside numbers must match; here they do in both orders, and the results differ in size, so AB≠BAAB \ne BA before we compute anything.
    2. Compute ABAB entry by entry. (AB)11=1⋅1+(−4)(−1)+2⋅5=15(AB)_{11} = 1\cdot1 + (-4)(-1) + 2\cdot5 = 15. (AB)12=1⋅2+(−4)⋅3+2⋅(−2)=−14(AB)_{12} = 1\cdot2 + (-4)\cdot3 + 2\cdot(-2) = -14. Row 2 of AA is the negative of row 1, so row 2 of ABAB is (−15,14)(-15, 14). Row ii of AA against column jj of BB. The shortcut for row 2 saves two dot products.
    3. Compute BABA row by row. Row ii of BABA is bi1(row 1 of A)+bi2(row 2 of A)b_{i1}(\text{row 1 of }A) + b_{i2}(\text{row 2 of }A). Row 1: 1(1,−4,2)+2(−1,4,−2)=(−1,4,−2)1(1,-4,2) + 2(-1,4,-2) = (-1, 4, -2). Row 2: −1(1,−4,2)+3(−1,4,−2)=(−4,16,−8)-1(1,-4,2) + 3(-1,4,-2) = (-4, 16, -8). Row 3: 5(1,−4,2)−2(−1,4,−2)=(7,−28,14)5(1,-4,2) - 2(-1,4,-2) = (7, -28, 14). A row of a product is a combination of the rows of the right factor, with the left factor’s row as weights. This is the mirror image of ‘combination of columns’.
    4. Compute ACAC. (AC)11=2−4+2=0(AC)_{11} = 2 - 4 + 2 = 0, (AC)12=2+4−6=0(AC)_{12} = 2 + 4 - 6 = 0, and row 2 is the negative of row 1. So AC=OAC = O (2×22 \times 2 zero matrix). Every column of CC is sent to OO by AA: the columns of CC lie in the null space of AA.
    5. Compute CACA. Row 1: 2(1,−4,2)+2(−1,4,−2)=(0,0,0)2(1,-4,2) + 2(-1,4,-2) = (0,0,0). Row 2: 1(1,−4,2)−1(−1,4,−2)=(2,−8,4)1(1,-4,2) - 1(-1,4,-2) = (2,-8,4). Row 3: 1(1,−4,2)−3(−1,4,−2)=(4,−16,8)1(1,-4,2) - 3(-1,4,-2) = (4,-16,8). Same row rule as step 3.

    Answer.

    AB=[15−14−1514],  BA=[−14−2−416−87−2814],  AC=O,  CA=[0002−844−168].AB = \begin{bmatrix}15&-14\\-15&14\end{bmatrix},\ \ BA = \begin{bmatrix}-1&4&-2\\-4&16&-8\\7&-28&14\end{bmatrix},\ \ AC = O,\ \ CA = \begin{bmatrix}0&0&0\\2&-8&4\\4&-16&8\end{bmatrix}.

    Here AC=OAC = O but CA≠OCA \ne O, and neither AA nor CC is zero.

    What does hold is the pair of laws that matter for algebra.

    Theorem T Apostol Thm 2.17

    Matrix multiplication is associative and distributive

    For matrices of compatible sizes: A(BC)=(AB)CA(BC) = (AB)C, (A+B)C=AC+BC(A + B)C = AC + BC, and C(A+B)=CA+CBC(A + B) = CA + CB.

    In one lineA(BC)=(AB)CA(BC) = (AB)C, (A+B)C=AC+BC(A + B)C = AC + BC and C(A+B)=CA+CBC(A + B) = CA + CB whenever the products are defined.

    Why it is trueMatrices are maps, and composition of maps is associative and distributive. Nobody needs to expand a sum.

    ProofApostol 2.15 (Apostol's own proof)
    The idea: Turn the matrices into maps using the isomorphism theorem, use the matching law for maps, and turn back.
    Let A,B,CA, B, C be m×pm \times p, p×qp \times q, q×nq \times n. Choose linear maps R,S,TR, S, T with m(R)=Am(R) = A, m(S)=Bm(S) = B, m(T)=Cm(T) = C in the standard bases.
    'Maps and matrices are the same thing' is onto: with standard bases, every matrix is mm of some linear map.
    (AB)C=m(RS) m(T)=m((RS)T)(AB)C = m(RS)\,m(T) = m\big((RS)T\big).
    'Matrix of a composition', used twice: m(RS)=ABm(RS) = AB, and then m((RS)T)=m(RS) m(T)m((RS)T) = m(RS)\,m(T).
    (RS)T=R(ST)(RS)T = R(ST), so m((RS)T)=m(R(ST))m\big((RS)T\big) = m\big(R(ST)\big).
    Composition is associative (2.4).
    m(R(ST))=m(R) m(ST)=A (BC)m\big(R(ST)\big) = m(R)\,m(ST) = A\,(BC). So (AB)C=A(BC)(AB)C = A(BC).
    'Matrix of a composition' once more, in the other grouping.
    The distributive laws follow in the same way.
    The same argument with the distributive laws of 2.4: m((R+S)T)=m(RT+ST)=m(RT)+m(ST)m((R + S)T) = m(RT + ST) = m(RT) + m(ST), and mm is linear.

    (An alternative proof expands ∑kaik(∑lbklclj)\sum_k a_{ik}\big(\sum_l b_{kl}c_{lj}\big) and swaps the finite sums. It checks the same thing with more index bookkeeping.) Associativity is why AnA^n makes sense: A0=IA^0 = I and An=A An−1A^n = A\,A^{n-1}.

    Definition T

    Identity matrix

    The identity matrix InI_n is the matrix of the identity map I:V→VI: V \to V with the same basis on both sides. Since I(ek)=ekI(e_k) = e_k, column kk is (0,…,1,…,0)(0, \dots, 1, \dots, 0) with the 11 in place kk, so InI_n has 11s on the diagonal and 00s elsewhere. For AA of size m×nm \times n: ImA=A=AInI_mA = A = AI_n.

    In one lineThe square matrix InI_n with 11 on the diagonal and 00 elsewhere; it is the matrix of the identity map and satisfies IA=AIA = A and AI=AAI = A.

    Why it existsIt is the matrix that does nothing, the unit for matrix multiplication.

    The last equation holds because IT=T=TIIT = T = TI for maps and mm turns products into products.

    Inverse matrices

    A square matrix AA is invertible when the map x↦Axx \mapsto Ax is one-to-one and onto (2.4; for a map from a space to itself, one-to-one already forces onto, by 2.3). Its inverse is written A−1A^{-1}.

    Theorem T Apostol 2.15 and 2.16; Spagnolie Lecture 11

    The matrix of an inverse is the inverse of the matrix

    Let T:V→VT: V \to V be one-to-one and onto, with the same basis on both sides, and A=m(T)A = m(T). Then m(T−1)m(T^{-1}) is the unique matrix A−1A^{-1} with AA−1=I=A−1AAA^{-1} = I = A^{-1}A. Also (AB)−1=B−1A−1(AB)^{-1} = B^{-1}A^{-1} when both are invertible.

    In one lineIf T:V→VT: V \to V is invertible and A=m(T)A = m(T) in one basis, then A−1=m(T−1)A^{-1} = m(T^{-1}) in the same basis, and AA−1=A−1A=IAA^{-1} = A^{-1}A = I.

    Why it is truemm turns products into products and the identity map into II.

    ProofApostol 2.15 and 2.16
    The idea: Apply m to TT⁻¹ = I and T⁻¹T = I. Uniqueness and the product rule come from the same facts about maps.
    m(T) m(T−1)=m(TT−1)=m(I)=Im(T)\,m(T^{-1}) = m(TT^{-1}) = m(I) = I.
    'Matrix of a composition': m(ST)=m(S) m(T)m(ST) = m(S)\,m(T).
    m(T−1) m(T)=m(T−1T)=m(I)=Im(T^{-1})\,m(T) = m(T^{-1}T) = m(I) = I.
    The same, in the other order.
    So m(T−1)m(T^{-1}) is a two-sided inverse of AA, and any other two-sided inverse equals it.
    If AB′=IAB' = I and B′A=IB'A = I and also AB′′=IAB'' = I, then B′′=(B′A)B′′=B′(AB′′)=B′B'' = (B'A)B'' = B'(AB'') = B' by associativity.
    For (AB)−1(AB)^{-1}: (ST)−1=T−1S−1(ST)^{-1} = T^{-1}S^{-1} for maps, so (AB)−1=B−1A−1(AB)^{-1} = B^{-1}A^{-1}.
    'Inverse of a composition reverses the order' from 2.4, then apply mm.

    There is a formula for the 2×22 \times 2 case that is worth knowing (it will reappear as a determinant in chapter 2.7).

    Proposition A Apostol 2.20 #11

    Inverse of a 2 by 2 matrix

    Let A=[abcd]A = \begin{bmatrix}a&b\\c&d\end{bmatrix} and Δ=ad−bc\Delta = ad - bc. If Δ≠0\Delta \ne 0, then AA is invertible with A−1=1Δ[d−b−ca]A^{-1} = \frac1\Delta\begin{bmatrix}d&-b\\-c&a\end{bmatrix}. If Δ=0\Delta = 0, then AA is not invertible.

    In one line[abcd]\begin{bmatrix}a&b\\c&d\end{bmatrix} is invertible exactly when ad−bc≠0ad - bc \ne 0, and then its inverse is 1ad−bc[d−b−ca]\frac{1}{ad - bc}\begin{bmatrix}d&-b\\-c&a\end{bmatrix}.

    Why it is trueMultiplying the matrix by the swapped-and-negated matrix gives (ad−bc)I(ad - bc)I. If ad−bc=0ad - bc = 0, a nonzero vector is sent to OO.

    ProofApostol 2.20 #11; MATH 375 HW7
    The idea: If Δ is not zero, multiply and see I. If Δ is zero, exhibit a nonzero vector that A sends to O, so A is not one-to-one.
    [abcd][d−b−ca]=[ad−bc−ab+bacd−dc−cb+da]=Δ I\begin{bmatrix}a&b\\c&d\end{bmatrix}\begin{bmatrix}d&-b\\-c&a\end{bmatrix} = \begin{bmatrix}ad - bc&-ab + ba\\cd - dc&-cb + da\end{bmatrix} = \Delta\, I.
    Row times column, entry by entry.
    If Δ≠0\Delta \ne 0, then A−1=1Δ[d−b−ca]A^{-1} = \frac1\Delta\begin{bmatrix}d&-b\\-c&a\end{bmatrix} works on both sides.
    Divide by Δ\Delta, which is allowed when Δ≠0\Delta \ne 0. The same multiplication in the other order gives ΔI\Delta I too, so the result is a two-sided inverse.
    If Δ=0\Delta = 0: A[d−c]=[ad−bccd−dc]=OA\begin{bmatrix}d\\-c\end{bmatrix} = \begin{bmatrix}ad - bc\\cd - dc\end{bmatrix} = O and A[−ba]=[−ab+ba−cb+da]=OA\begin{bmatrix}-b\\a\end{bmatrix} = \begin{bmatrix}-ab + ba\\-cb + da\end{bmatrix} = O.
    Compute AA times the column (d,−c)(d, -c) and times (−b,a)(-b, a).
    So AA is not one-to-one, hence not invertible (2.4).
    If AA is not the zero matrix, one of a,b,c,da, b, c, d is nonzero, so one of the two columns above is not OO. The zero matrix is not invertible either. A nonzero vector in N(A)N(A) means AA is not one-to-one.
    Quick checkWhich of these matrices is NOT invertible?
    Worked example
    Find the inverse of A=[5273]A = \begin{bmatrix}5&2\\7&3\end{bmatrix} and use it to solve Ax=[4−1]Ax = \begin{bmatrix}4\\-1\end{bmatrix}

    Solution.

    1. Compute Δ\Delta. Δ=5⋅3−2⋅7=15−14=1\Delta = 5\cdot3 - 2\cdot7 = 15 - 14 = 1. The inverse exists exactly when Δ≠0\Delta \ne 0.
    2. Swap the diagonal and negate the off-diagonal. [3−2−75]\begin{bmatrix}3&-2\\-7&5\end{bmatrix}, then divide by Δ=1\Delta = 1. So A−1=[3−2−75]A^{-1} = \begin{bmatrix}3&-2\\-7&5\end{bmatrix}. The formula 1Δ[d−b−ca]\frac1\Delta\begin{bmatrix}d&-b\\-c&a\end{bmatrix}.
    3. Check. AA−1=[15−14−10+1021−21−14+15]=IAA^{-1} = \begin{bmatrix}15 - 14&-10 + 10\\21 - 21&-14 + 15\end{bmatrix} = I. A claimed inverse must multiply back to II.
    4. Solve by multiplying by the inverse. x=A−1[4−1]=[12+2−28−5]=[14−33]x = A^{-1}\begin{bmatrix}4\\-1\end{bmatrix} = \begin{bmatrix}12 + 2\\-28 - 5\end{bmatrix} = \begin{bmatrix}14\\-33\end{bmatrix}. From Ax=bAx = b, multiply both sides on the left by A−1A^{-1}: A−1Ax=xA^{-1}Ax = x.
    5. Check the solution. A[14−33]=[70−6698−99]=[4−1]A\begin{bmatrix}14\\-33\end{bmatrix} = \begin{bmatrix}70 - 66\\98 - 99\end{bmatrix} = \begin{bmatrix}4\\-1\end{bmatrix}. Plug back into the original equation.

    Answer. A−1=[3−2−75]A^{-1} = \begin{bmatrix}3&-2\\-7&5\end{bmatrix} and x=(14,−33)x = (14, -33).

    Your answerFind the inverse of [3142]\begin{bmatrix}3&1\\4&2\end{bmatrix}. What is the entry in row 1, column 2 of the inverse?
    Worked example used in graphics
    Find the 3×33 \times 3 homogeneous matrix that scales the plane by 2 about the origin and then shifts it by (1,3)(1, 3); apply it to (1,1)(1, 1) and find its inverse

    Solution.

    1. Explain homogeneous coordinates. Shifting is not a linear map, so a matrix cannot do it directly. The trick is to write the point (x,y)(x, y) as the column (x,y,1)(x, y, 1). A shift adds a constant, and the constant can be produced as the third coordinate times a column.
    2. Write the matrix. Scaling by 2 is [2002]\begin{bmatrix}2&0\\0&2\end{bmatrix} on (x,y)(x,y). The shift adds 11 to xx and 33 to yy. Together: H=[201023001]H = \begin{bmatrix}2&0&1\\0&2&3\\0&0&1\end{bmatrix}. The last row (0,0,1)(0, 0, 1) keeps the third coordinate equal to 11. The last column carries the shift.
    3. Apply it. H[111]=[2+0+10+2+31]=[351]H\begin{bmatrix}1\\1\\1\end{bmatrix} = \begin{bmatrix}2 + 0 + 1\\0 + 2 + 3\\1\end{bmatrix} = \begin{bmatrix}3\\5\\1\end{bmatrix}, the point (3,5)(3, 5). Check by hand: scale (1,1)(1,1) to (2,2)(2,2), then shift to (3,5)(3,5).
    4. Invert in two stages. Undo the shift first (subtract (1,3)(1, 3)), then undo the scaling (halve): H−1=[12000120001][10−101−3001]=[120−12012−32001]H^{-1} = \begin{bmatrix}\tfrac12&0&0\\0&\tfrac12&0\\0&0&1\end{bmatrix}\begin{bmatrix}1&0&-1\\0&1&-3\\0&0&1\end{bmatrix} = \begin{bmatrix}\tfrac12&0&-\tfrac12\\0&\tfrac12&-\tfrac32\\0&0&1\end{bmatrix}. H=(shift)(scale)H = (\text{shift})(\text{scale}), so H−1=(scale)−1(shift)−1H^{-1} = (\text{scale})^{-1}(\text{shift})^{-1}, socks and shoes.
    5. Check. H−1(3,5,1)=(32−12, 52−32, 1)=(1,1,1)H^{-1}(3, 5, 1) = (\tfrac32 - \tfrac12,\ \tfrac52 - \tfrac32,\ 1) = (1, 1, 1). It must return the starting point.

    Answer. H=[201023001]H = \begin{bmatrix}2&0&1\\0&2&3\\0&0&1\end{bmatrix}, H(1,1,1)=(3,5,1)H(1,1,1) = (3,5,1), and H−1H^{-1} as above.

    Powers of a matrix

    Worked example Apostol 2.16 #6; MATH 375 HW7
    For A=[1101]A = \begin{bmatrix}1&1\\0&1\end{bmatrix}, find A2A^2 and AnA^n, and prove the formula by induction

    Solution.

    1. Compute small powers. A2=[1101][1101]=[1201]A^2 = \begin{bmatrix}1&1\\0&1\end{bmatrix}\begin{bmatrix}1&1\\0&1\end{bmatrix} = \begin{bmatrix}1&2\\0&1\end{bmatrix} and A3=A A2=[1301]A^3 = A\,A^2 = \begin{bmatrix}1&3\\0&1\end{bmatrix}. Compute until a pattern appears; here the top-right entry counts the powers.
    2. State the guess. An=[1n01]A^n = \begin{bmatrix}1&n\\0&1\end{bmatrix} for every n≥1n \ge 1. It fits n=1,2,3n = 1, 2, 3. A guess is not a proof, so we prove it by induction.
    3. Base case. For n=1n = 1 the formula says A1=[1101]A^1 = \begin{bmatrix}1&1\\0&1\end{bmatrix}, which is AA. Induction starts from one true case.
    4. Inductive step. Assume An−1=[1n−101]A^{n-1} = \begin{bmatrix}1&n-1\\0&1\end{bmatrix}. Then An=A An−1=[1101][1n−101]=[1(n−1)+101]=[1n01]A^n = A\,A^{n-1} = \begin{bmatrix}1&1\\0&1\end{bmatrix}\begin{bmatrix}1&n-1\\0&1\end{bmatrix} = \begin{bmatrix}1&(n-1) + 1\\0&1\end{bmatrix} = \begin{bmatrix}1&n\\0&1\end{bmatrix}. The definition An=A An−1A^n = A\,A^{n-1}, the hypothesis, then one row-times-column multiplication.

    Answer. An=[1n01]A^n = \begin{bmatrix}1&n\\0&1\end{bmatrix}. Geometrically, nn shears in a row slide the point (0,1)(0,1) to (n,1)(n, 1).

    The transpose

    Definition T

    Transpose

    The transpose of an m×nm \times n matrix A=(aij)A = (a_{ij}) is the n×mn \times m matrix ATA^{\mathsf T} with (AT)ij=aji(A^{\mathsf T})_{ij} = a_{ji}: rows become columns. For example, [123456]T=[142536]\begin{bmatrix}1&2&3\\4&5&6\end{bmatrix}^{\mathsf T} = \begin{bmatrix}1&4\\2&5\\3&6\end{bmatrix}.

    In one lineThe matrix ATA^{\mathsf T} whose rows are the columns of AA: (AT)ij=aji(A^{\mathsf T})_{ij} = a_{ji}.

    Why it existsIt swaps the roles of input and output. Later it is the matrix that moves across an inner product.

    Directly from the definition, (AT)T=A(A^{\mathsf T})^{\mathsf T} = A, (A+B)T=AT+BT(A + B)^{\mathsf T} = A^{\mathsf T} + B^{\mathsf T} and (cA)T=cAT(cA)^{\mathsf T} = cA^{\mathsf T}. The one that needs a proof reverses the order, like inverses.

    Theorem T Apostol 3.6 #7(d); MATH 375 HW7 (2.21 #7)

    Transpose of a product

    For AA of size m×pm \times p and BB of size p×np \times n, (AB)T=BTAT(AB)^{\mathsf T} = B^{\mathsf T}A^{\mathsf T}.

    In one line(AB)T=BTAT(AB)^{\mathsf T} = B^{\mathsf T}A^{\mathsf T}.

    Why it is trueEntries of ABAB come from a row of AA and a column of BB, and the transposes swap which is which.

    ProofApostol 3.6 #7
    The idea: Compare the (i, j) entries of both sides, one definition at a time.
    ((AB)T)ij=(AB)ji\big((AB)^{\mathsf T}\big)_{ij} = (AB)_{ji}.
    Definition of transpose: swap the indices of ABAB.
    =∑kajkbki= \sum_k a_{jk}b_{ki}.
    Definition of the product, entry (j,i)(j, i).
    =∑k(BT)ik (AT)kj= \sum_k (B^{\mathsf T})_{ik}\,(A^{\mathsf T})_{kj}.
    Definition of transpose, backwards: ajk=(AT)kja_{jk} = (A^{\mathsf T})_{kj} and bki=(BT)ikb_{ki} = (B^{\mathsf T})_{ik}. The numbers commute, so we can write bb first.
    =(BTAT)ij= (B^{\mathsf T}A^{\mathsf T})_{ij}. All entries agree.
    Definition of the product of BTB^{\mathsf T} (n×pn \times p) and ATA^{\mathsf T} (p×mp \times m), entry (i,j)(i, j).
    Your answerLet A=[1234]A = \begin{bmatrix}1&2\\3&4\end{bmatrix} and B=[0110]B = \begin{bmatrix}0&1\\1&0\end{bmatrix}. Compute (AB)T(AB)^{\mathsf T}. What is its entry in row 1, column 2?

    (Chapter 2.9 gives the transpose its geometric meaning, once we have inner products.)

    Changing the basis

    Now fix one space VV of dimension nn and one map T:V→VT: V \to V. Take two ordered bases: the old basis E=(e1,…,en)\mathcal E = (e_1, \dots, e_n) and the new basis F=(f1,…,fn)\mathcal F = (f_1, \dots, f_n). Let A=mE→E(T)A = m_{\mathcal E \to \mathcal E}(T) be the matrix of TT in the old basis and B=mF→F(T)B = m_{\mathcal F \to \mathcal F}(T) the matrix in the new basis. How are AA and BB related?

    Definition T

    Change of basis

    Write each new basis vector in the old basis, fj=∑kckjekf_j = \sum_k c_{kj}e_k. The change-of-basis matrix is C=(ckj)C = (c_{kj}). Its jjth column is the old coordinates of fjf_j. In the language of the previous sections, C=mF→E(I)C = m_{\mathcal F \to \mathcal E}(I), the matrix of the identity map with the new basis on the input side and the old basis on the output side.

    In one lineThe matrix CC whose column jj is the new basis vector fjf_j written in old coordinates; it converts new coordinates into old ones.

    Why it existsIt is the dictionary between two descriptions of the same space.

    Theorem T Apostol 4.9; Spagnolie Lecture 17

    Coordinates change by C

    For every x∈Vx \in V: [x]E=C [x]F[x]_{\mathcal E} = C\,[x]_{\mathcal F}. The matrix CC is invertible, and its inverse C−1=mE→F(I)C^{-1} = m_{\mathcal E \to \mathcal F}(I) turns old coordinates into new: [x]F=C−1[x]E[x]_{\mathcal F} = C^{-1}[x]_{\mathcal E}.

    In one line[x]E=C [x]F[x]_{\mathcal E} = C\,[x]_{\mathcal F}, and CC is invertible with C−1=mE→F(I)C^{-1} = m_{\mathcal E \to \mathcal F}(I).

    Why it is trueCC is the matrix of the identity map, so it turns new coordinates into old coordinates, and the matrix of the reverse trip is its inverse.

    ProofApostol 4.9; Spagnolie Lecture 17
    The idea: x is the identity map applied to x. 'Matrix times vector' for the identity map says exactly this. For the inverse, compose the two identity matrices.
    By ‘Matrix times vector’, [I(x)]E=mF→E(I) [x]F[I(x)]_{\mathcal E} = m_{\mathcal F \to \mathcal E}(I)\,[x]_{\mathcal F}. Since I(x)=xI(x) = x, [x]E=C[x]F[x]_{\mathcal E} = C[x]_{\mathcal F}.
    I(x)=xI(x) = x, and C=mF→E(I)C = m_{\mathcal F \to \mathcal E}(I) takes F\mathcal F-coordinates of the input to E\mathcal E-coordinates of the output.
    mE→F(I)  mF→E(I)=mF→F(I)=Inm_{\mathcal E \to \mathcal F}(I)\; m_{\mathcal F \to \mathcal E}(I) = m_{\mathcal F \to \mathcal F}(I) = I_n.
    'Matrix of a composition' for II=III = I with three bases: first F→E\mathcal F \to \mathcal E, then E→F\mathcal E \to \mathcal F.
    mF→E(I)  mE→F(I)=Inm_{\mathcal F \to \mathcal E}(I)\; m_{\mathcal E \to \mathcal F}(I) = I_n.
    The same in the other order: E→F→E\mathcal E \to \mathcal F \to \mathcal E.
    So CC is invertible and C−1=mE→F(I)C^{-1} = m_{\mathcal E \to \mathcal F}(I).
    Definition of an inverse matrix.

    Remember the direction. CC takes NEW coordinates to OLD coordinates. It is the matrix whose columns are the new basis written in old language.

    Theorem T Apostol Thm 4.6 and 4.7; Spagnolie Lecture 17

    Change of basis rewrites the matrix of a map

    Let T:V→VT: V \to V be linear, A=mE→E(T)A = m_{\mathcal E \to \mathcal E}(T), B=mF→F(T)B = m_{\mathcal F \to \mathcal F}(T), and CC the change-of-basis matrix. Then B=C−1ACB = C^{-1}AC. Conversely, if AA is the matrix of TT in the basis E\mathcal E and CC is any invertible matrix, then C−1ACC^{-1}AC is the matrix of TT in the basis F\mathcal F whose columns, in E\mathcal E-coordinates, are the columns of CC.

    In one lineIf AA and BB are the matrices of TT in the old and new bases, then B=C−1ACB = C^{-1}AC. Conversely every C−1ACC^{-1}AC is the matrix of the same map in some basis.

    Why it is trueTo describe TT in new coordinates: convert new to old, apply the old matrix, convert back. The three conversions are CC, AA, C−1C^{-1}, read right to left.

    ProofApostol 4.9 proves this with matrices of vectors; this is the same idea phrased with maps
    The idea: T does not care about bases: T = I∘T∘I. Give each factor a matrix with the right bases, and multiply (matrix of a composition).
    Write T=I∘T∘IT = I \circ T \circ I as a chain of maps (V,F)→ I (V,E)→ T (V,E)→ I (V,F)(V, \mathcal F) \xrightarrow{\,I\,} (V, \mathcal E) \xrightarrow{\,T\,} (V, \mathcal E) \xrightarrow{\,I\,} (V, \mathcal F).
    The identity map changes nothing, so T=I T IT = I\,T\,I. We give the three factors different bases so that each has a matrix we know.
    The first map has matrix CC, the middle map has matrix AA, and the last map has matrix mE→F(I)=C−1m_{\mathcal E \to \mathcal F}(I) = C^{-1}.
    Matrices of the three pieces: CC, then AA, then C−1C^{-1} from the previous theorem.
    B=mF→F(T)=C−1 A CB = m_{\mathcal F \to \mathcal F}(T) = C^{-1}\,A\,C.
    'Matrix of a composition': the matrix of a chain is the product, with the first map on the right.
    The vectors f1,…,fnf_1, \dots, f_n form a basis F\mathcal F, and CC is its change-of-basis matrix.
    Converse. Let CC be invertible and define fj=∑kckjekf_j = \sum_k c_{kj}e_k. Let UU be the linear map with U(ej)=fjU(e_j) = f_j ('Prescribed values on a basis'), so m(U)=Cm(U) = C. Let U′U' be the linear map whose matrix is C−1C^{-1}. Then m(UU′)=CC−1=I=m(I)m(UU') = CC^{-1} = I = m(I) and m(U′U)=Im(U'U) = I too. Since mm is one-to-one ('Maps and matrices are the same thing'), UU′=U′U=IUU' = U'U = I. So UU is one-to-one and onto, and it sends the basis E\mathcal E to a basis ('One-to-one in finite dimension' from 2.4).
    So the matrix of TT in F\mathcal F is C−1ACC^{-1}AC.
    Apply the first half of this theorem to this F\mathcal F.
    Proof workshopGive the reason for each line: B=C−1ACB = C^{-1}AC

    Each line of the proof is shown in order. Choose the reason that justifies it, then press Check.

    1. Write T=I∘T∘IT = I \circ T \circ I as the chain (V,F)→(V,E)→(V,E)→(V,F)(V, \mathcal F) \to (V, \mathcal E) \to (V, \mathcal E) \to (V, \mathcal F).
    2. The first map has matrix CC.
    3. The middle map has matrix AA.
    4. The last map has matrix C−1C^{-1}.
    5. B=C−1ACB = C^{-1}AC.
    Definition T

    Similar matrices

    Two n×nn \times n matrices AA and BB are similar if there is an invertible CC with B=C−1ACB = C^{-1}AC.

    In one lineMatrices AA and BB with B=C−1ACB = C^{-1}AC for some invertible CC; equivalently, two descriptions of the same map in different bases.

    Why it existsIt is the right notion of 'the same linear map', since any quantity of the map itself must be the same for similar matrices.

    By the theorem and its converse (Apostol Thm 4.8), AA and BB are similar exactly when they are matrices of the same linear map in two bases. Spagnolie’s slogan: similar matrices are the same transformation in different coordinates. Everything about the map that does not depend on the basis must come out the same for similar matrices. Chapters 2.7 and 2.8 show that the determinant, the trace and the eigenvalues are such quantities. A remark you will need: similarity is an equivalence relation (the prove problem on similarity below proves it).

    In the picture. Pick “Eigen example” in the visualizer below and tick ‘eigenlines’. The matrix is [3102]\begin{bmatrix}3&1\\0&2\end{bmatrix}. The two dashed lines are special directions that the map only stretches, by 3 and by 2. Use those two directions as the new basis and the matrix of the SAME picture becomes [3002]\begin{bmatrix}3&0\\0&2\end{bmatrix}: a table with only a diagonal. That is a change of basis doing its job, and it is why B=C−1ACB = C^{-1}AC is worth the effort. Chapter 2.8 shows how to find such a basis.

    Worked example Spagnolie Lecture 17; Apostol 4.9
    Let T(x)=AxT(x) = Ax with A=[4123]A = \begin{bmatrix}4&1\\2&3\end{bmatrix}. Find its matrix BB in the basis f1=(1,1)f_1 = (1,1), f2=(1,−2)f_2 = (1,-2), check it on x=(2,5)x = (2,5), and use it to compute A5A^5

    Solution.

    Answer. B=[5002]B = \begin{bmatrix}5&0\\0&2\end{bmatrix} and A5=[2094103120621063]A^5 = \begin{bmatrix}2094&1031\\2062&1063\end{bmatrix}.

    Quick checkB=C−1ACB = C^{-1}AC where the columns of CC are the new basis vectors in old coordinates. To find BB's action on new coordinates yy, which happens FIRST?
    Your answerIn the example above the new basis is f1=(1,1)f_1 = (1, 1), f2=(1,−2)f_2 = (1, -2). Write x=(4,1)x = (4, 1) as c1f1+c2f2c_1 f_1 + c_2 f_2. What is c1c_1, the first new coordinate?
    Worked example Spagnolie Lecture 17 (powers); the general n is a prove problem below
    Prove: if B=C−1ACB = C^{-1}AC, then B2=C−1A2CB^2 = C^{-1}A^2C

    Solution.

    1. Write B2B^2 as a product. B2=B B=(C−1AC)(C−1AC)B^2 = B\,B = (C^{-1}AC)(C^{-1}AC). That is the definition of the square.
    2. Regroup. =C−1A (C C−1) AC= C^{-1}A\,(C\,C^{-1})\,AC. Matrix multiplication is associative, so brackets can move.
    3. Cancel. C C−1=IC\,C^{-1} = I and A I=AA\,I = A, so this is C−1A A CC^{-1}A\,A\,C. The middle C C−1C\,C^{-1} cancels because C−1C^{-1} is the inverse of CC.
    4. Name the result. =C−1A2C= C^{-1}A^2C. Definition of A2A^2.

    Answer. B2=C−1A2CB^2 = C^{-1}A^2C. Every power cancels the middle pairs in the same way.

    The simplest matrix a map can have

    If you may choose different bases for the input and output, you can make the matrix almost empty.

    Theorem T Apostol Thm 2.14; Spagnolie Lecture 10 (diagonal form)

    Diagonal form of a linear map

    Let dim⁡V=n\dim V = n, dim⁡W=m\dim W = m, and r=rank⁡Tr = \operatorname{rank} T. There are bases (e1,…,en)(e_1, \dots, e_n) of VV and (w1,…,wm)(w_1, \dots, w_m) of WW with T(ei)=wiT(e_i) = w_i for i=1,…,ri = 1, \dots, r and T(ei)=OT(e_i) = O for i=r+1,…,ni = r+1, \dots, n. The matrix of TT is then the m×nm \times n matrix with 11 in positions (1,1),…,(r,r)(1,1), \dots, (r,r) and 00 elsewhere.

    In one lineFor T:V→WT: V \to W of rank rr there are bases of VV and WW in which the matrix has 11s in the first rr diagonal places and 00 everywhere else.

    Why it is trueChoose a basis of the range and lift it to VV; fill out with a basis of the null space.

    ProofApostol 2.11; Spagnolie Lecture 10 page 5
    The idea: Start in W: a basis of the range, extended to a basis of W. Lift the range basis back to V. Then add a basis of the null space. Rank–nullity says the count is right.
    Let w1,…,wrw_1, \dots, w_r be a basis of T(V)T(V).
    The range T(V)T(V) is a subspace of WW of dimension rr, so it has a basis (2.2).
    Extend to a basis w1,…,wr,wr+1,…,wmw_1, \dots, w_r, w_{r+1}, \dots, w_m of WW.
    'Extending to a basis' (2.2): an independent set extends to a basis of WW.
    For i≤ri \le r choose ei∈Ve_i \in V with T(ei)=wiT(e_i) = w_i.
    Each wiw_i with i≤ri \le r is in the range, so it has a source.
    Let er+1,…,ene_{r+1}, \dots, e_n be a basis of N(T)N(T), so T(ei)=OT(e_i) = O for i>ri > r.
    The null space has dimension k=n−rk = n - r by rank–nullity (2.3).
    It remains to show e1,…,ene_1, \dots, e_n are independent. Applying TT gives ∑i=1rciwi=O\sum_{i=1}^r c_i w_i = O.
    Since there are n=r+kn = r + k vectors, it is enough to show independence ('Extending to a basis' (b)). Suppose ∑i=1nciei=O\sum_{i=1}^n c_ie_i = O and apply TT.
    So c1=⋯=cr=0c_1 = \dots = c_r = 0.
    The wiw_i with i≤ri \le r are independent.
    Then ∑i>rciei=O\sum_{i>r} c_ie_i = O forces cr+1=⋯=cn=0c_{r+1} = \dots = c_n = 0. So the eie_i are a basis of VV, and the matrix has the claimed form.
    What remains is a combination of a basis of the null space equal to OO.

    (Spagnolie’s page has a typo in the index range. The second condition is for i=r+1,…,ni = r+1, \dots, n because there are nn basis vectors of VV.) This is what the differentiation example above did with DD: the basis (x,12x2,13x3,1)(x, \tfrac12 x^2, \tfrac13 x^3, 1) maps the first three vectors onto 1,x,x21, x, x^2 and the last one into the null space.

    A preview· Preview: the case V = W with one shared basis

    The theorem above allows different bases on the two sides. When the input and output spaces are the same space and the bases must agree, as in the change-of-basis section, you cannot always reach a diagonal matrix. When you can, the diagonal entries are the eigenvalues of chapter 2.8, and A=CBC−1A = CBC^{-1} is the factorisation that makes A500A^{500} easy. The shear [1101]\begin{bmatrix}1&1\\0&1\end{bmatrix} is the standard example that cannot be diagonalised.

    Where it is used

    Used inside maths· Inside maths: the chain rule is a matrix product

    In multivariable calculus the derivative of a map g:R2→R2g: \mathbb R^2 \to \mathbb R^2 at a point is a linear map, and its matrix is the Jacobian DgDg of partial derivatives. The chain rule from Lectures 22 and 23 says D(F∘g)=DF(g)  DgD(F \circ g) = DF(g)\;Dg, a product of matrices, because the derivative of a composition is the composition of derivatives. Take polar coordinates g(r,θ)=(rcos⁡θ,rsin⁡θ)g(r, \theta) = (r\cos\theta, r\sin\theta) and F(x,y)=x2+y2F(x, y) = x^2 + y^2. Then DF=[2x2y]DF = \begin{bmatrix}2x&2y\end{bmatrix} and Dg=[cos⁡θ−rsin⁡θsin⁡θrcos⁡θ]Dg = \begin{bmatrix}\cos\theta&-r\sin\theta\\\sin\theta&r\cos\theta\end{bmatrix}, so

    D(F∘g)=[2rcos⁡θ2rsin⁡θ][cos⁡θ−rsin⁡θsin⁡θrcos⁡θ]=[2r0].D(F\circ g) = \begin{bmatrix}2r\cos\theta&2r\sin\theta\end{bmatrix}\begin{bmatrix}\cos\theta&-r\sin\theta\\\sin\theta&r\cos\theta\end{bmatrix} = \begin{bmatrix}2r&0\end{bmatrix}.

    Direct check: F(g(r,θ))=r2F(g(r,\theta)) = r^2, whose partial derivative in rr is 2r2r and in θ\theta is 00.

    Used inside maths· Inside maths: angle-addition formulas from multiplying rotations

    Let R(α)=[cos⁡α−sin⁡αsin⁡αcos⁡α]R(\alpha) = \begin{bmatrix}\cos\alpha&-\sin\alpha\\\sin\alpha&\cos\alpha\end{bmatrix} be rotation by α\alpha. Turning by β\beta and then by α\alpha is turning by α+β\alpha + \beta, so R(α)R(β)=R(α+β)R(\alpha)R(\beta) = R(\alpha + \beta). Multiply the left side out. Its first column is [cos⁡αcos⁡β−sin⁡αsin⁡βsin⁡αcos⁡β+cos⁡αsin⁡β]\begin{bmatrix}\cos\alpha\cos\beta - \sin\alpha\sin\beta\\\sin\alpha\cos\beta + \cos\alpha\sin\beta\end{bmatrix}. The first column of R(α+β)R(\alpha + \beta) is (cos⁡(α+β),sin⁡(α+β))(\cos(\alpha + \beta), \sin(\alpha + \beta)). Comparing entries gives cos⁡(α+β)=cos⁡αcos⁡β−sin⁡αsin⁡β\cos(\alpha+\beta) = \cos\alpha\cos\beta - \sin\alpha\sin\beta and sin⁡(α+β)=sin⁡αcos⁡β+cos⁡αsin⁡β\sin(\alpha + \beta) = \sin\alpha\cos\beta + \cos\alpha\sin\beta, the two formulas you memorised in JEE. They are matrix multiplication, and the memorising was never needed. Also R(α)R(β)=R(β)R(α)R(\alpha)R(\beta) = R(\beta)R(\alpha): rotations of the plane about one point commute, unlike the 3D rotations of 2.4.

    Used in the real world· Graphics: model, view and projection matrices, chained

    To draw a 3D scene, a game engine takes each vertex pp (a point of a model) and applies three maps in a row: the model matrix M1M_1 places the object in the world, the view matrix M2M_2 moves the world so the camera sits at the origin looking down the −z-z axis, and the projection matrix PP squeezes the 3D view into a flat image. Shifts are not linear, so the points are written in homogeneous coordinates (x,y,z,1)(x, y, z, 1), which lets a shift be a 4×44 \times 4 matrix. In 2D, rotating 90∘90^\circ and shifting by (5,2)(5, 2) is H=[0−15102001]H = \begin{bmatrix}0&-1&5\\1&0&2\\0&0&1\end{bmatrix}, and H(1,0,1)=(5,3,1)H(1, 0, 1) = (5, 3, 1); its inverse, the matrix a mouse-click needs, is H−1=[01−2−105001]H^{-1} = \begin{bmatrix}0&1&-2\\-1&0&5\\0&0&1\end{bmatrix}.

    The vertex shader on the GPU computes P M2 M1 pP\,M_2\,M_1\,p. Read it right to left: model first, projection last. A perspective matrix with near plane 11 and far plane 100100 (field of view 90∘90^\circ, square image) is

    P=[1000010000−10199−2009900−10].P = \begin{bmatrix}1&0&0&0\\0&1&0&0\\0&0&-\tfrac{101}{99}&-\tfrac{200}{99}\\0&0&-1&0\end{bmatrix}.

    A point (2,1,−4)(2, 1, -4) in front of the camera is (2,1,−4,1)(2, 1, -4, 1), and PP sends it to (2, 1, 20499, 4)(2,\ 1,\ \tfrac{204}{99},\ 4). The last coordinate 44 is the distance in front of the camera. Dividing by it gives the screen position (0.5, 0.25)(0.5,\ 0.25) and a depth of about 0.5150.515. That final division is the only non-linear step. Everything before it is matrix multiplication, so the three matrices can be multiplied together once, into PM2M1PM_2M_1. For a model of 100,000 vertices, multiplying each vertex by three separate 4×44 \times 4 matrices costs 3×16×100,000=4,800,0003 \times 16 \times 100{,}000 = 4{,}800{,}000 multiplications. Multiplying the matrices first costs 2×64=1282 \times 64 = 128 for the two matrix products, plus 16×100,00016 \times 100{,}000 for the vertices: about 1,600,0001{,}600{,}000, three times fewer. Associativity is what makes this legal.

    Used in the real world· Robotics: forward kinematics of a two-link arm

    A planar robot arm has a first link of length 22 at angle θ1\theta_1 from the xx-axis and a second link of length 11 at angle θ2\theta_2 relative to the first. The end of the second link, measured from the elbow, is R(θ2) (1,0)R(\theta_2)\,(1, 0) in the first link’s frame. Add the first link and rotate everything by θ1\theta_1: the hand is at

    p=R(θ1)[(2,0)+R(θ2)(1,0)].p = R(\theta_1)\big[(2, 0) + R(\theta_2)(1, 0)\big].

    For θ1=90∘\theta_1 = 90^\circ and θ2=−90∘\theta_2 = -90^\circ: R(−90∘)(1,0)=(0,−1)R(-90^\circ)(1, 0) = (0, -1), then (2,0)+(0,−1)=(2,−1)(2, 0) + (0, -1) = (2, -1), then R(90∘)(2,−1)=(1,2)R(90^\circ)(2, -1) = (1, 2). Check by drawing: link 1 points straight up to (0,2)(0, 2); link 2 turns 90∘90^\circ clockwise from it, so it points right and ends at (1,2)(1, 2). Inverse kinematics, going from the hand position back to the angles, asks for the inverse of this chain of rotations, applied in reverse order.

    Used in the real world· AI: why a neural network needs nonlinearities between layers

    A dense layer is a matrix. For handwritten digits (MNIST, 28×28=78428 \times 28 = 784 pixels), a network with a 128×784128 \times 784 matrix W1W_1 and then a 10×12810 \times 128 matrix W2W_2 computes W2(W1x)W_2(W_1x), which has 784×128+128×10=101,632784 \times 128 + 128 \times 10 = 101{,}632 weights. By associativity W2(W1x)=(W2W1)xW_2(W_1x) = (W_2W_1)x, and W2W1W_2W_1 is a single 10×78410 \times 784 matrix with only 7,8407{,}840 entries. Without a nonlinear function between the layers, the two layers collapse into one, and the second layer has added nothing. The matrix W2W1W_2W_1 also has rank at most 1010 (the second stretch problem), however large the middle layer is. That is why every deep network inserts a function such as ReLU between matrix products. CS 532 builds on exactly these shape-and-rank facts. A batch of 64 images is a 64×78464 \times 784 matrix XX, and the whole batch passes through the first layer in one product XW1TXW_1^{\mathsf T}, a 64×12864 \times 128 matrix. That one product is what GPUs are built to do fast.

    Traps

    Watch out· Columns, not rows

    The matrix of TT has the images T(ek)T(e_k) as its COLUMNS. Writing them as rows gives the transpose, which is a different map. On HW6 the answer key had a wrong first column in exactly this kind of problem (2.12 #6; the correct matrix is worked out in the Apostol 2.12 #6 problem below).

    Watch out· AB is not BA

    Even for square matrices of the same size. Spagnolie’s rotate-and-mirror example gives two different answers. And AB=OAB = O does not force A=OA = O or B=OB = O (the HW7 example AC=OAC = O above). So you cannot cancel a matrix from both sides of an equation the way you cancel a number, unless it is invertible.

    Watch out· Shapes: the inside numbers must match

    (m×p)(p×n)(m \times p)(p \times n) gives m×nm \times n. If ABAB exists, BABA may not exist, and if both exist they can have different sizes (2×22 \times 2 and 3×33 \times 3 in HW7 #1).

    Watch out· Reversed order: inverses and transposes

    (AB)−1=B−1A−1(AB)^{-1} = B^{-1}A^{-1} and (AB)T=BTAT(AB)^{\mathsf T} = B^{\mathsf T}A^{\mathsf T}. Both reverse the order. And B=C−1ACB = C^{-1}AC is not the same as B=CAC−1B = CAC^{-1}: which one you need depends on whether CC‘s columns are the NEW basis in OLD coordinates (then C−1ACC^{-1}AC) or the other way round. Check which way the coordinates go.

    Watch out· Same eigenvalues does not mean similar

    Similar matrices share many numbers, but sharing them does not make two matrices similar. (Eigenvalues are defined in chapter 2.8; for now, they are the numbers by which a map stretches the directions it only stretches, like 3 and 2 in the picture above.) [1101]\begin{bmatrix}1&1\\0&1\end{bmatrix} and II have the same characteristic polynomial (λ−1)2(\lambda - 1)^2, so the same eigenvalues, yet they are not similar (HW10 4.10 #1): C−1IC=IC^{-1}IC = I for every CC, so II is similar only to itself (see the prove problem on II below).

    Problems

    checkApostol 2.12 #11; MATH 375 HW6

    Let DD be differentiation on the span of sin⁡x\sin x and cos⁡x\cos x, with basis (sin⁡x,cos⁡x)(\sin x, \cos x). Find the matrix of DD and of D2D^2.

    Solution

    D(sin⁡x)=cos⁡xD(\sin x) = \cos x has coordinates (0,1)(0, 1), and D(cos⁡x)=−sin⁡xD(\cos x) = -\sin x has coordinates (−1,0)(-1, 0). So m(D)=[0−110]m(D) = \begin{bmatrix}0&-1\\1&0\end{bmatrix}. Then m(D)2=[0−110][0−110]=[−100−1]=−Im(D)^2 = \begin{bmatrix}0&-1\\1&0\end{bmatrix}\begin{bmatrix}0&-1\\1&0\end{bmatrix} = \begin{bmatrix}-1&0\\0&-1\end{bmatrix} = -I, which says D2=−idD^2 = -\mathrm{id}, i.e. f′′=−ff'' = -f for these functions.

    check

    AA is 2×32 \times 3 and BB is 3×43 \times 4. What are the sizes of ABAB and of BABA?

    Solution

    ABAB is 2×42 \times 4. BABA does not exist: BB has 4 columns and AA has 2 rows.

    check

    Compute [1234][0110]\begin{bmatrix}1&2\\3&4\end{bmatrix}\begin{bmatrix}0&1\\1&0\end{bmatrix} and [0110][1234]\begin{bmatrix}0&1\\1&0\end{bmatrix}\begin{bmatrix}1&2\\3&4\end{bmatrix}. What does each do to the first matrix?

    Solution

    The first product is [2143]\begin{bmatrix}2&1\\4&3\end{bmatrix}: multiplying on the right by the swap matrix swaps the COLUMNS. The second is [3412]\begin{bmatrix}3&4\\1&2\end{bmatrix}: multiplying on the left swaps the ROWS. (Right factor: columns of the product are combinations of columns of the left factor. Left factor: rows of the product are combinations of rows of the right factor.)

    checkApostol 2.12 #2(b)

    Find the matrix of the projection T:R3→R2T: \mathbb R^3 \to \mathbb R^2, T(x1,x2,x3)=(x2,x3)T(x_1, x_2, x_3) = (x_2, x_3) in the standard bases.

    Solution

    T(e1)=(0,0)T(e_1) = (0, 0), T(e2)=(1,0)T(e_2) = (1, 0), T(e3)=(0,1)T(e_3) = (0, 1), so m(T)=[010001]m(T) = \begin{bmatrix}0&1&0\\0&0&1\end{bmatrix} (2×32 \times 3). Check: it times (x1,x2,x3)(x_1, x_2, x_3) gives (x2,x3)(x_2, x_3).

    useApostol 2.16 #1; MATH 375 HW7

    For the matrices A,B,CA, B, C of the worked example above, compute A(2B−3C)A(2B - 3C) in two ways.

    Solution

    First, 2B−3C=[24−2610−4]−[663−33−9]=[−4−2−5975]2B - 3C = \begin{bmatrix}2&4\\-2&6\\10&-4\end{bmatrix} - \begin{bmatrix}6&6\\3&-3\\3&-9\end{bmatrix} = \begin{bmatrix}-4&-2\\-5&9\\7&5\end{bmatrix}. Then A(2B−3C)A(2B - 3C) has first row (1,−4,2)⋅(1,-4,2)\cdot columns: 1(−4)−4(−5)+2(7)=301(-4) - 4(-5) + 2(7) = 30 and 1(−2)−4(9)+2(5)=−281(-2) - 4(9) + 2(5) = -28. Row 2 is the negative: (−30,28)(-30, 28). Second way, using distributivity: A(2B−3C)=2AB−3AC=2[15−14−1514]−3O=[30−28−3028]A(2B - 3C) = 2AB - 3AC = 2\begin{bmatrix}15&-14\\-15&14\end{bmatrix} - 3O = \begin{bmatrix}30&-28\\-30&28\end{bmatrix}. Both agree.

    use

    Let A=[2112]A = \begin{bmatrix}2&1\\1&2\end{bmatrix} and let T(x)=AxT(x) = Ax. Find the matrix of TT in the basis f1=(1,1)f_1 = (1,1), f2=(1,−1)f_2 = (1,-1).

    Solution

    C=[111−1]C = \begin{bmatrix}1&1\\1&-1\end{bmatrix} and C−1=12[111−1]C^{-1} = \tfrac12\begin{bmatrix}1&1\\1&-1\end{bmatrix} (check: CC−1=ICC^{-1} = I). AC=[313−1]AC = \begin{bmatrix}3&1\\3&-1\end{bmatrix}. B=C−1AC=12[111−1][313−1]=12[6002]=[3001]B = C^{-1}AC = \tfrac12\begin{bmatrix}1&1\\1&-1\end{bmatrix}\begin{bmatrix}3&1\\3&-1\end{bmatrix} = \tfrac12\begin{bmatrix}6&0\\0&2\end{bmatrix} = \begin{bmatrix}3&0\\0&1\end{bmatrix}. Direct check: A(1,1)=(3,3)=3f1A(1,1) = (3,3) = 3f_1 and A(1,−1)=(1,−1)=1⋅f2A(1,-1) = (1,-1) = 1\cdot f_2.

    useApostol 2.12 #6; MATH 375 HW6 (corrected)

    For the map of the worked example with matrix A=[−1−121−33−1−55]A = \begin{bmatrix}-1&-1&2\\1&-3&3\\-1&-5&5\end{bmatrix}, find its matrix in the basis e1=(2,3,5)e_1 = (2,3,5), e2=(1,0,0)e_2 = (1,0,0), e3=(0,1,−1)e_3 = (0,1,-1) (same basis on both sides).

    Solution

    Compute each T(ek)T(e_k) with AA, then write it in the basis. T(e1)=A(2,3,5)=(−2−3+10, 2−9+15, −2−15+25)=(5,8,8)T(e_1) = A(2,3,5) = (-2-3+10,\ 2-9+15,\ -2-15+25) = (5, 8, 8). Solve ae1+be2+ce3=(5,8,8)a e_1 + b e_2 + c e_3 = (5,8,8): the second and third entries give 3a+c=83a + c = 8 and 5a−c=85a - c = 8, so a=2a = 2, c=2c = 2, and the first gives 2a+b=52a + b = 5, b=1b = 1. Column 1 is (2,1,2)(2, 1, 2). T(e2)=A(1,0,0)=(−1,1,−1)T(e_2) = A(1,0,0) = (-1, 1, -1): 3a+c=13a + c = 1, 5a−c=−15a - c = -1 give a=0a = 0, c=1c = 1, then b=−1b = -1. Column 2 is (0,−1,1)(0, -1, 1). T(e3)=A(0,1,−1)=(−3,−6,−10)T(e_3) = A(0, 1, -1) = (-3, -6, -10): 3a+c=−63a + c = -6, 5a−c=−105a - c = -10 give a=−2a = -2, c=0c = 0, then 2a+b=−32a + b = -3 gives b=1b = 1. Column 3 is (−2,1,0)(-2, 1, 0). So

    B=[20−21−11210].B = \begin{bmatrix}2&0&-2\\1&-1&1\\2&1&0\end{bmatrix}.

    This agrees with C−1ACC^{-1}AC for C=[21030150−1]C = \begin{bmatrix}2&1&0\\3&0&1\\5&0&-1\end{bmatrix} (one can verify that AC=CBAC = CB). The published key had T(i)T(i) wrong in an intermediate step and a wrong first column.

    use

    A game draws a sprite by rotating it 90∘90^\circ counterclockwise about the origin and then shifting it by (2,−1)(2, -1). Write the 3×33 \times 3 homogeneous matrix, apply it to the corner (3,1)(3, 1), and find the matrix that undoes it.

    Solution

    Rotation by 90∘90^\circ is [0−110]\begin{bmatrix}0&-1\\1&0\end{bmatrix}, so H=[0−1210−1001]H = \begin{bmatrix}0&-1&2\\1&0&-1\\0&0&1\end{bmatrix}. Then H(3,1,1)=(0−1+2, 3+0−1, 1)=(1,2,1)H(3, 1, 1) = (0 - 1 + 2,\ 3 + 0 - 1,\ 1) = (1, 2, 1), the point (1,2)(1, 2). To undo: subtract (2,−1)(2, -1), then rotate by −90∘-90^\circ, which is [01−10]\begin{bmatrix}0&1\\-1&0\end{bmatrix}. As matrices, H−1=[010−100001][10−2011001]=[011−102001]H^{-1} = \begin{bmatrix}0&1&0\\-1&0&0\\0&0&1\end{bmatrix}\begin{bmatrix}1&0&-2\\0&1&1\\0&0&1\end{bmatrix} = \begin{bmatrix}0&1&1\\-1&0&2\\0&0&1\end{bmatrix}. Check: H−1(1,2,1)=(2+1, −1+2, 1)=(3,1,1)H^{-1}(1, 2, 1) = (2 + 1,\ -1 + 2,\ 1) = (3, 1, 1), the corner we started with.

    proveApostol 3.6 #7(e); MATH 375 HW7 (2.21 #7)

    Prove that if AA is invertible then ATA^{\mathsf T} is invertible and (AT)−1=(A−1)T(A^{\mathsf T})^{-1} = (A^{-1})^{\mathsf T}.

    Solution

    Let B=A−1B = A^{-1}, so AB=IAB = I. Take transposes: (AB)T=IT=I(AB)^{\mathsf T} = I^{\mathsf T} = I. By ‘Transpose of a product’, (AB)T=BTAT(AB)^{\mathsf T} = B^{\mathsf T}A^{\mathsf T}, so BTAT=IB^{\mathsf T}A^{\mathsf T} = I. Likewise BA=IBA = I gives ATBT=IA^{\mathsf T}B^{\mathsf T} = I. So BTB^{\mathsf T} is a two-sided inverse of ATA^{\mathsf T}, and by uniqueness of the inverse (AT)−1=BT=(A−1)T(A^{\mathsf T})^{-1} = B^{\mathsf T} = (A^{-1})^{\mathsf T}.

    proveApostol 4.9

    Prove that similarity is an equivalence relation: (i) AA is similar to AA; (ii) if AA is similar to BB then BB is similar to AA; (iii) if AA is similar to BB and BB to DD then AA is similar to DD.

    Solution

    (i) A=I−1AIA = I^{-1}AI. (ii) If B=C−1ACB = C^{-1}AC, then multiplying by CC on the left and C−1C^{-1} on the right gives CBC−1=ACBC^{-1} = A. Write this as A=(C−1)−1B (C−1)A = (C^{-1})^{-1}B\,(C^{-1}), so AA is similar to BB via the invertible matrix C−1C^{-1}. (iii) If B=C−1ACB = C^{-1}AC and D=E−1BED = E^{-1}BE, then D=E−1C−1ACE=(CE)−1A(CE)D = E^{-1}C^{-1}ACE = (CE)^{-1}A(CE), using (CE)−1=E−1C−1(CE)^{-1} = E^{-1}C^{-1}. And CECE is invertible as a product of invertible matrices.

    proveSpagnolie Lecture 17

    Let B=C−1ACB = C^{-1}AC. Prove by induction that Bn=C−1AnCB^n = C^{-1}A^nC for every n≥1n \ge 1. Deduce An=CBnC−1A^n = CB^nC^{-1}.

    Solution

    For n=1n = 1 the claim is the hypothesis. Assume Bn−1=C−1An−1CB^{n-1} = C^{-1}A^{n-1}C. Then Bn=B Bn−1=(C−1AC)(C−1An−1C)=C−1A (CC−1) An−1C=C−1AnCB^n = B\,B^{n-1} = (C^{-1}AC)(C^{-1}A^{n-1}C) = C^{-1}A\,(CC^{-1})\,A^{n-1}C = C^{-1}A^nC, using associativity and CC−1=ICC^{-1} = I. For the second claim, multiply Bn=C−1AnCB^n = C^{-1}A^nC on the left by CC and on the right by C−1C^{-1}: CBnC−1=(CC−1)An(CC−1)=AnCB^nC^{-1} = (CC^{-1})A^n(CC^{-1}) = A^n.

    proveApostol 2.16 #9; MATH 375 HW7

    Let A=[10−11]A = \begin{bmatrix}1&0\\-1&1\end{bmatrix}. Prove A2=2A−IA^2 = 2A - I, then prove An=nA−(n−1)IA^n = nA - (n-1)I for all n≥1n \ge 1, and compute A100A^{100}.

    Solution

    A2=[10−21]A^2 = \begin{bmatrix}1&0\\-2&1\end{bmatrix} and 2A−I=[20−22]−[1001]=[10−21]2A - I = \begin{bmatrix}2&0\\-2&2\end{bmatrix} - \begin{bmatrix}1&0\\0&1\end{bmatrix} = \begin{bmatrix}1&0\\-2&1\end{bmatrix}. Equal. For the induction: n=1n = 1 gives A=1A−0IA = 1A - 0I. Assume An−1=(n−1)A−(n−2)IA^{n-1} = (n-1)A - (n-2)I. Then An=A An−1=(n−1)A2−(n−2)A=(n−1)(2A−I)−(n−2)A=nA−(n−1)IA^n = A\,A^{n-1} = (n-1)A^2 - (n-2)A = (n-1)(2A - I) - (n-2)A = nA - (n-1)I. For n=100n = 100: A100=100A−99I=[1000−100100]−[990099]=[10−1001]A^{100} = 100A - 99I = \begin{bmatrix}100&0\\-100&100\end{bmatrix} - \begin{bmatrix}99&0\\0&99\end{bmatrix} = \begin{bmatrix}1&0\\-100&1\end{bmatrix}. (Matches the pattern An=[10−n1]A^n = \begin{bmatrix}1&0\\-n&1\end{bmatrix}.)

    proveStrang

    Prove that similar matrices have the same trace, where the trace of a square matrix is the sum of its diagonal entries. (Hint: first prove tr⁡(PQ)=tr⁡(QP)\operatorname{tr}(PQ) = \operatorname{tr}(QP).)

    Solution

    tr⁡(PQ)=∑i(PQ)ii=∑i∑kpikqki\operatorname{tr}(PQ) = \sum_i (PQ)_{ii} = \sum_i\sum_k p_{ik}q_{ki}, and tr⁡(QP)=∑k∑iqkipik\operatorname{tr}(QP) = \sum_k\sum_i q_{ki}p_{ik}. These are the same finite double sum with the order of summation swapped and the numbers pikqkip_{ik}q_{ki} multiplied in the other order, so they are equal. Now if B=C−1ACB = C^{-1}AC, put P=C−1P = C^{-1} and Q=ACQ = AC: tr⁡(B)=tr⁡(C−1⋅AC)=tr⁡(AC⋅C−1)=tr⁡(A)\operatorname{tr}(B) = \operatorname{tr}(C^{-1}\cdot AC) = \operatorname{tr}(AC\cdot C^{-1}) = \operatorname{tr}(A).

    proveMATH 375 HW10 4.10 #1

    Prove that II is similar only to itself. Deduce that [1101]\begin{bmatrix}1&1\\0&1\end{bmatrix} is not similar to II.

    Solution

    If B=C−1ICB = C^{-1}IC, then B=C−1C=IB = C^{-1}C = I. So the only matrix similar to II is II. The shear [1101]\begin{bmatrix}1&1\\0&1\end{bmatrix} is not II, so it is not similar to II, although both have the eigenvalue 11 only.

    stretchAxler 3.D

    Let AA be an n×nn \times n matrix with AB=BAAB = BA for every n×nn \times n matrix BB. Prove A=cIA = cI for some number cc.

    Solution

    Use B=EijB = E_{ij} (the matrix with a single 11 in row ii, column jj). Computing entries, (AEij)kl=∑makm(Eij)ml=aki(AE_{ij})_{kl} = \sum_m a_{km}(E_{ij})_{ml} = a_{ki} if l=jl = j and 00 otherwise. Likewise (EijA)kl=ajl(E_{ij}A)_{kl} = a_{jl} if k=ik = i and 00 otherwise. Since AEij=EijAAE_{ij} = E_{ij}A, compare entries. Take l=jl = j and k≠ik \ne i: aki=0a_{ki} = 0. So every off-diagonal entry of AA is 00 (any off-diagonal pair (k,i)(k, i) with k≠ik \ne i arises). Take k=ik = i, l=jl = j: aii=ajja_{ii} = a_{jj}. So all diagonal entries are equal, to some cc, and A=cIA = cI.

    stretch

    Prove that rank⁡(ST)≤min⁡(rank⁡S, rank⁡T)\operatorname{rank}(ST) \le \min(\operatorname{rank} S,\ \operatorname{rank} T) for linear maps T:U→VT: U \to V and S:V→WS: V \to W with finite-dimensional domains. Why does this bound the rank of W2W1W_2W_1 in the neural-network example?

    Solution

    The range of STST is S(T(U))S(T(U)), which lies inside S(V)S(V), the range of SS. A subspace of S(V)S(V) has dimension at most dim⁡S(V)\dim S(V) (a problem in 2.2), so rank⁡(ST)≤rank⁡S\operatorname{rank}(ST) \le \operatorname{rank} S. For the other bound, restrict SS to the subspace X=T(U)X = T(U) of VV. The restricted map S∣X:X→WS|_X: X \to W is linear, and by rank–nullity its range has dimension dim⁡X−dim⁡N(S∣X)≤dim⁡X\dim X - \dim N(S|_X) \le \dim X. Its range is S(T(U))S(T(U)), so rank⁡(ST)≤dim⁡T(U)=rank⁡T\operatorname{rank}(ST) \le \dim T(U) = \operatorname{rank} T. In the network, W1W_1 is 128×784128 \times 784 and W2W_2 is 10×12810 \times 128, so rank⁡(W2W1)≤rank⁡W2≤10\operatorname{rank}(W_2W_1) \le \operatorname{rank} W_2 \le 10, because the range of W2W_2 sits inside R10\mathbb R^{10}.

    Summary

    • The matrix of a linear map relative to bases has T(ek)T(e_k), written in the target basis, as its kkth column. Its shape is (target dimension) by (source dimension).
    • Matrix times vector is a combination of the columns, with the vector’s coordinates as the weights. The map T↦m(T)T \mapsto m(T) is an isomorphism from L(V,W)L(V, W) to Rm×n\mathbb R^{m \times n}, so dim⁡L(V,W)=mn\dim L(V, W) = mn.
    • Matrix multiplication is composition. Column jj of ABAB is AA times column jj of BB, which gives the row-times-column rule. It is associative and distributive, and generally not commutative, and the inside sizes must match.
    • The identity matrix does nothing. (AB)−1=B−1A−1(AB)^{-1} = B^{-1}A^{-1} and (AB)T=BTAT(AB)^{\mathsf T} = B^{\mathsf T}A^{\mathsf T} both reverse the order. A 2×22 \times 2 matrix is invertible exactly when ad−bc≠0ad - bc \ne 0.
    • The change-of-basis matrix CC has the new basis, in old coordinates, as its columns. It converts new coordinates to old ones: [x]E=C[x]F[x]_{\mathcal E} = C[x]_{\mathcal F}.
    • The matrix of the same map in the new basis is B=C−1ACB = C^{-1}AC: similar matrices are one map in two languages. Powers become easy when BB is diagonal: An=CBnC−1A^n = CB^nC^{-1}.
    • With separate bases on input and output, a map of rank rr has a matrix with rr ones on the diagonal and zeros elsewhere. With one shared basis you often cannot reach that, and finding the best basis is the subject of chapter 2.8.

    Watch and read

    The same ideas explained by someone else. Use these when an explanation here does not land.

    Where this sits

    Comes from
    2.3 Linear maps, null space, range, rank–nullity
    2.4 Inverses, one-to-one maps, isomorphism
    Leads to
    2.6 Systems of equations and elimination
    2.7 Determinants
    2.8 Eigenvalues and eigenvectors
    Same idea elsewhere
    CS 532: CS 532 (matrix methods in machine learning) treats every data set as a matrix and every model layer as a matrix product. The rules here (shapes, order, columns as images of basis vectors, low rank) are what it assumes from the first week.
    MATH 340: MATH 340 begins with matrix arithmetic and row reduction. Here the arithmetic is derived from composing maps, so the rules (associative, not commutative, reversed order for inverses and transposes) come with reasons.
    MATH 376: The solution of a linear system of differential equations y' = Ay is written with the matrix exponential of A. Computing it is easy only after a change of basis to a diagonal matrix, as previewed at the end of this chapter.