Ten problems on linear maps and their matrices: a matrix built from the images of e₁ and e₂, a test for linearity, rotations and reflections composed in both orders, a projection with its kernel, image and rank–nullity count, coordinates in a new basis, a reflection across y = 2x built from diag(1, −1), the matrix of a map in a new basis two ways, what similar matrices share, the determinant as an area scale and an orientation, and PCA coordinates and whitening in an orthonormal basis, with worked solutions and the mistakes of writing the images as rows, composing in reading order, multiplying by P instead of P⁻¹, using Pᵀ for P⁻¹ when the basis is not orthonormal and treating x ↦ Ax + b as linear.
Before you start
A matrix is a linear map written down in a particular basis. Change the basis and the same map gets a different matrix, sometimes a much simpler one: a reflection across a slanted line becomes ,diag(1,−1), and a covariance matrix becomes diagonal in the coordinates PCA picks. These ten problems build the matrix of a map from what it does to the standard basis, test whether a map is linear at all, compose maps in the right order, take a projection apart into its kernel and image, and then change basis, first for a single vector and then for a whole map. They end with the determinant as an area scale and with PCA coordinates and whitening. The five mistakes at the end are the ones that still produce a matrix: the images written as rows, a composition multiplied in reading order, coordinates found with P instead of ,P−1,P⊤ used as P−1 for a basis that is not orthonormal, and an affine map treated as linear.
Vectors are columns; (3,−2)⊤ is the column with entries 3 and ,−2, written on one line to save space. e1=(1,0)⊤ and e2=(0,1)⊤ are the standard basis of .R2.
A map T:Rn→Rm is linear when T(u+v)=T(u)+T(v) and T(cu)=cT(u) for all vectors u,v and numbers .c. Then T(x)=Ax for the m×n matrix A whose column j is .T(ej).
AB means “apply ,B, then A”: .(AB)x=A(Bx).
The kernel of A is ,{x:Ax=0}, the image is ,{Ax}, and for A with n columns, dimkerA+rankA=n (rank–nullity).
A basis B={b1,…,bn} of Rn has basis matrix,P=[b1⋯bn], with the basis vectors as columns. The coordinates[v]B=c are the numbers with ,v=c1b1+⋯+cnbn, that is ,Pc=v, so .[v]B=P−1v.
The matrix of a linear map T(x)=Ax in the basis B is :[T]B=P−1AP: its column j is .[T(bj)]B. Matrices A and P−1AP are called similar.
A basis is orthonormal when its vectors have length 1 and are pairwise orthogonal; then ,P⊤P=I, so .P−1=P⊤.
For 2×2 matrices, [acbd]−1=ad−bc1[d−c−ba] when .ad−bc=0.
Let R rotate the plane by 90∘ counterclockwise and F reflect it across the x-axis. Find ,R,,F,RF and ,FR, and describe each product geometrically. Which one is “reflect first, then rotate”?
··
Let Π be the orthogonal projection onto the line through ,u=(1,2)⊤, so .Πx=u⊤uu⊤xu. Find the matrix of ,Π, its kernel and image, and check rank–nullity and .Π2=Π.
··
Let B={b1,b2} with b1=(1,1)⊤ and .b2=(1,2)⊤. Find the coordinates [v]B of ,v=(3,5)⊤, and check them.
···
Find the matrix, in the standard basis, of the reflection T across the line .y=2x. Use a basis in which T is .diag(1,−1).
···
Let A=[1023] and use the basis B of Problem 5. Find [T]B for T(x)=Ax in two ways: column by column from ,[T(bj)]B, and as .P−1AP.
··
Show that similar matrices A and P−1AP have the same characteristic polynomial, and hence the same eigenvalues, trace and determinant. Then show that I and N=[1011] have the same trace and determinant but are not similar.
··
Let .A=[1231]. What is the area of the image of the triangle with vertices ,(0,0),(1,0) and ?(0,1)? Does A keep or reverse orientation? What is the area scale factor of ,RA, with R the rotation of Problem 3?
···
A two-feature data set has covariance .Σ=[5222]. Its unit eigenvectors are q1=(2,1)⊤/5 and .q2=(1,−2)⊤/5. With ,Q=[q1q2], find the PCA coordinates c=[x]Q of ,x=(1,3)⊤, the covariance of the data in those coordinates, and the whitened coordinates ,z=Λ−1/2c, where Λ is the diagonal matrix of eigenvalues.
Answers
;A=[21−13];T((3,−2)⊤)=(8,−3)⊤
Only T3 is linear, with matrix ;[21−10];T1 is affine, not linear, and T2 is not linear
,RF=[0110], reflection across ,y=x, is “reflect, then rotate”; ,FR=[0−1−10], reflection across ,y=−x, is “rotate, then reflect”
,det(P−1AP−λI)=det(A−λI), so eigenvalues, trace and determinant are shared; I and N share them but are not similar, because I is similar only to itself
Area ;25;A reverses orientation ();detA=−5);RA also scales areas by 5 and reverses orientation
;c=(5,−5)⊤; covariance ,diag(6,1), uncorrelated; z=(5/6,−5)⊤≈(0.913,−2.236)⊤ with covariance I
Worked solutions
Problem 1
A linear map T:R2→R2 sends e1 to (2,1)⊤ and e2 to .(−1,3)⊤. Find its matrix A and .T((3,−2)⊤).
.(3,−2)⊤=3e1−2e2.Every vector is a combination of the standard basis, with its entries as the coefficients.
.T((3,−2)⊤)=3T(e1)−2T(e2).Linearity: T of a combination is the same combination of the images.
.=3(2,1)⊤−2(−1,3)⊤=(8,−3)⊤..(6+2,3−6).
.A=[21−13].Column j is ,T(ej), so Aej picks out exactly that image.
;A=[21−13];T((3,−2)⊤)=(8,−3)⊤Check: A(3,−2)⊤ has rows 2⋅3+(−1)(−2)=8 and .1⋅3+3(−2)=−3. Two images determine the whole map: that is what linearity buys.
Problem 2
Which of these maps R2→R2 are linear? For each linear one, give its matrix.
.T1(0,0)=(0,1).A linear map sends 0 to ,0, because .T(0)=T(0⋅0)=0⋅T(0)=0.T1 fails, because of the constant .+1.
T2(−1,0)=(1,0) but .−T2(1,0)=(−1,0).Scaling by c=−1 is not preserved, so T2 is not linear, even though .T2(0)=0.
T3 is linear: each output entry is a combination of x and y with no constant.Then both rules hold entry by entry.
,T3(e1)=(2,1)⊤,.T3(e2)=(−1,0)⊤.Read off with (x,y)=(1,0) and .(0,1).
Only T3 is linear, with matrix ;[21−10];T1 is affine, not linear, and T2 is not linearT1(x)=Ax+b with .b=(0,1)⊤. A dense layer Wx+b is affine in the same way; it becomes linear only with ,b=0, or after appending a constant 1 to .x.
Problem 3
Let R rotate the plane by 90∘ counterclockwise and F reflect it across the x-axis. Find ,R,,F,RF and ,FR, and describe each product geometrically. Which one is “reflect first, then rotate”?
.R=[01−10].R(e1)=e2=(0,1)⊤ and R(e2)=−e1=(−1,0)⊤ are its columns.
.F=[100−1].F keeps e1 and sends e2 to .−e2.
.RF=[0110].Row times column; or by columns: RFe1=Re1=e2 and .RFe2=R(−e2)=e1.
RF swaps x and :y: it is the reflection across .y=x..RF(x,y)⊤=(y,x)⊤.
,FR=[0−1−10], so :FR(x,y)⊤=(−y,−x)⊤: the reflection across .y=−x.FRe1=Fe2=−e2 and .FRe2=F(−e1)=−e1.
,RF=[0110], reflection across ,y=x, is “reflect, then rotate”; ,FR=[0−1−10], reflection across ,y=−x, is “rotate, then reflect”:(RF)x=R(Fx): the factor next to x acts first. Matrix products are composed right to left, and .RF=FR. Both have determinant ,−1, as a rotation times a reflection must.
Problem 4
Let Π be the orthogonal projection onto the line through ,u=(1,2)⊤, so .Πx=u⊤uu⊤xu. Find the matrix of ,Π, its kernel and image, and check rank–nullity and .Π2=Π.
.Πx=u⊤uu(u⊤x)=u⊤uuu⊤x.A scalar times a vector can be written with the scalar on the right, and .u(u⊤x)=(uu⊤)x.
.Π=51[1224].u⊤u=1+4=5 and uu⊤ has entries .uiuj.
.kerΠ=span{(2,−1)⊤}.Πx=0 exactly when :u⊤x=x1+2x2=0: the vectors orthogonal to .u.
,imΠ=span{u}, so .rankΠ=1.Every output is a multiple of ,u, and ,Πu=u, so every multiple is reached.
,1+1=2, the number of columns.Rank–nullity: .dimkerΠ+rankΠ=n.
.Π2=(u⊤u)2u(u⊤u)u⊤=u⊤uuu⊤=Π.u⊤u is a number and cancels once. Projecting a second time changes nothing.
;Π=51[1224];;kerΠ=span{(2,−1)⊤};;imΠ=span{(1,2)⊤};;1+1=2;Π2=Π:detΠ=(4−4)/25=0: a projection that loses a direction squashes area to zero, and cannot be undone.
Problem 5
Let B={b1,b2} with b1=(1,1)⊤ and .b2=(1,2)⊤. Find the coordinates [v]B of ,v=(3,5)⊤, and check them.
.P=[1112].The basis vectors are the columns.
,detP=2−1=1, so .P−1=[2−1−11].The 2×2 inverse, with nothing to divide by. ,detP=0, so b1,b2 really are a basis.
.1⋅b1+2⋅b2=(1+2,1+4)⊤=(3,5)⊤.The check multiplies by ,P, the reverse direction.
:[v]B=(1,2)⊤:v=b1+2b2P turns B-coordinates into standard ones; P−1 goes the other way. In the standard basis the coordinates of v are its entries, ;(3,5); in B the same vector is .(1,2).
Problem 6
Find the matrix, in the standard basis, of the reflection T across the line .y=2x. Use a basis in which T is .diag(1,−1).
Take b1=(1,2)⊤ on the line and b2=(−2,1)⊤ perpendicular to it..b1⊤b2=−2+2=0. The reflection keeps the line and flips the perpendicular direction.
T(b1)=b1 and ,T(b2)=−b2, so .[T]B=diag(1,−1)=D.Column j of [T]B is :[T(bj)]B: here (1,0)⊤ and .(0,−1)⊤.
A=PDP−1 with .P=[12−21].,[T]B=P−1AP, solved for :A: multiply by P on the left and P−1 on the right.
,detP=1+4=5, so .P−1=51[1−221].The 2×2 inverse. The columns of P are orthogonal but have length ,5, so ,P−1=51P⊤, not .P⊤.
.PD=[122−1].D on the right scales column 2 of P by .−1.
.PDP−1=51[1−42+22+24−1].Row times column with ,[1−221], then the .51.
A=51[−3443]Checks: ,A(1,2)⊤=51(5,10)⊤=(1,2)⊤,,A(−2,1)⊤=(2,−1)⊤,A2=I and .detA=−1. It matches the formula for the reflection across a line at angle ,φ, with cos2φ=−53 and sin2φ=54 when .tanφ=2.
Problem 7
Let A=[1023] and use the basis B of Problem 5. Find [T]B for T(x)=Ax in two ways: column by column from ,[T(bj)]B, and as .P−1AP.
.T(b1)=A(1,1)⊤=(3,3)⊤=3b1+0b2.So column 1 of [T]B is .(3,0)⊤.b1 happens to be an eigenvector of .A.
.T(b2)=A(1,2)⊤=(5,6)⊤.Row times column: 1+4 and .0+6.
.[T(b2)]B=P−1(5,6)⊤=(10−6,−5+6)⊤=(4,1)⊤.P−1 from Problem 5. Check: .4b1+b2=(5,6)⊤.
.AP=[3356].Its columns are T(b1) and ,T(b2), from steps 1 and 2.
.P−1(AP)=[6−3−3+310−6−5+6].Row times column with ;P−1=[2−1−11]; this applies P−1 to each column of ,AP, which is step 3 done for both columns at once.
[T]B=[3041] both waysBoth A and [T]B have trace 4 and determinant ,3, so the same eigenvalues 1 and :3: they are one map written in two bases. Read right to left, P−1AP says: turn B-coordinates into standard ones (),P), apply the map (),A), turn the result back into B-coordinates ().P−1).
Problem 8
Show that similar matrices A and P−1AP have the same characteristic polynomial, and hence the same eigenvalues, trace and determinant. Then show that I and N=[1011] have the same trace and determinant but are not similar.
.P−1AP−λI=P−1(A−λI)P.,λI=λP−1P=P−1(λI)P, then factor.
.det(P−1(A−λI)P)=detP−1det(A−λI)detP=det(A−λI).det of a product is the product of the dets, and .detP−1=1/detP.
The eigenvalues are the roots of the characteristic polynomial, and for a 2×2 matrix it is .λ2−(trA)λ+detA.So equal polynomials mean equal eigenvalues, trace and determinant; for n×n the trace and determinant are still coefficients of the polynomial.
trI=trN=2 and .detI=detN=1.Both are triangular with diagonal .(1,1).
P−1IP=P−1P=I for every invertible .P.So the only matrix similar to I is I itself, and .N=I.
,det(P−1AP−λI)=det(A−λI), so eigenvalues, trace and determinant are shared; I and N share them but are not similar, because I is similar only to itselfEqual invariants are necessary for similarity, not sufficient. N is the shear of the eigenvalues page: it has one eigenvector direction where I has two.
Problem 9
Let .A=[1231]. What is the area of the image of the triangle with vertices ,(0,0),(1,0) and ?(0,1)? Does A keep or reverse orientation? What is the area scale factor of ,RA, with R the rotation of Problem 3?
.detA=1−6=−5..ad−bc.
A linear map scales every area by .∣detA∣.It sends the unit square to the parallelogram spanned by its columns, whose area is ,∣detA∣, and every region is a limit of small squares.
The image triangle has area .5⋅21=25.The original triangle has area .21. Its image has vertices ,(0,0),(1,2) and ,(3,1), and 21∣1⋅1−3⋅2∣=25 directly.
,detA<0, so A reverses orientation.Going (0,0)→(1,0)→(0,1) is counterclockwise; the image path (0,0)→(1,2)→(3,1) turns clockwise.
.det(RA)=detRdetA=1⋅(−5)=−5.A rotation has determinant :1: it keeps both area and orientation.
Area ;25;A reverses orientation ();detA=−5);RA also scales areas by 5 and reverses orientationThe sign of the determinant records orientation and its size records the area scale. In a normalizing flow, log∣det∣ of each layer's Jacobian is exactly this area (volume) scale, and it enters the log-likelihood.
Problem 10
A two-feature data set has covariance .Σ=[5222]. Its unit eigenvectors are q1=(2,1)⊤/5 and .q2=(1,−2)⊤/5. With ,Q=[q1q2], find the PCA coordinates c=[x]Q of ,x=(1,3)⊤, the covariance of the data in those coordinates, and the whitened coordinates ,z=Λ−1/2c, where Λ is the diagonal matrix of eigenvalues.
Σq1=(12,6)⊤/5=6q1 and ,Σq2=(1,−2)⊤/5=q2, so .Λ=diag(6,1).Check the eigenvectors before using them: (10+2,4+2) and .(5−4,2−4).
q1⊤q2=(2−2)/5=0 and ,q1⊤q1=q2⊤q2=1, so .Q−1=Q⊤.The basis is orthonormal, so no inverse needs computing.
.c=Q⊤x=((2+3)/5,(1−6)/5)⊤=(5,−5)⊤.Each coordinate is a dot product .qj⊤x. Check: ,∥c∥2=10=∥x∥2, since an orthonormal change of basis keeps lengths.
In Q-coordinates the data are ,c=Q⊤x, with covariance .Q⊤ΣQ.For a linear map ,M,;Cov(Mx)=MΣM⊤; here .M=Q⊤.
.Q⊤ΣQ=Q−1ΣQ=Λ=diag(6,1).This is [T]Q for :T(x)=Σx: in the eigenvector basis the matrix is diagonal.
.z=Λ−1/2c=(5/6,−5)⊤≈(0.913,−2.236)⊤.Divide coordinate j by ;λj; its covariance is .Λ−1/2ΛΛ−1/2=I.
;c=(5,−5)⊤; covariance ,diag(6,1), uncorrelated; z=(5/6,−5)⊤≈(0.913,−2.236)⊤ with covariance IPCA is a change to an orthonormal basis that diagonalizes ;Σ; whitening then rescales each new axis to variance .1. The rescaling is not orthogonal, so .∥z∥=∥x∥.
Where this goes wrong
1. Images written as rows
The images T(e1) and T(e2) are usually listed one after the other, and it is natural to write them into the matrix the same way, line by line.
,T(e1)=(2,1)⊤,T(e2)=(−1,3)⊤Right so far: Problem 1.
“Write the first image in the first row and the second in the second.”The habit that causes the mistake: filling a matrix row by row, the way it is read.
,A=[2−113], so T((3,−2)⊤)=(4,−9)⊤That is .A⊤.Ae1 is the first column of ,A, so the images must be columns; the right answer is .(8,−3)⊤. The check is cheap: multiply the matrix by e1 and see whether T(e1) comes out.
2. Composing in reading order
“Reflect, then rotate” names the reflection first, and the product is easy to write in the same order.
R=[01−10] and F=[100−1]Right so far: Problem 3.
“Reflect, then rotate: F then ,R, so .FR.”The habit that causes the mistake: writing the factors left to right in the order they happen.
“Reflect, then rotate” ,=FR, which sends e1 to (0,−1)⊤(FR)x=F(Rx) rotates first. Reflecting e1 across the x-axis leaves it alone, and rotating gives ,(0,1)⊤, so the right product is RF (Problem 3). The factor nearest x acts first: in a network ,W2W1x, the layer W1 is applied first.
3. Coordinates found with P instead of P⁻¹
P is the matrix that comes with the basis, and multiplying by it is the obvious thing to do with a new basis.
P=[1112] and v=(3,5)⊤Right so far: Problem 5.
“To express v in the new basis, apply the basis matrix to it.”The shortcut that causes the mistake: P goes from B-coordinates to standard ones, not the other way.
[v]B=Pv=(8,13)⊤Then ,8b1+13b2=(21,34)⊤, not .v. The coordinates solve ,Pc=v, so [v]B=P−1v=(1,2)⊤ (Problem 5). Rebuilding v from the claimed coordinates catches the error at once.
4. Pᵀ used as P⁻¹ for a basis that is not orthonormal
Orthogonal basis vectors look like the case where the inverse is the transpose.
,P=[12−21], with orthogonal columns, and v=(3,1)⊤Right so far: the basis of Problem 6.
“The columns are orthogonal, so .P−1=P⊤.”The rule that causes the mistake: P⊤P=I needs columns of length 1 as well, and these have length .5.
[v]B=P⊤v=(5,−5)⊤,P⊤P=5I, so P−1=51P⊤ and :[v]B=(1,−1)⊤: indeed .b1−b2=(3,1)⊤. The transpose gives coordinates 5 times too large, and .5b1−5b2=(15,5)⊤. Normalize the basis first, as in Problem 10, or divide by the squared lengths.
5. An affine map treated as linear
The recipe “column j is T(ej)” works so reliably that it gets applied before checking that the map is linear.
,T1(x,y)=(x+2y,3x−y+1), so T1(e1)=(1,4)⊤ and T1(e2)=(2,0)⊤Right so far: the map of Problem 2, evaluated correctly.
“Put the images in the columns.”The habit that causes the mistake: the recipe assumes linearity, and .T1(0)=(0,1)⊤=0.
,T1=[1420], so T1(1,1)=(3,4)The true value is .T1(1,1)=(3,3). Each column carries the constant ,b, so the matrix applied to (1,1)⊤ adds it twice, where T1 adds it once. The map is Ax+b with A=[132−1] and :b=(0,1)⊤: read A from .T(ej)−T(0).