Proposition (matrix of a linear map). Let V,W be vector spaces with bases v1,…,vn and w1,…,wm respectively, and let f:V→W be linear. Then there is a unique m×n-matrix A=(aij), the matrix associated to f with respect to the given bases, such that
f(vi)=j=1∑majiwj(i=1,…,n).
We write Mf,v,w:=(aij), where v={v1,…,vn} and w={w1,…,wm}.
In words: the i-th column of Mf,v,w contains the coordinates of f(vi) with respect to the basis w. For a general vector v=∑i=1nbivi,
f(v)=i=1∑nj=1∑mbiajiwj,
i.e. the coordinates of f(v) are obtained by multiplying the matrix with the coordinate column (b1,…,bn)T.
Proof. Each f(vi)∈W can be written in a unique way as a linear combination of the basis w1,…,wm (uniqueness of coordinates). This gives the existence and uniqueness of the aji. For general v, using linearity,
With bases v1,v2,v3 (domain) and w1,w2,w3 (codomain) the matrix is the identity 100010001, since f(vi)=wi.
With the standard basis e1,e2,e3 in the domain and w1,w2,w3 in the codomain: f(e1)=w1, f(e2)=w2, f(e3)=−w2+w3, so the matrix is
1000100−11.
For instance the third column expresses f(e3)=a13w1+a23w2+a33w3=−w2+w3.
So the matrix depends not only on f but also on the choice of the bases of V and W.
Example (rotation in a non-standard basis). Let A=(01−10) and f:R2→R2, (x,y)↦(−y,x) (rotation by 90∘). Take the basis v1=(1,0), v2=(1,1).
Matrix with respect to v in the domain and the standard basis in the codomain: v1=1e1+0e2 and v2=1e1+1e2, so by linearity
f(v1)=f(e1)=(0,1)=0e1+1e2,f(v2)=f(e1)+f(e2)=(0,1)+(−1,0)=(−1,1)=−1e1+1e2,
and the matrix is (01−11).
Matrix with respect to v in both domain and codomain: express (0,1)=−v1+v2 and (−1,1)=−2v1+v2. So f(v1)=−v1+v2, f(v2)=−2v1+v2 and the matrix is
(−11−21).
2. Composing linear maps and multiplying matrices
Definition and Lemma. Let f:U→V and g:V→W be linear maps. The composition is g∘f:U→W, u↦g(f(u)). It is again linear.
Proof. For u,u′∈U and a∈R, using linearity of f and of g:
Example.f:R2→R, (x,y)↦x and g:R→R3, x↦(x,0,x) are linear, and g∘f:(x,y)↦g(x)=(x,0,x). With h:R→R2, x↦(x,x) we get h∘f:(x,y)↦(x,x) and f∘h:R→R, x↦f(x,x)=x. The composition f∘g is not defined, since g takes values in R3 but f is defined on R2.
2.1 The matrix product
Definition. If A=(aij) is an m×n-matrix and B=(bij) is an n×k-matrix, the product AB is the m×k-matrix whose entry in row i and column j is
e=1∑naiebej=ai1b1j+ai2b2j+⋯+ainbnj.
One picks the i-th row of A and the j-th column of B, multiplies corresponding entries and adds. The product is defined only if the number of columns of A equals the number of rows of B.
A 2×3 matrix times a 3×2 matrix is a 2×2 matrix, while the same two matrices multiplied in the other order give a 3×3 matrix. A 3×2 matrix times a 3×2 matrix is not defined at all.
Proposition (composition = product). Let A be an m×n-matrix with map f:Rn→Rm, v↦Av, and let B be an n×l-matrix with map g:Rl→Rn, u↦Bu. Then f∘g:Rl→Rm is the map u↦(AB)u.
Proposition (matrices of a composition). Let f:U→V and g:V→W be linear with bases u1,…,ul, v1,…,vm, w1,…,wn of U,V,W. If A is the matrix of f (bases of U and V) and B the matrix of g (bases of V and W), then BA is the matrix of g∘f with respect to the bases of U and W. (Proved with similar arguments.)
2.2 Properties of matrix multiplication
Warning: the product depends on the order. For square matrices A,B in general AB=BA.
This is best understood through composition: for linear maps f,g:Rn→Rn in general g∘f=f∘g. For instance let f be the reflection at the x-axis and g the counterclockwise rotation by 90∘. For w=(x,y): g(f(w))=g(x,−y)=(y,x) but f(g(w))=f(−y,x)=(−y,−x). In matrices, (01−10)(100−1)=(0110) whereas the other order gives (0−1−10). (Doing sports then showering is not the same as showering then doing sports.)
Identity matrix. The identity matrix idn is the n×n matrix whose entries on the main diagonal (north-west to south-east) are all 1 and all other entries 0; id1=(1) and id2=(1001).
Lemma. For matrices A,B,C of sizes such that the products and sums are defined, and r∈R:
id⋅A=A and A⋅id=A (the identity plays the role of the number 1);
A(B+C)=AB+AC and (A+B)C=AC+BC (distributivity);
(AB)C=A(BC) (associativity);
r(AB)=(rA)B=A(rB).
Proof (illustrated for the first distributivity law). Let A be m×n and B,C be n×k. Then B+C=(bij+cij) and the (i,j) entry of A(B+C) is
where the distributivity law for real numbers was used. This is the (i,j) entry of AB+AC. The other identities follow in the same way from the corresponding laws for real numbers. □
2.3 Elementary matrices
Elementary row operations can be recast as multiplication with matrices. (An "invisible" entry of a matrix is zero.)
Proposition. Let A be an m×n-matrix.
If A′ is obtained from A by interchanging rows i and j, then A′=Ei,j(1)A, where Ei,j(1) is the m×m matrix obtained from idm by exchanging its i-th and j-th rows.
If A′ is obtained by multiplying row i by r∈R, then A′=Ei,r(2)A, where Ei,r(2) is idm with the (i,i)-entry replaced by r.
If A′ is obtained by adding r times row j to row i, then A′=Ei,j,r(3)A, where Ei,j,r(3) is idm with the (i,j)-entry replaced by r.
The matrices Ei,j(1), Ei,r(2) (with r=0) and Ei,j,r(3) are called elementary matrices. For example, for m=3:
E1,3,r(3)=100010r01,E1,3,r(3)A has first row (row 1)+r(row 3).
Proof of the third statement. Let B=Ei,j,r(3), so bii=1, bij=r and all other entries on row i are zero; the other rows are those of the identity. Let C=BA=(cst), cst=∑e=1mbseaet.
If s=i, the only non-zero bse is bss=1, so cst=ast.
If s=i, the non-zero coefficients are bii=1 and bij=r, so cit=ait+rajt.
Thus the i-th row of C is row i of A plus r times row j of A, and the other rows are unchanged. □
3. Invertible matrices
Definition. Let A be an n×n-matrix. An n×n-matrix B is an inverse of A if AB=id and BA=id. If such a B exists, A is called invertible.
Example.A=(0111) is invertible with inverse B=(−1110):
A 1×1 matrix (a) is invertible precisely if a=0 (inverse (a−1)). For larger matrices being non-zero is not enough:
Example (a non-invertible matrix).A=(1224) is not invertible. For an arbitrary B=(acbd),
AB=(a+2c2a+4cb+2d2b+4d).
AB=id would require a+2c=1, b+2d=0, 2a+4c=0, 2b+4d=1. Multiplying the first equation by 2 gives 2a+4c=2, and the third equation then yields the contradiction 0=2. Hence no such B exists. Observe that the two rows (and the two columns) of A are linearly dependent; this is no accident, see the criteria below.
The geometric matrices and their inverses.
Geometrical description
Matrix A
Inverse A−1
Reflection at the x-axis
(100−1)
(100−1)
Reflection at the y-axis
(−1001)
(−1001)
Rescaling (if r,s=0; if r=0 or s=0 then A is not invertible)
Lemma (uniqueness of the inverse). An invertible matrix has exactly one inverse: if B and C are inverses of A (AB=BA=id and AC=CA=id), then B=C. One writes A−1.
Proof. Using associativity (marked !): B=Bid=B(AC)=!(BA)C=idC=C. □
Theorem (linear systems with invertible matrix). Let A be an invertible n×n-matrix. The system Ax=b (with x=(x1,…,xn)T unknown and b∈Rn) has a unique solution, namely
x=A−1b.
Proof.A−1b is a solution: A(A−1b)=!(AA−1)b=idnb=b (associativity, with b regarded as an n×1-matrix). It is the only solution: let y be any solution, Ay=b, and put z:=A−1b−y. Then Az=AA−1b−Ay=b−b=0, and multiplying by A−1: z=A−1Az=A−10=0. So y=A−1b. □
Theorem (rules for inverses). For square matrices of the same size:
Statement
For 1×1-matrices
id is invertible: id−1=id
1−1=1
If A is invertible, so is A−1 and (A−1)−1=A
1/(1/a)=a
If A,B are invertible, so is AB and (AB)−1=B−1A−1
1/(ab)=(1/b)(1/a)
(A1⋯Ak)−1=Ak−1⋯A1−1
1/(a1⋯ak)=(1/ak)⋯(1/a1)
Proof of (AB)−1=B−1A−1.(AB)(B−1A−1)=A(BB−1)A−1=AA−1=id by associativity and since B−1, A−1 are inverses; likewise (B−1A−1)(AB)=id. □
Note that the order is reversed; since AB=BA in general this matters (only for 1×1 matrices does the order not matter).
Proof (for the last one, 2×2 case).(10r1)(10−r1)=(10−r+r1)=id, and symmetrically in the other order. □
Lemma. If B is obtained from the m×n-matrix A by elementary row operations, A⇝B, then B=UA for an invertible m×m-matrix U. (In particular, if A⇝id then id=UA.)
Proof. A single step is multiplication by an elementary matrix, which is invertible. For A=A0⇝A1⇝⋯⇝An=B with Ak=UkAk−1,
An=UnUn−1⋯U1A=:UA,
by associativity, and U is a product of invertible matrices, hence invertible. □
Corollary (elimination does not change the solutions). If Ax=b is a linear system and A′,b′ are obtained by applying the same elementary row operations to A and b, then A′x=b′ has the same solution set.
Proof. There is an invertible U with A′=UA and b′=Ub. If Ax=b then A′x=UAx=Ub=b′. Conversely, if A′x=b′ then (crucially using that U is invertible) Ax=U−1UAx=U−1A′x=U−1b′=U−1Ub=b. □
3.2 Invertibility criteria and computing the inverse
Theorem. For a square matrix A∈Matn×n the following are equivalent:
A is invertible.
For every b∈Rn the equation Ax=b has exactly one solution.
For every b∈Rn the equation Ax=b has at most one solution.
The system Ax=0 has only the trivial solution x=0.
A can be transformed into idn by the Gaussian algorithm.
A is a product of elementary matrices.
There is a matrix B with AB=id.
Proof. We show (1)⇒(2)⇒(3)⇒(4)⇒(5)⇒(6)⇒(7)⇒(1).
(1)⇒(2): the previous theorem.
(2)⇒(3) and (3)⇒(4): clear.
(4)⇒(5): bring A into reduced row echelon form A⇝R. If R=id, then R (square) contains a zero row, so Rx=0 has at least one free parameter and hence a non-trivial solution. By the corollary above Ax=0 has the same solutions, a contradiction to (4). So R=id.
(5)⇒(6): UA=id with U=U1⋯Un a product of elementary matrices, so A=U−1UA=U−1=Un−1⋯U1−1, again a product of elementary matrices (the inverse of an elementary matrix is elementary).
(6)⇒(7): if A=U1⋯Un then AUn−1⋯U1−1=id.
(7)⇒(1): let AB=id. If Bx=0 then x=idx=ABx=A0=0. So B satisfies (4), and by the already proven implication (4)⇒(7) applied to B there is C with BC=id. Then A=Aid=A(BC)=(AB)C=idC=C, so BA=id as well. □
Computing the inverse. If A is invertible, write the identity to its right to get the n×2n-matrix (A∣idn), bring it to reduced row echelon form by Gaussian elimination: the result is (idn∣E) and E=A−1. Indeed the row operations that bring A to id bring (A∣id) to (UA∣Uid)=(id∣U), and U=A−1.
Example.A=13−10−12−1−32. Start from
(A∣id)=13−10−12−1−32100010001.
Subtract 3 times row 1 from row 2, and add row 1 to row 3:
1000−12−1011−31010001.
Add 2 times row 2 to row 3:
1000−10−1011−3−5012001.
Multiply row 2 by −1, then add row 3 to row 1:
100010001−43−52−12101.
Hence A is invertible and A−1=−43−52−12101. (Check, first row of AA−1: (1)(−4)+(−1)(−5)=1, (1)(2)+(−1)(2)=0, (1)(1)+(−1)(1)=0.)
Corollary. If A is square and AB=id for some square B, then also BA=id.
Proof. By the theorem A is invertible, so B=idB=A−1AB=A−1, and A−1A=id. □
4. Change of basis
Let V be a vector space with basis v={v1,…,vn}. Every x∈V is uniquely x=α1v1+⋯+αnvn, and (α1,…,αn)v are its coordinates in the basis v. For another basis w={w1,…,wn} we get other coordinates x=β1w1+⋯+βnwn. How do we pass from (αi)v to (βi)w?
The identity map.
With the basis v in both domain and codomain, idV(vi)=vi=0v1+⋯+1vi+⋯+0vn, so MidV,v,v=idn.
With basis v in the domain and w in the codomain, write idV(vi)=vi=a1iw1+⋯+aniwn (the coordinates of vi in the basis w). The matrix MidV,v,w=(aij) is the base change matrix from v to w; it multiplies the v-coordinates of a vector to give its w-coordinates.
Example.V=R2, v={e1,e2} the standard basis and w={w1,w2}={(1,1),(1,3)}.
(1,0)=a11(1,1)+a21(1,3) means a11+a21=1, a11+3a21=0, so a11=23, a21=−21. And (0,1)=a12(1,1)+a22(1,3) gives a12=−21, a22=21. Hence
MidR2,v,w=(23−21−2121).
For (3,2)=3e1+2e2: (23−21−2121)(32)=(27−21)w, i.e. (3,2)=27w1−21w2.
Inverse of a base change matrix. Since composition corresponds to the matrix product, applying idV=idV∘idV to Vv→Vw→Vv gives
Method (matrix of an endomorphism in another basis). Let f:V→V be linear, represented by E∈Matn×n with respect to the basis v (in domain and codomain). The matrix of f with respect to another basis w (in domain and codomain) is
Mf,w,w=AEA−1,A=MidV,v,w.
Proof.f=idV∘f∘idV, but we put different bases on V:
VwidVA−1VvfEVvidVAVw.
The first map has matrix Mid,w,v=A−1, the last Mid,v,w=A, and the composite has matrix AEA−1. □
Example.f:R2→R2 is multiplication by E=(2−103) in the standard basis e. Find its matrix with respect to w={w1,w2}={(1,1),(1,−2)}.
We need A=Mid,e,w and A−1=Mid,w,e. The inverse is easier: its columns are the coordinates of w1,w2 in the standard basis (id(w1)=1e1+1e2, id(w2)=1e1−2e2):
Check by the columns: Ew1=(2,2)=2w1+0w2 gives the first column (2,0)T; Ew2=(2,−7)=−1⋅w1+3w2 gives the second column (−1,3)T.
5. Transposition
Definition. The transpose of an m×n-matrix A=(aij) is the n×m-matrix AT:=(aji), obtained by reflecting the entries along the main diagonal.
Example.A=135246 has AT=(123456). The transpose of a column vector is a row vector and vice versa, e.g. (xy)T=(xy).
Lemma. Let A be an m×n-matrix and r∈R.
(AT)T=A.
For B of the same size, (A+B)T=AT+BT.
For an n×k-matrix B: (AB)T=BTAT (opposite order).
If the square matrix A is invertible, so is AT, and (AT)−1=(A−1)T.
Proof. (1) and (2) are immediate (reflecting twice along the diagonal gives back the matrix). (3): let C=AB=(cij) with cij=∑e=1naiebej. Then CT=(cji)=(∑e=1najebei), and this is the (i,j) entry of BTAT (the i-th row of BT is the i-th column of B, and the j-th column of AT is the j-th row of A). (4): by (3),
AT(A−1)T=(A−1A)T=idT=id,(A−1)TAT=(AA−1)T=idT=id.
So AT and (A−1)T are inverse to each other. □
Corollary (more invertibility criteria). For A∈Matn×n the following are equivalent:
A is invertible.
The n columns of A are linearly independent.
The rank of A is n.
The n rows of A are linearly independent.
Proof. (1)⟺(2): by the invertibility theorem, A is invertible exactly if Ax=0 has only the solution x=0. With A=(c1…cn) we have Ax=x1c1+⋯+xncn, so this condition says exactly that the columns are linearly independent.
(2)⟺(3): the rank is by definition the dimension of the column space L(c1,…,cn). If A is invertible, then for b∈Rn the system Ax=b has a (unique) solution x, so b=∑kxkck: the columns span Rn and the rank is n. Conversely, if the rank is n then the n columns span an n-dimensional space, so they are linearly independent.
(1)⟺(4): A is invertible if and only if AT is invertible (previous lemma). The rows of A are the columns of AT, so apply the already proved equivalence (1)⟺(2) to AT. □
Matrix of a linear map. For bases v of V and w of W, Mf,v,w is the m×n-matrix whose i-th column holds the coordinates of f(vi) in the basis w, i.e. f(vi)=∑jajiwj. It depends on the chosen bases. In the standard basis, f(v)=Av and the columns of A are f(ei)=Aei.
Composition and product.g∘f is linear; (AB)ij=∑eaiebej (needs columns of A = rows of B); AB=(Ab1…Abk). The matrix of g∘f is BA (matrix of g times matrix of f); v↦Av composed with u↦Bu is u↦(AB)u.
Rules.idA=Aid=A; distributive; associative; r(AB)=(rA)B=A(rB). AB=BA in general (e.g. reflection at the x-axis and rotation by 90∘).
Elementary matrices. Row swap Ei,j(1), scaling Ei,r(2) (r=0), adding r⋅ row j to row i: Ei,j,r(3). Row operation = left multiplication. Inverses: (Ei,j(1))−1=Ei,j(1), (Ei,r(2))−1=Ei,r−1(2), (Ei,j,r(3))−1=Ei,j,−r(3). Hence A⇝B by row operations means B=UA with U invertible, so elimination preserves the solution set of Ax=b.
Inverse.B with AB=BA=id; unique (B=B(AC)=(BA)C=C). Ax=b with A invertible has the unique solution x=A−1b. Rules: (A−1)−1=A, (AB)−1=B−1A−1 (reversed), (AT)−1=(A−1)T. Inverses of the geometric matrices: reflections are self-inverse, diag(r,s)−1=diag(r−1,s−1), rotation by r inverse is rotation by −r, shear r has inverse shear −r. A 1×1 matrix (a) is invertible iff a=0; (1224) is not invertible.
Invertibility theorem (equivalent for A∈Matn×n). (1) invertible; (2) Ax=b has exactly one solution for all b; (3) at most one; (4) Ax=0 only trivial; (5) A⇝id by Gauss; (6) A is a product of elementary matrices; (7) AB=id for some B (then also BA=id). Also: columns independent; rkA=n; rows independent.
Change of basis.Mid,v,w (columns: coordinates of vi in w) turns v-coordinates into w-coordinates; Mid,w,v=(Mid,v,w)−1. If f has matrix E in the basis v, then in the basis w it has matrix Mf,w,w=AEA−1 with A=Mid,v,w. Easy way: the columns of A−1 are the vectors wi written in the old basis; invert to get A.
Typical mistakes. Writing (AB)−1=A−1B−1 or (AB)T=ATBT (the order reverses); using the wrong direction AEA−1 versus A−1EA (check with the columns f(wi)); putting coordinates of f(vi) in rows instead of columns; assuming AB=BA; concluding invertibility from "non-zero" for matrices larger than 1×1.