Notes on Determinants and Matrix Inverse University of British Columbia, Vancouver Yue-Xian Li March, 2014 1 1 Definition of determinant Determinant is a scalar that measures the “magnitude” or “size” of a square matrix. Notice that conclusions presented below are focused on rows and row expansions. Similar results apply when the row-focus is changed to column-focus. Definition (verbal): For each n × n (square) matrix A, det A is the sum of n! terms, each is the product of n entries in which one and only one is taken from each row and column. The sum exhausts all permutations of integers {1, 2, · · · , n}. Terms with even permutations carry a “+” sign and those with odd permutations a “-” sign. Permutation: any rearrangement of an ordered list of numbers, say S, is a permutation of S. Example 1.1: For S = {1, 2, 3}, there are a total of 3! = 6 permutations: {123, 231, 312, 132, 213, 321}. Definition: For each permutation (j1 j2 · · · jn ) of the ordered list S = {1, 2, · · · , n}, σ(j1 j2 · · · jn ) = min number of pairwise exchanges to recover order (12 · · · n). Even/odd permutations: a permutation (j1 j2 · · · jn ) is even/odd if the value of σ(j1 j2 · · · jn ) is even/odd. Example 1.2: For S = {1, 2, 3}: σ(123) = 0, σ(231) = 2, σ(312) = 2 are even; σ(132) = 1, σ(213) = 1, σ(321) = 1 are odd. 2 Example 1.3: Show that the determinant of diagonal and triangular matrices is equal to the product of diagonal entries. Answer: In each one of these matrices, there is only one way of picking one entry from each and only one row and column that is not a zero. a11 0 · · · 0 0 a22 · · · 0 .. .. . . .. . . . . 0 0 · · · ann = a11 0 · · · 0 ∗ a22 · · · 0 .. .. . . .. . . . . ∗ ∗ · · · ann 3 = a11 ∗ · · · ∗ 0 a22 · · · ∗ .. .. . . .. . . . . 0 0 · · · ann = a11 a22 · · · ann . Definition (formula): ∀ n × n matrix A = [aij ] (1 ≤ i, j ≤ n) a11 a12 · · · a1n a21 a22 · · · a2n X det A = .. = (−1)σ(j1 j2 ···jn ) a1j1 a2j2 · · · anjn , .. . . .. .. . . (j1 j2 ···jn ) an1 an2 · · · ann where the sum is taken over all possible permutations of integers (12 · · · n) (a total of n!) and that +1, if σ(j1 j2 · · · jn ) is even, σ(j1 j2 ···jn ) (−1) = −1, if σ(j1 j2 · · · jn ) is odd. Example 1.4: For a11 a12 det A = a21 a22 a31 an2 a 3 × 3 matrix A = [aij ] (1 ≤ i, j ≤ 3), a13 X a23 = (−1)σ(j1 j2 j3 ) a1j1 a2j2 a3j3 a33 (j1 j2 j3 ) = (−1)σ(123)=0 a11 a22 a33 + (−1)σ(231)=2 a12 a23 a31 + (−1)σ(312)=2 a13 a21 a32 +(−1)σ(132)=1 a11 a23 a32 + (−1)σ(213)=1 a12 a21 a33 + (−1)σ(321)=1 a13 a22 a31 = a11 a22 a33 + a12 a23 a31 + a13 a21 a32 − a11 a23 a32 − a12 a21 a33 − a13 a22 a31 . Remark: For matrices larger than 3×3, this formula is not practical to use by hand. So, it shall be mainly employed in demonstrating important properties of determinants. 4 2 Determinants calculated by row expansions For all n × n matrix A = [aij ] (1 ≤ i, j ≤ n), expansion in the ith row yields det A = n X i+j aij (−1) det Aij = j=1 n X aij cij , j=1 or in expanded form det A = ai1 (−1)i+1 det Ai1 + ai2 (−1)i+2 det Ai2 + · · · + ain (−1)i+n det Ain = ai1 ci1 + ai2 ci2 + · · · + ain cin where • Aij = (n − 1) × (n − 1) matrix obtained by deleting the ith row and j th column of A; • det Aij = (i, j)th −minor of A; • cij = (−1)i+j det Aij = (i, j)th −cofactor of A. Formula for expansion in the j th column is obtained by changing the summation index from j to i: det A = n X aij (−1) i+j i=1 det Aij = n X aij Cij . i=1 Remark: The determinants for 2 × 2 and 3 × 3 matrices are easy to calculate. Most students are familiar with the expansion in the first row (i.e., i = 1). 5 Example 2.1: det A = 2 0 2 3 0 0 2 0 2 3 4 6 4 2 4 2 =? Ans: Using expansion in the first row, we obtain 0 3 2 det A = 2 2 4 4 0 6 2 0 0 2 + 2 2 2 4 3 0 2 0 0 3 − 4 2 2 4 3 0 6 . Using expansion in the second row, we obtain 2 0 4 2+3 det A = (−1) 3 2 4 4 3 0 2 2 0 2 +(−1)2+4 2 2 2 4 3 0 6 2 0 4 = −3 2 4 4 3 0 2 2 0 2 +2 2 2 4 3 0 6 But the simplest is to expand in the second column, 2 2 4 3+2 det A = (−1) 2 0 3 2 3 6 2 = (−2)(12 + 12 − 36 − 24) = 72. 6 . Derivation/proof of the expansion formula: (not required!) det A = n X i+j aij (−1) det Aij = j=1 n X aij cij . j=1 Proof: Based on definition: det A = X (−1)σ(l1 ···li ···ln ) [a1l1 · · · aili · · · anln ] (l1 ···li ···ln ) = X σ(li l1 ···l(i−1) l(i+1) ···ln )−(i−1) (−1) h aili a1l1 · · · a(i−1)l(i−1) a(i+1)l(i+1) · · · anln i (l1 ···li ···ln ) = X i h (−1)σ(jl1 ···l(i−1) l(i+1) ···ln )−(i−1)−(j−1) aij a1l1 · · · a(i−1)l(i−1) a(i+1)l(i+1) · · · anln (l1 ···li ···ln ) = n X j=1 = n X lk 6=j for all k X aij (−1)i+j h (−1)σ(l1 ···l(i−1) l(i+1) ···ln ) a1l1 · · · a(i−1)l(i−1) a(i+1)l(i+1) (l1 ···l(i−1) l(i+1) ···ln ) aij (−1)i+j det Aij . j=1 In the derivation above, we used the following identities: (i) σ(l1 · · · li · · · ln ) = σ(li l1 · · · l(i−1) l(i+1) · · · ln ) − (i − 1), because it takes (i−1) pairwise exchanges to turn (li l1 · · · l(i−1) l(i+1) · · · ln ) into (l1 · · · li · · · ln ). (ii) σ(li l1 · · · l(i−1) l(i+1) · · · ln ) = σ(jl1 · · · l(i−1) l(i+1) · · · ln ) − (j − 1), because it takes (j − 1) pairwise exchanges to turn (1 · · · j · · · n) into (j1 · · · (j − 1)(j + 1) · · · ln ). (iii) (−1)−(i+j)−2 = (−1)−(i+j) = (−1)i+j . 7 i · · · anln 3 3.1 Important properties of determinants det A = det AT Because the “row-focused” and “column-focused” formulas are identical. det A = X (−1)σ(j1 j2 ···jn ) a1j1 a2j2 · · · anjn (j1 j2 ···jn ) = X (−1)σ(i1 i2 ···in ) ai1 1 ai2 2 · · · ain n = det AT . (i1 i2 ···in ) Example 3.1: 1 2 3 4 =4−6= 1 3 2 4 8 . det Ak↔l = − det A 3.2 Suppose that matrix A0 = Ak↔l is obtained by swapping the k th and j th rows of A. Thus, a0ij = aij except that a0kj = alj and a0lj = akj for all 1 ≤ j ≤ n. Then, det A0 = = X X (−1)σ(j1 j2 ···jk ···jl ···jn ) a01j1 a02j2 · · · a0kjk · · · a0ljl · · · a0njn (j1 j2 ···jn ) σ(j1 j2 ···jk ···jl ···jn ) (−1) a1j1 a2j2 · · · aljk · · · akjl · · · anjn (j1 j2 ···jn ) = X (−1)σ(j1 j2 ···jk ···jl ···jn ) a1j1 a2j2 · · · akjl · · · aljk · · · anjn (j1 j2 ···jn ) = X (−1)σ(j1 j2 ···jl ···jk ···jn )+1 a1j1 a2j2 · · · akjl · · · aljk · · · anjn = − det A. (j1 j2 ···jn ) Note that σ(j1 j2 · · · jk · · · jl · · · jn ) = σ(j1 j2 · · · jl · · · jk · · · jn ) + 1 because the two differ by one pairwise swap. Example 3.2: 1 2 3 4 = 4 − 6 = −2, 3 4 1 2 but 9 2 1 = 4 3 = 6 − 4 = 2. 3.3 det Ak=l = 0 If two rows (columns) of a matrix A are identical (i.e. A = Ak↔l ), then det A = det Ak↔l = − det A = 0. Alternatively, if two rows are identical or are constant multiples of each other, then the rows in A are not linearly independent. Thus, A is not invertible which implies det A = 0. Example 3.3: 1 2 1 2 = 2 − 2 = 0. 10 3.4 Determinant is linear in each row/column Suppose a row vector is a linear combination of two row vectors, say the k th row ak = sb + tc (k = 1, 2, · · · , n), where s, t are scalars. Then, a1 a1 a2 a2 . . . . . . det = s det + t det . sb + tc b c . . . .. .. .. an an an a1 a2 .. . Equivalently, we can also express this property in the following form a11 a12 a a22 21 .. .. . . sb1 + tc1 sb2 + tc2 .. .. . . an1 an2 ··· ··· .. . ··· .. . ··· = s sbn + tcn .. . ann a1n a2n .. . a11 a12 · · · a21 a22 · · · .. .. .. . . . b1 b2 · · · .. .. .. . . . an1 an2 · · · +t bn .. . ann a1n a2n .. . a11 a12 · · · a21 a22 · · · .. .. .. . . . c1 c2 · · · .. .. .. . . . an1 an2 · · · . cn .. . ann a1n a2n .. . Proof: det A = X (−1)σ(j1 j2 ···jn ) a1j1 a2j2 · · · akjk · · · anjn X (j1 j2 ···jn ) (−1)σ(j1 j2 ···jn ) a1j1 a2j2 · · · (sbjk + tcjk ) · · · anjn = (j1 j2 ···jn ) =s X (−1)σ(j1 j2 ···jn ) a1j1 a2j2 · · · bjk · · · anjn +t (j1 j2 ···jn ) X (j1 j2 ···jn ) 11 (−1)σ(j1 j2 ···jn ) a1j1 a2j2 · · · cjk · · · anjn . This property can also be expressed in form of two related properties: (1) ··· ··· .. . a1n a2n .. . sak1 sak2 · · · .. .. .. . . . an1 an2 · · · sakn .. . a11 a21 .. . a12 a22 .. . a11 a12 a21 a22 .. .. . . (2) b1 + c 1 b2 + c 2 .. .. . . a a n1 n2 ann ··· ··· .. . ··· .. . ··· = s a11 a12 · · · a21 a22 · · · .. .. .. . . . ak1 ak2 · · · .. .. .. . . . an1 an2 · · · = bn + c n .. . ann a1n a2n .. . , akn .. . ann a1n a2n .. . a11 a12 · · · a21 a22 · · · .. .. .. . . . b1 b2 · · · .. .. .. . . . an1 an2 · · · + bn .. . ann a1n a2n .. . a11 a12 · · · a21 a22 · · · .. .. .. . . . c1 c2 · · · .. .. .. . . . an1 an2 · · · Example 3.4: a b 3 5 = 5a − 3b, a+c b+d 3 5 2a 2b 3 5 = 10a − 6b = 2(5a − 3b). = 5(a+c)−3(b+d) = (5a−3b)+(5c−3d) = a b 3 5 12 c d + 3 5 . . cn .. . ann a1n a2n .. . 3.5 Adding a scalar multiple of one row to another Let matrix A0 be identical to A except that k th row multiplied by scalar s (6= 0) is added to lth row (1 ≤ k < l ≤ n). Thus, a0ij = aij for all 1 ≤ i, j ≤ n except that a0lj = alj + sakj . Then, det A0 = det A. Proof: X det A0 = = X (−1)σ(j1 j2 ···jn ) a01j1 a02j2 · · · a0ljk · · · a0njn (j1 j2 ···jn ) σ(j1 j2 ···jn ) (−1) a1j1 · · · akjk · · · (aljl + sakjl ) · · · anjn (j1 j2 ···jn ) = X (−1)σ(j1 j2 ···jn ) a1j1 · · · akjk · · · aljl · · · anjn +s (j1 j2 ···jn ) X (−1)σ(j1 j2 ···jn ) a1j1 · · · akjk · · · akjl · · · anjn (j1 j2 ···jn ) = det A + 0 = det A. Example 3.5: a b c d = ad − bc. a b c + 2a d + 2b = a(d + 2b) − b(c + 2a) = ad + 2ab − bc − 2ba = ad − bc. 13 3.6 det AB = det A det B. Example 3.6: 2 1 det A = 3 4 = 8 − 3 = 5, −2 5 det AB = −13 15 1 1 = 3 − (−4) = 7. det B = −4 3 = −30 − (−65) = 35 = det A det B. 14 Proof(1): (not required!): Case I: If at least one of A and B is noninvertible, i.e. either det A = 0 or det B = 0 or both, then AB as the composite transformation of the two must also be noninvertible. Thus, det(AB) = 0 = det A det B. Case II: If both A and B are invertible, then based on the results on elementary matrices: A = A1 A2 · · · Ak , B = B1 B2 · · · Bl , where A1 , · · · , Ak and B1 , · · · , Bl are all elementary matrices. Therefore, det(AB) = det(A1 A2 · · · Ak B1 B2 · · · Bl ) = (det A1 · · · det Ak )(det B1 · · · det Bl ) = det A det B. 15 Proof(2): (not required!): n X Note that AB = [(AB)ij ], where (AB)ij = ail blj . l=1 X det AB = (−1)σ(j1 j2 ···jn ) (AB)1j1 (AB)2j2 · · · (AB)njn (j1 j2 ···jn ) = X n X (−1)σ(j1 j2 ···jn ) (j1 j2 ···jn ) ! n X a1l1 bl1 j1 ! a2l2 bl2 j2 ··· n X ! anln bln jn l1 =1 l2 =1 ln =1 All non−selfavoiding terms cancel (i.e. l1 ,l2 ,··· ,ln must be distinct) −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−→ because an identical term with opposite sign occurs when sumed over all permutations of (j1 j2 ···jn ) X X = (−1)σ(j1 j2 ···jn ) (a1l1 bl1 j1 )(a2l2 bl2 j2 ) · · · (anln bln jn ) (j1 j2 ···jn ) = = X (l1 l2 ···ln ) σ(j1 j2 ···jn ) (−1) (a1l1 a2l2 · · · anln )(bl1 j1 bl2 j2 · · · bln jn ) (j1 j2 ···jn ) (l1 l2 ···ln ) X X (−1)σ(j1 j2 ···jn ) (j1 j2 ···jn ) = X X (a1l1 a2l2 · · · anln )(−1)σ(l1 l2 ···ln ) (b1j1 b2j2 · · · bnjn ) (l1 l2 ···ln ) σ(j1 j2 ···jn ) (−1) X (b1j1 b2j2 · · · bnjn ) (j1 j2 ···jn ) (−1)σ(l1 l2 ···ln ) (a1l1 a2l2 · · · anln ) (l1 l2 ···ln ) = det B det A. The key step in the proof above is to eliminate all the non-selfavoiding terms. Here, a “non-selfavoiding term” refers to those terms in which li = lj (i 6= j) happens for at least one pair of i, j (1 ≤ i, j ≤ n). To see this more clearly, we show the case when only two subscripts exists for 2×2 matrices. In this case, (12) or (21) X det AB = (−1)σ(j1 j2 ) (AB)1j1 (AB)2j2 (j1 j2 ) (12) or (21) = X σ(j1 j2 ) (−1) (j1 j2 ) (12) or (21) = X 2 X ! a1l1 bl1 j1 l1 =1 2 X ! a2l2 bl2 j2 l2 =1 (−1)σ(j1 j2 ) (a11 b1j1 + a12 b2j1 ) (a21 b1j2 + a22 b2j2 ) (j1 j2 ) = (a11 b11 + a12 b21 ) (a21 b12 + a22 b22 ) − (a11 b12 + a12 b22 ) (a21 b11 + a22 b21 ) Terms with identical color cancel each other. −−−−−−−−−−−−−−−−−−−−−−−−−−→ Self−avoiding colors! 16 = a11 b11 a22 b22 + a12 b21 a21 b12 − a11 b12 a22 b21 − a12 b22 a21 b11 2 X = = = (a1l1 bl1 1 a2l2 bl2 2 − a1l1 bl1 2 a2l2 bl2 1 ) l1 ,l2 =1, (l1 6=l2 ) 2 X X (−1)σ(j1 j2 ) a1l1 bl1 j1 a2l2 bl2 j2 = l1 ,l2 =1, (l1 6=l2 ) (j1 j2 ) X X σ(j1 j2 ) (−1) = (−1)σ(j1 j2 ) a1l1 bl1 j1 a2l2 bl2 j2 1 l2 ) (j1 j2 ) X (lX (a1l1 a2l2 )(bl1 j1 bl2 j2 ) = (−1)σ(j1 j2 ) (a1l1 a2l2 )(−1)σ(l1 l2 ) (b1j1 b2j2 ) (l1 l2 ) (j1 j2 ) X X X (l1 l2 ) (j1 j2 ) σ(l1 l2 ) (−1) (l1 l2 ) (a1l1 a2l2 ) X (−1) σ(j1 j2 ) (b1j1 b2j2 ) (j1 j2 ) = det A det B. Here, non-selfavoiding terms are terms like a11 b11 a21 b12 and a12 b21 a22 b22 in which entries from the same column or row of a matrix occur twice in the same product. They all cancel out in the summation. Therefore, “self-avoiding” means in each term of the expression, there must be one and only one entries from each row and each column of each matrix. The same conclusion works in a similar way when the matrix is bigger. For any term that contains at least one pair of non-selfavoiding entries, we can use the same argument for this particular pair of entries in exactly the same way as we treat the 2×2 case. 17 4 Formula for the inverse of n × n matrices Definition of minor and cofactor: ∀ n × n matrices A = [aij ], the (i, j)th −minor and (i, j)th −cofactor are mij = det Aij , cij = (−1)i+j mij , where Aij is the (n − 1) × (n − 1) matrix obtained by deleting the ith row and j th column of A. Definition of cofactor matrix: ∀ n × n matrices A = [aij ], its cofactor c11 c21 C = [cij ] = .. . cn1 matrix is defined as c12 · · · c1n c22 · · · c2n .. . . .. , . . . cn2 · · · cnn where cij = (−1)i+j det Aij is the (i, j)th −cofactor of matrix A. Formula for A−1 : ∀ invertible n × n matrices A with a cofactor matrix C: 1 −1 A = CT . det A 18 0 2 1 Example 4.1: Consider the matrix A = −1 1 0 . 2 −5 2 (a) Show that it is invertible using the row expansion formula; (b) Find A−1 using the cofactor formula. Ans: (a) First calculate the cofactors for the expansion in row 1: −1 0 −1 1 1 0 = 2; c12 = − = 2; c13 = + c11 = + −5 2 2 2 2 −5 =⇒ = 3. det A = (0)c11 + (2)c12 + (1)c13 = 4 + 3 = 7 6= 0! (b) Then, calculate all the other cofactors: 0 1 2 1 = −9; c = + c21 = − 22 2 2 −5 2 2 1 = −1; c32 = − 0 1 c31 = + −1 0 1 0 = −2; = −1; c23 c33 0 2 = − 2 −5 0 2 = + −1 1 = 4. = 2. Therefore, 2 2 3 C = −9 −2 4 −1 −1 2 ⇒ A−1 = 1 det A 2 −9 −1 1 C T = 2 −2 −1 . 7 3 4 2 Verify, 2 −9 −1 0 2 1 7 0 0 1 0 0 1 1 A−1 A = 2 −2 −1 −1 1 0 = 0 7 0 = 0 1 0 = I3 . 7 7 3 4 2 2 −5 2 0 0 7 0 0 1 19 Derivation/proof of the cofactor formula for inverse: (not required!) −1 A = 1 det A CT . Proof: Based on the definition of det A: det A = n X aij cij n X =⇒ j=1 aij j=1 cij = 1. det A Let A0 = [a0ij ] be a matrix obtained by replacing the ith row of A by its lth row. Then, 0 det A = n X a0ij cij = j=1 n X alj cij . j=1 If l = i (no change), then A0 = A 0 det A = n X a0ij cij j=1 = n X alj cij = j=1 n X aij cij = det A =⇒ j=1 n X j=1 alj cij = 1 ( for l = i). det A If l 6= i, then A0 has two identical rows i and l, thus det A0 = 0 = n X j=1 a0ij cij = n X alj cij =⇒ j=1 n X alj j=1 Therefore, n X cij alj = det A j=1 20 1, if l = i, 0, if l 6= i. cij = 0 ( for l 6= i). det A Introduce a new matrix B = [bij ] such that bij = cji . det A Now, let D = AB = [dij ]. Based on definition of matrix multiplication n X n X cij dli = alj bji = alj = det A j=1 j=1 1, if l = i, 0, if l 6= i. Therefore, D = I = AB ⇒ A −1 cji ]= = B = [bij ] = [ det A 21 1 det A CT .