#set document(title: "9.2 Matrix Algebra", author: "Jiří Lebl") #set page(width: 8.5in, height: auto, margin: 1in) #import "@preview/cetz:0.5.2" #set text(font: ("STIX Two Text", "Libertinus Serif", "New Computer Modern"), size: 10.5pt, lang: "en") #show math.equation: set text(font: ("STIX Two Math", "New Computer Modern Math")) #set par(justify: true, leading: 0.62em, spacing: 0.9em) #set enum(spacing: 1.1em) // room between list items so tall inline fractions don't collide #set list(spacing: 1.1em) #set table(stroke: 0.5pt + rgb("#c7ccd3")) #let BLUE = rgb("#183B6F") // brand navy — section bars + example/solution labels (white on navy 11.09:1) #let ORANGE = rgb("#A94509") // brand primary-700 — AA-safe deep orange for TEXT (5.93:1 on white; raw brand #F37021 is 2.94:1 and must never carry text) #let RED = rgb("#DC2626") // brand error-600 #let GREEN = rgb("#059669") // brand success-600 (decoration only; small green text uses green-text #007942) #show heading.where(level: 1): it => block(width: 100%, above: 0pt, below: 16pt, fill: gradient.linear(BLUE, rgb("#2C5AA0")), inset: (x: 14pt, y: 12pt), radius: 3pt, text(fill: white, weight: "bold", size: 19pt, it.body)) #show heading.where(level: 2): it => block(width: 100%, above: 18pt, below: 10pt, fill: BLUE, inset: (x: 10pt, y: 6pt), radius: 2pt, text(fill: white, weight: "bold", size: 12pt, it.body)) #show heading.where(level: 3): it => text(fill: ORANGE, weight: "bold", size: 12.5pt, it.body) #show heading.where(level: 4): it => text(fill: BLUE, weight: "bold", size: 10.5pt, it.body) #let examplebox(label, title, body) = block(width: 100%, breakable: true, fill: rgb("#EFF1F5"), stroke: 0.5pt + rgb("#CFDDF0"), radius: 4pt, inset: 10pt, above: 12pt, below: 12pt)[ #block(below: 6pt)[#box(fill: BLUE, inset: (x: 6pt, y: 2pt), radius: 2pt, text(fill: white, weight: "bold", size: 8.5pt, label)) #h(0.4em) #strong[#title]] #body] // rail = decorative left rule (raw brand token); labelcolor = AA-safe label text shade #let notebox(label, rail, labelcolor, tint, body) = block(width: 100%, breakable: true, fill: tint, stroke: (left: 3pt + rail), inset: (left: 10pt, rest: 8pt), radius: (right: 4pt), above: 11pt, below: 11pt)[ #text(fill: labelcolor, weight: "bold", size: 7.5pt, tracking: 0.5pt)[#upper(label)] #linebreak() #body] #let solutionbox(body) = block(above: 4pt, below: 8pt)[ #text(fill: BLUE, weight: "bold", size: 8.5pt)[Solution] #linebreak() #body] #let figph(msg) = block(width: 100%, height: 60pt, fill: rgb("#f6f7f9"), stroke: (paint: rgb("#c7ccd3"), dash: "dashed"), radius: 4pt, inset: 10pt)[ #align(center + horizon, text(fill: rgb("#889"), style: "italic", size: 9pt, msg))] // Standardize inlined figure sizes: measure the natural CeTZ canvas, then scale to a // consistent envelope (aspect-aware; see build_typst.py FIG_* constants). Unlike the // print preamble, dimensions are FLOORED: in an editor a user can trim a figure to a // degenerate 1-D shape (a bare line), and w/h or tw/w would then divide by zero. #let _STD_W = 3.5 #let _WIDE_W = 5.6 #let _MAX_H = 3.4 #let _ASPECT_WIDE = 2.2 #let _UPSCALE_MAX = 1.15 #let stdfig(body) = context { let m = measure(body) let w = calc.max(m.width / 1in, 0.01) let h = calc.max(m.height / 1in, 0.01) let tw = if w / h > _ASPECT_WIDE { _WIDE_W } else { _STD_W } let s = calc.min(tw / w, _MAX_H / h, _UPSCALE_MAX) align(center, box(scale(x: s * 100%, y: s * 100%, reflow: true, body))) } #show figure: set block(breakable: false) #set figure(gap: 8pt) #show figure.caption: set text(size: 8.5pt, fill: rgb("#555")) == 9.2#h(0.6em)Matrix Algebra === One-by-One Matrices Let us motivate what we want to achieve with matrices. Real-valued linear mappings of the real line, linear functions that eat numbers and spit out numbers, are just multiplications by a number. Consider a mapping defined by multiplying by a number. Let’s call this number #math.equation(block: false, alt: "α")[$α$]. The mapping then takes #math.equation(block: false, alt: "x")[$x$] to #math.equation(block: false, alt: "α x")[$α x$]. We can #emph[add] such mappings: If we have another mapping #math.equation(block: false, alt: "β")[$β$], then #math.equation(block: true, alt: "α x plus β x equals open parenthesis α plus β close parenthesis x .")[$α x + β x = ( α + β ) x .$] We get a new mapping #math.equation(block: false, alt: "α plus β")[$α + β$] that multiplies #math.equation(block: false, alt: "x")[$x$] by, well, #math.equation(block: false, alt: "α plus β")[$α + β$]. If #math.equation(block: false, alt: "D")[$D$] is a mapping that doubles its input, #math.equation(block: false, alt: "D x equals 2 x")[$D x = 2 x$], and #math.equation(block: false, alt: "T")[$T$] is a mapping that triples, #math.equation(block: false, alt: "T x equals 3 x")[$T x = 3 x$], then #math.equation(block: false, alt: "D plus T")[$D + T$] is a mapping that multiplies by #math.equation(block: false, alt: "5")[$5$], #math.equation(block: false, alt: "open parenthesis D plus T close parenthesis x equals 5 x")[$( D + T ) x = 5 x$]. Similarly we can #emph[compose] such mappings, that is, we could apply one and then the other. We take #math.equation(block: false, alt: "x")[$x$], we run it through the first mapping #math.equation(block: false, alt: "α")[$α$] to get #math.equation(block: false, alt: "α")[$α$] times #math.equation(block: false, alt: "x")[$x$], then we run #math.equation(block: false, alt: "α x")[$α x$] through the second mapping #math.equation(block: false, alt: "β")[$β$]. In other words, #math.equation(block: true, alt: "β open parenthesis α x close parenthesis equals open parenthesis β α close parenthesis x .")[$β ( α x ) = ( β α ) x .$] We just multiply those two numbers. Using our doubling and tripling mappings, if we double and then triple, that is #math.equation(block: false, alt: "T open parenthesis D x close parenthesis")[$T ( D x )$] then we obtain #math.equation(block: false, alt: "3 open parenthesis 2 x close parenthesis equals 6 x")[$3 ( 2 x ) = 6 x$]. The composition #math.equation(block: false, alt: "T D")[$T D$] is the mapping that multiplies by #math.equation(block: false, alt: "6")[$6$]. For larger matrices, composition also ends up being a kind of multiplication. === Matrix Addition and Scalar Multiplication The mappings that multiply numbers by numbers are just #math.equation(block: false, alt: "1 times 1")[$1 × 1$] matrices. The number #math.equation(block: false, alt: "α")[$α$] above could be written as a matrix #math.equation(block: false, alt: "[ α ]")[$[ α ]$]. Perhaps we would want to do to all matrices the same things that we did to those #math.equation(block: false, alt: "1 times 1")[$1 × 1$] matrices at the start of this section above. First, let us add matrices. If we have a matrix #math.equation(block: false, alt: "A")[$A$] and a matrix #math.equation(block: false, alt: "B")[$B$] that are of the same size, say #math.equation(block: false, alt: "m times n")[$m × n$], then they are mappings from #math.equation(block: false, alt: "ℝ to the power n")[$ℝ^(n)$] to #math.equation(block: false, alt: "ℝ to the power m")[$ℝ^(m)$]. The mapping #math.equation(block: false, alt: "A plus B")[$A + B$] should also be a mapping from #math.equation(block: false, alt: "ℝ to the power n")[$ℝ^(n)$] to #math.equation(block: false, alt: "ℝ to the power m")[$ℝ^(m)$], and it should do the following to vectors: #math.equation(block: true, alt: "open parenthesis A plus B close parenthesis x → equals A x → plus B x → .")[$( A + B ) arrow(x) = A arrow(x) + B arrow(x) .$] It turns out you just add the matrices element-wise: If the #math.equation(block: false, alt: "i j to the power th")[$i j^("th")$] entry of #math.equation(block: false, alt: "A")[$A$] is #math.equation(block: false, alt: "a sub i j")[$a_(i j)$], and the #math.equation(block: false, alt: "i j to the power th")[$i j^("th")$] entry of #math.equation(block: false, alt: "B")[$B$] is #math.equation(block: false, alt: "b sub i j")[$b_(i j)$], then the #math.equation(block: false, alt: "i j to the power th")[$i j^("th")$] entry of #math.equation(block: false, alt: "A plus B")[$A + B$] is #math.equation(block: false, alt: "a sub i j plus b sub i j")[$a_(i j) + b_(i j)$]. If #math.equation(block: true, alt: "A equals [ a sub 11, a sub 12, a sub 13; a sub 21, a sub 22, a sub 23 ] and B equals [ b sub 11, b sub 12, b sub 13; b sub 21, b sub 22, b sub 23 ] ,")[$A = [ a_(11) & a_(12) & a_(13) \ a_(21) & a_(22) & a_(23) ] #h(2em) "and" #h(2em) B = [ b_(11) & b_(12) & b_(13) \ b_(21) & b_(22) & b_(23) ] ,$] then #math.equation(block: true, alt: "A plus B equals [ a sub 11 plus b sub 11, a sub 12 plus b sub 12, a sub 13 plus b sub 13; a sub 21 plus b sub 21, a sub 22 plus b sub 22, a sub 23 plus b sub 23 ] .")[$A + B = [ a_(11) + b_(11) & a_(12) + b_(12) & a_(13) + b_(13) \ a_(21) + b_(21) & a_(22) + b_(22) & a_(23) + b_(23) ] .$] Let us illustrate on a more concrete example: #math.equation(block: true, alt: "[ 1, 2; 3, 4; 5, 6 ] plus [ 7, 8; 9, 10; 11, minus 1 ] equals [ 1 plus 7, 2 plus 8; 3 plus 9, 4 plus 10; 5 plus 11, 6 minus 1 ] equals [ 8, 10; 12, 14; 16, 5 ] .")[$[ 1 & 2 \ 3 & 4 \ 5 & 6 ] + [ 7 & 8 \ 9 & 10 \ 11 & − 1 ] = [ 1 + 7 & 2 + 8 \ 3 + 9 & 4 + 10 \ 5 + 11 & 6 − 1 ] = [ 8 & 10 \ 12 & 14 \ 16 & 5 ] .$] Let’s check that this does the right thing to a vector. Let’s use some of the vector algebra that we already know, and regroup things: #math.equation(block: true, alt: "[ 1, 2; 3, 4; 5, 6 ] [ 2; minus 1 ] plus [ 7, 8; 9, 10; 11, minus 1 ] [ 2; minus 1 ] equals open parenthesis 2 [ 1; 3; 5 ] minus [ 2; 4; 6 ] close parenthesis plus open parenthesis 2 [ 7; 9; 11 ] minus [ 8; 10; minus 1 ] close parenthesis; equals 2 open parenthesis [ 1; 3; 5 ] plus [ 7; 9; 11 ] close parenthesis minus open parenthesis [ 2; 4; 6 ] plus [ 8; 10; minus 1 ] close parenthesis; equals 2 [ 1 plus 7; 3 plus 9; 5 plus 11 ] minus [ 2 plus 8; 4 plus 10; 6 minus 1 ] equals 2 [ 8; 12; 16 ] minus [ 10; 14; 5 ]; equals [ 8, 10; 12, 14; 16, 5 ] [ 2; minus 1 ] open parenthesis equals [ 2 open parenthesis 8 close parenthesis minus 10; 2 open parenthesis 12 close parenthesis minus 14; 2 open parenthesis 16 close parenthesis minus 5 ] equals [ 6; 10; 27 ] close parenthesis .")[$[ 1 & 2 \ 3 & 4 \ 5 & 6 ] [ 2 \ − 1 ] + [ 7 & 8 \ 9 & 10 \ 11 & − 1 ] [ 2 \ − 1 ] = ( 2 [ 1 \ 3 \ 5 ] − [ 2 \ 4 \ 6 ] ) + ( 2 [ 7 \ 9 \ 11 ] − [ 8 \ 10 \ − 1 ] ) \ = 2 ( [ 1 \ 3 \ 5 ] + [ 7 \ 9 \ 11 ] ) − ( [ 2 \ 4 \ 6 ] + [ 8 \ 10 \ − 1 ] ) \ = 2 [ 1 + 7 \ 3 + 9 \ 5 + 11 ] − [ 2 + 8 \ 4 + 10 \ 6 − 1 ] = 2 [ 8 \ 12 \ 16 ] − [ 10 \ 14 \ 5 ] \ = [ 8 & 10 \ 12 & 14 \ 16 & 5 ] [ 2 \ − 1 ] #h(1em) ( = [ 2 ( 8 ) − 10 \ 2 ( 12 ) − 14 \ 2 ( 16 ) − 5 ] = [ 6 \ 10 \ 27 ] ) .$] If we replaced the numbers by letters that would constitute a proof! You’ll notice that we didn’t really have to even compute what the result is to convince ourselves that the two expressions were equal. If the sizes of the matrices do not match, then addition is not defined. If #math.equation(block: false, alt: "A")[$A$] is #math.equation(block: false, alt: "3 times 2")[$3 × 2$] and #math.equation(block: false, alt: "B")[$B$] is #math.equation(block: false, alt: "2 times 5")[$2 × 5$], then we cannot add these matrices. We don’t know what that could possibly mean. It is also useful to have a matrix that when added to any other matrix does nothing. This is the zero matrix, the matrix of all zeros: #math.equation(block: true, alt: "[ 1, 2; 3, 4 ] plus [ 0, 0; 0, 0 ] equals [ 1, 2; 3, 4 ] .")[$[ 1 & 2 \ 3 & 4 ] + [ 0 & 0 \ 0 & 0 ] = [ 1 & 2 \ 3 & 4 ] .$] We often denote the zero matrix by #math.equation(block: false, alt: "0")[$0$] without specifying size. We would then just write #math.equation(block: false, alt: "A plus 0")[$A + 0$], where we just assume that #math.equation(block: false, alt: "0")[$0$] is the zero matrix of the same size as #math.equation(block: false, alt: "A")[$A$]. There are really two things we can multiply matrices by. We can multiply matrices by scalars or we can multiply by other matrices. Let us first consider multiplication by scalars. For a matrix #math.equation(block: false, alt: "A")[$A$] and a scalar #math.equation(block: false, alt: "α")[$α$], we want #math.equation(block: false, alt: "α A")[$α A$] to be the matrix that accomplishes #math.equation(block: true, alt: "open parenthesis α A close parenthesis x → equals α open parenthesis A x → close parenthesis .")[$( α A ) arrow(x) = α ( A arrow(x) ) .$] That is just scaling the result by #math.equation(block: false, alt: "α")[$α$]. If you think about it, scaling every term in #math.equation(block: false, alt: "A")[$A$] by #math.equation(block: false, alt: "α")[$α$] achieves just that: If #math.equation(block: true, alt: "A equals [ a sub 11, a sub 12, a sub 13; a sub 21, a sub 22, a sub 23 ] , then α A equals [ α a sub 11, α a sub 12, α a sub 13; α a sub 21, α a sub 22, α a sub 23 ] .")[$A = [ a_(11) & a_(12) & a_(13) \ a_(21) & a_(22) & a_(23) ] , #h(2em) "then" #h(2em) α A = [ α a_(11) & α a_(12) & α a_(13) \ α a_(21) & α a_(22) & α a_(23) ] .$] For example, #math.equation(block: true, alt: "2 [ 1, 2, 3; 4, 5, 6 ] equals [ 2, 4, 6; 8, 10, 12 ] .")[$2 [ 1 & 2 & 3 \ 4 & 5 & 6 ] = [ 2 & 4 & 6 \ 8 & 10 & 12 ] .$] Let us list some properties of matrix addition and scalar multiplication. Denote by #math.equation(block: false, alt: "0")[$0$] the zero matrix, by #math.equation(block: false, alt: "α")[$α$], #math.equation(block: false, alt: "β")[$β$] scalars, and by #math.equation(block: false, alt: "A")[$A$], #math.equation(block: false, alt: "B")[$B$], #math.equation(block: false, alt: "C")[$C$] matrices. Then: #math.equation(block: true, alt: "A plus 0 equals A equals 0 plus A ,; A plus B equals B plus A ,; open parenthesis A plus B close parenthesis plus C equals A plus open parenthesis B plus C close parenthesis ,; α open parenthesis A plus B close parenthesis equals α A plus α B ,; open parenthesis α plus β close parenthesis A equals α A plus β A .")[$A + 0 = A = 0 + A , \ A + B = B + A , \ ( A + B ) + C = A + ( B + C ) , \ α ( A + B ) = α A + α B , \ ( α + β ) A = α A + β A .$] These rules should look very familiar. === Matrix Multiplication As we mentioned above, composition of linear mappings is also a multiplication of matrices. Suppose #math.equation(block: false, alt: "A")[$A$] is an #math.equation(block: false, alt: "m times n")[$m × n$] matrix, that is, #math.equation(block: false, alt: "A")[$A$] takes #math.equation(block: false, alt: "R to the power n")[$R^(n)$] to #math.equation(block: false, alt: "R to the power m")[$R^(m)$], and #math.equation(block: false, alt: "B")[$B$] is an #math.equation(block: false, alt: "n times p")[$n × p$] matrix, that is, #math.equation(block: false, alt: "B")[$B$] takes #math.equation(block: false, alt: "R to the power p")[$R^(p)$] to #math.equation(block: false, alt: "R to the power n")[$R^(n)$]. The composition #math.equation(block: false, alt: "A B")[$A B$] should work as follows #math.equation(block: true, alt: "A B x → equals A open parenthesis B x → close parenthesis .")[$A B arrow(x) = A ( B arrow(x) ) .$] First, a vector #math.equation(block: false, alt: "x →")[$arrow(x)$] in #math.equation(block: false, alt: "R to the power p")[$R^(p)$] gets taken to the vector #math.equation(block: false, alt: "B x →")[$B arrow(x)$] in #math.equation(block: false, alt: "R to the power n")[$R^(n)$]. Then the mapping #math.equation(block: false, alt: "A")[$A$] takes it to the vector #math.equation(block: false, alt: "A open parenthesis B x → close parenthesis")[$A ( B arrow(x) )$] in #math.equation(block: false, alt: "R to the power m")[$R^(m)$]. In other words, the composition #math.equation(block: false, alt: "A B")[$A B$] should be an #math.equation(block: false, alt: "m times p")[$m × p$] matrix. In terms of sizes we should have #math.equation(block: true, alt: "\" [ m times n ] [ n times p ] equals [ m times p ] . \"")[$\" #h(1em) [ m × n ] #h(0.222em) [ n × p ] = [ m × p ] . #h(1em) \"$] Notice how the middle size must match. OK, now we know what sizes of matrices we should be able to multiply, and what the product should be. Let us see how to actually compute matrix multiplication. We start with the so-called #emph[dot product] (or #emph[inner product]) of two vectors. Usually this is a row vector multiplied with a column vector of the same size. Dot product multiplies each pair of entries from the first and the second vector and sums these products. The result is a single number. For example, #math.equation(block: true, alt: "[ a sub 1, a sub 2, a sub 3 ] times [ b sub 1; b sub 2; b sub 3 ] equals a sub 1 b sub 1 plus a sub 2 b sub 2 plus a sub 3 b sub 3 .")[$[ a_(1) & a_(2) & a_(3) ] · [ b_(1) \ b_(2) \ b_(3) ] = a_(1) b_(1) + a_(2) b_(2) + a_(3) b_(3) .$] And similarly for larger (or smaller) vectors. A dot product is really a product of two matrices: a #math.equation(block: false, alt: "1 times n")[$1 × n$] matrix and an #math.equation(block: false, alt: "n times 1")[$n × 1$] matrix resulting in a #math.equation(block: false, alt: "1 times 1")[$1 × 1$] matrix, that is, a number. Armed with the dot product we define the #emph[product of matrices]. We denote by #math.equation(block: false, alt: "row sub i open parenthesis A close parenthesis")[$op("row")_(i) ( A )$] the #math.equation(block: false, alt: "i to the power th")[$i^("th")$] row of #math.equation(block: false, alt: "A")[$A$] and by #math.equation(block: false, alt: "column sub j open parenthesis A close parenthesis")[$op("column")_(j) ( A )$] the #math.equation(block: false, alt: "j to the power th")[$j^("th")$] column of #math.equation(block: false, alt: "A")[$A$]. For an #math.equation(block: false, alt: "m times n")[$m × n$] matrix #math.equation(block: false, alt: "A")[$A$] and an #math.equation(block: false, alt: "n times p")[$n × p$] matrix #math.equation(block: false, alt: "B")[$B$] we can compute the product #math.equation(block: false, alt: "A B")[$A B$]: The matrix #math.equation(block: false, alt: "A B")[$A B$] is an #math.equation(block: false, alt: "m times p")[$m × p$] matrix whose #math.equation(block: false, alt: "i j to the power th")[$i j^("th")$] entry is the dot product #math.equation(block: true, alt: "row sub i open parenthesis A close parenthesis times column sub j open parenthesis B close parenthesis .")[$op("row")_(i) ( A ) · op("column")_(j) ( B ) .$] For example, given a #math.equation(block: false, alt: "2 times 3")[$2 × 3$] and a #math.equation(block: false, alt: "3 times 2")[$3 × 2$] matrix we should end up with a #math.equation(block: false, alt: "2 times 2")[$2 × 2$] matrix: #math.equation(block: true, alt: "[ a sub 11, a sub 12, a sub 13; a sub 21, a sub 22, a sub 23 ] [ b sub 11, b sub 12; b sub 21, b sub 22; b sub 31, b sub 32 ] equals [ a sub 11 b sub 11 plus a sub 12 b sub 21 plus a sub 13 b sub 31, a sub 11 b sub 12 plus a sub 12 b sub 22 plus a sub 13 b sub 32; a sub 21 b sub 11 plus a sub 22 b sub 21 plus a sub 23 b sub 31, a sub 21 b sub 12 plus a sub 22 b sub 22 plus a sub 23 b sub 32 ] ,")[$[ a_(11) & a_(12) & a_(13) \ a_(21) & a_(22) & a_(23) ] [ b_(11) & b_(12) \ b_(21) & b_(22) \ b_(31) & b_(32) ] = [ a_(11) b_(11) + a_(12) b_(21) + a_(13) b_(31) & & a_(11) b_(12) + a_(12) b_(22) + a_(13) b_(32) \ a_(21) b_(11) + a_(22) b_(21) + a_(23) b_(31) & & a_(21) b_(12) + a_(22) b_(22) + a_(23) b_(32) ] ,$] or with some numbers: #math.equation(block: true, alt: "[ 1, 2, 3; 4, 5, 6 ] [ minus 1, 2; minus 7, 0; 1, minus 1 ] equals [ 1 times open parenthesis minus 1 close parenthesis plus 2 times open parenthesis minus 7 close parenthesis plus 3 times 1, 1 times 2 plus 2 times 0 plus 3 times open parenthesis minus 1 close parenthesis; 4 times open parenthesis minus 1 close parenthesis plus 5 times open parenthesis minus 7 close parenthesis plus 6 times 1, 4 times 2 plus 5 times 0 plus 6 times open parenthesis minus 1 close parenthesis ] equals [ minus 12, minus 1; minus 33, 2 ] .")[$[ 1 & 2 & 3 \ 4 & 5 & 6 ] [ − 1 & 2 \ − 7 & 0 \ 1 & − 1 ] = [ 1 · ( − 1 ) + 2 · ( − 7 ) + 3 · 1 & & 1 · 2 + 2 · 0 + 3 · ( − 1 ) \ 4 · ( − 1 ) + 5 · ( − 7 ) + 6 · 1 & & 4 · 2 + 5 · 0 + 6 · ( − 1 ) ] = [ − 12 & − 1 \ − 33 & 2 ] .$] A useful consequence of the definition is that the evaluation #math.equation(block: false, alt: "A x →")[$A arrow(x)$] for a matrix #math.equation(block: false, alt: "A")[$A$] and a (column) vector #math.equation(block: false, alt: "x →")[$arrow(x)$] is also matrix multiplication. That is really why we think of vectors as column vectors, or #math.equation(block: false, alt: "n times 1")[$n × 1$] matrices. For example, #math.equation(block: true, alt: "[ 1, 2; 3, 4 ] [ 2; minus 1 ] equals [ 1 times 2 plus 2 times open parenthesis minus 1 close parenthesis; 3 times 2 plus 4 times open parenthesis minus 1 close parenthesis ] equals [ 0; 2 ] .")[$[ 1 & 2 \ 3 & 4 ] [ 2 \ − 1 ] = [ 1 · 2 + 2 · ( − 1 ) \ 3 · 2 + 4 · ( − 1 ) ] = [ 0 \ 2 ] .$] If you look at the last section, that is precisely the last example we gave. You should stare at the computation of multiplication of matrices #math.equation(block: false, alt: "A B")[$A B$] and the previous definition of #math.equation(block: false, alt: "A y →")[$A arrow(y)$] as a mapping for a moment. What we are doing with matrix multiplication is applying the mapping #math.equation(block: false, alt: "A")[$A$] to the columns of #math.equation(block: false, alt: "B")[$B$]. This is usually written as follows. Suppose we write the #math.equation(block: false, alt: "n times p")[$n × p$] matrix #math.equation(block: false, alt: "B equals [ b → sub 1 b → sub 2 ⋯ b → sub p ]")[$B = [ arrow(b)_(1) " " arrow(b)_(2) " " ⋯ " " arrow(b)_(p) ]$], where #math.equation(block: false, alt: "b → sub 1 , b → sub 2 , … , b → sub p")[$arrow(b)_(1) , arrow(b)_(2) , … , arrow(b)_(p)$] are the columns of #math.equation(block: false, alt: "B")[$B$]. Then for an #math.equation(block: false, alt: "m times n")[$m × n$] matrix #math.equation(block: false, alt: "A")[$A$], #math.equation(block: true, alt: "A B equals A [ b → sub 1 b → sub 2 ⋯ b → sub p ] equals [ A b → sub 1 A b → sub 2 ⋯ A b → sub p ] .")[$A B = A [ arrow(b)_(1) " " arrow(b)_(2) " " ⋯ " " arrow(b)_(p) ] = [ A arrow(b)_(1) " " A arrow(b)_(2) " " ⋯ " " A arrow(b)_(p) ] .$] The columns of the #math.equation(block: false, alt: "m times p")[$m × p$] matrix #math.equation(block: false, alt: "A B")[$A B$] are the vectors #math.equation(block: false, alt: "A b → sub 1 , A b → sub 2 , … , A b → sub p")[$A arrow(b)_(1) , A arrow(b)_(2) , … , A arrow(b)_(p)$]. For example, in (9.2.1), the columns of #math.equation(block: true, alt: "[ a sub 11, a sub 12, a sub 13; a sub 21, a sub 22, a sub 23 ] [ b sub 11, b sub 12; b sub 21, b sub 22; b sub 31, b sub 32 ]")[$[ a_(11) & a_(12) & a_(13) \ a_(21) & a_(22) & a_(23) ] [ b_(11) & b_(12) \ b_(21) & b_(22) \ b_(31) & b_(32) ]$] are #math.equation(block: true, alt: "[ a sub 11, a sub 12, a sub 13; a sub 21, a sub 22, a sub 23 ] [ b sub 11; b sub 21; b sub 31 ] and [ a sub 11, a sub 12, a sub 13; a sub 21, a sub 22, a sub 23 ] [ b sub 12; b sub 22; b sub 32 ] .")[$[ a_(11) & a_(12) & a_(13) \ a_(21) & a_(22) & a_(23) ] [ b_(11) \ b_(21) \ b_(31) ] #h(2em) "and" #h(2em) [ a_(11) & a_(12) & a_(13) \ a_(21) & a_(22) & a_(23) ] [ b_(12) \ b_(22) \ b_(32) ] .$] This is a very useful way to understand what matrix multiplication is. It should also make it easier to remember how to perform matrix multiplication. === Rules of Matrix Algebra For multiplication we want an analogue of a 1. That is, we desire a matrix that just leaves everything as it found it. This analogue is the so-called #emph[identity matrix]. The identity matrix is a square matrix with 1s on the main diagonal and zeros everywhere else. It is usually denoted by #math.equation(block: false, alt: "I")[$I$]. For each size we have a different identity matrix and so sometimes we may denote the size as a subscript. For example, #math.equation(block: false, alt: "I sub 3")[$I_(3)$] is the #math.equation(block: false, alt: "3 times 3")[$3 × 3$] identity matrix #math.equation(block: true, alt: "I equals I sub 3 equals [ 1, 0, 0; 0, 1, 0; 0, 0, 1 ] .")[$I = I_(3) = [ 1 & 0 & 0 \ 0 & 1 & 0 \ 0 & 0 & 1 ] .$] Let us see how the matrix works on a smaller example, #math.equation(block: true, alt: "[ a sub 11, a sub 12; a sub 21, a sub 22 ] [ 1, 0; 0, 1 ] equals [ a sub 11 times 1 plus a sub 12 times 0, a sub 11 times 0 plus a sub 12 times 1; a sub 21 times 1 plus a sub 22 times 0, a sub 21 times 0 plus a sub 22 times 1 ] equals [ a sub 11, a sub 12; a sub 21, a sub 22 ] .")[$[ a_(11) & a_(12) \ a_(21) & a_(22) ] [ 1 & 0 \ 0 & 1 ] = [ a_(11) · 1 + a_(12) · 0 & & a_(11) · 0 + a_(12) · 1 \ a_(21) · 1 + a_(22) · 0 & & a_(21) · 0 + a_(22) · 1 ] = [ a_(11) & a_(12) \ a_(21) & a_(22) ] .$] Multiplication by the identity from the left looks similar, and also does not touch anything. We have the following rules for matrix multiplication. Suppose that #math.equation(block: false, alt: "A")[$A$], #math.equation(block: false, alt: "B")[$B$], #math.equation(block: false, alt: "C")[$C$] are matrices of the correct sizes so that the following make sense. Let #math.equation(block: false, alt: "α")[$α$] denote a scalar (number). Then #math.equation(block: true, alt: "A open parenthesis B C close parenthesis equals open parenthesis A B close parenthesis C (associative law) ,; A open parenthesis B plus C close parenthesis equals A B plus A C (distributive law) ,; open parenthesis B plus C close parenthesis A equals B A plus C A (distributive law) ,; α open parenthesis A B close parenthesis equals open parenthesis α A close parenthesis B equals A open parenthesis α B close parenthesis ,; I A equals A equals A I (identity) .")[$A ( B C ) = ( A B ) C "(associative law)" , \ A ( B + C ) = A B + A C "(distributive law)" , \ ( B + C ) A = B A + C A "(distributive law)" , \ α ( A B ) = ( α A ) B = A ( α B ) , \ I A = A = A I "(identity)" .$] #examplebox("Example 1")[][ Let us demonstrate a couple of these rules. For example, the associative law: #math.equation(block: true, alt: "[ minus 3, 3; 2, minus 2 ] ⏟ A open parenthesis [ 4, 4; 1, minus 3 ] ⏟ B [ minus 1, 4; 5, 2 ] ⏟ C close parenthesis equals [ minus 3, 3; 2, minus 2 ] ⏟ A [ 16, 24; minus 16, minus 2 ] ⏟ B C equals [ minus 96, minus 78; 64, 52 ] ⏟ A open parenthesis B C close parenthesis ,")[$limits(underbrace([ − 3 & 3 \ 2 & − 2 ]))_(A) ( limits(underbrace([ 4 & 4 \ 1 & − 3 ]))_(B) limits(underbrace([ − 1 & 4 \ 5 & 2 ]))_(C) ) = limits(underbrace([ − 3 & 3 \ 2 & − 2 ]))_(A) limits(underbrace([ 16 & 24 \ − 16 & − 2 ]))_(B C) = limits(underbrace([ − 96 & − 78 \ 64 & 52 ]))_(A ( B C )) ,$] and #math.equation(block: true, alt: "open parenthesis [ minus 3, 3; 2, minus 2 ] ⏟ A [ 4, 4; 1, minus 3 ] ⏟ B close parenthesis [ minus 1, 4; 5, 2 ] ⏟ C equals [ minus 9, minus 21; 6, 14 ] ⏟ A B [ minus 1, 4; 5, 2 ] ⏟ C equals [ minus 96, minus 78; 64, 52 ] ⏟ open parenthesis A B close parenthesis C .")[$( limits(underbrace([ − 3 & 3 \ 2 & − 2 ]))_(A) limits(underbrace([ 4 & 4 \ 1 & − 3 ]))_(B) ) limits(underbrace([ − 1 & 4 \ 5 & 2 ]))_(C) = limits(underbrace([ − 9 & − 21 \ 6 & 14 ]))_(A B) limits(underbrace([ − 1 & 4 \ 5 & 2 ]))_(C) = limits(underbrace([ − 96 & − 78 \ 64 & 52 ]))_(( A B ) C) .$] Or how about multiplication by scalars: #math.equation(block: true, alt: "10 open parenthesis [ minus 3, 3; 2, minus 2 ] ⏟ A [ 4, 4; 1, minus 3 ] ⏟ B close parenthesis equals 10 [ minus 9, minus 21; 6, 14 ] ⏟ A B equals [ minus 90, minus 210; 60, 140 ] ⏟ 10 open parenthesis A B close parenthesis ,; open parenthesis 10 [ minus 3, 3; 2, minus 2 ] ⏟ A close parenthesis [ 4, 4; 1, minus 3 ] ⏟ B equals [ minus 30, 30; 20, minus 20 ] ⏟ 10 A [ 4, 4; 1, minus 3 ] ⏟ B equals [ minus 90, minus 210; 60, 140 ] ⏟ open parenthesis 10 A close parenthesis B ,")[$10 ( limits(underbrace([ − 3 & 3 \ 2 & − 2 ]))_(A) limits(underbrace([ 4 & 4 \ 1 & − 3 ]))_(B) ) = 10 limits(underbrace([ − 9 & − 21 \ 6 & 14 ]))_(A B) = limits(underbrace([ − 90 & − 210 \ 60 & 140 ]))_(10 ( A B )) , \ ( 10 limits(underbrace([ − 3 & 3 \ 2 & − 2 ]))_(A) ) limits(underbrace([ 4 & 4 \ 1 & − 3 ]))_(B) = limits(underbrace([ − 30 & 30 \ 20 & − 20 ]))_(10 A) limits(underbrace([ 4 & 4 \ 1 & − 3 ]))_(B) = limits(underbrace([ − 90 & − 210 \ 60 & 140 ]))_(( 10 A ) B) ,$] and #math.equation(block: true, alt: "[ minus 3, 3; 2, minus 2 ] ⏟ A open parenthesis 10 [ 4, 4; 1, minus 3 ] ⏟ B close parenthesis equals [ minus 3, 3; 2, minus 2 ] ⏟ A [ 40, 40; 10, minus 30 ] ⏟ 10 B equals [ minus 90, minus 210; 60, 140 ] ⏟ A open parenthesis 10 B close parenthesis .")[$limits(underbrace([ − 3 & 3 \ 2 & − 2 ]))_(A) ( 10 limits(underbrace([ 4 & 4 \ 1 & − 3 ]))_(B) ) = limits(underbrace([ − 3 & 3 \ 2 & − 2 ]))_(A) limits(underbrace([ 40 & 40 \ 10 & − 30 ]))_(10 B) = limits(underbrace([ − 90 & − 210 \ 60 & 140 ]))_(A ( 10 B )) .$] ] A multiplication rule, one you have used since primary school on numbers, is quite conspicuously missing for matrices. That is, matrix multiplication is not commutative. Firstly, just because #math.equation(block: false, alt: "A B")[$A B$] makes sense, it may be that #math.equation(block: false, alt: "B A")[$B A$] is not even defined. For example, if #math.equation(block: false, alt: "A")[$A$] is #math.equation(block: false, alt: "2 times 3")[$2 × 3$], and #math.equation(block: false, alt: "B")[$B$] is #math.equation(block: false, alt: "3 times 4")[$3 × 4$], the we can multiply #math.equation(block: false, alt: "A B")[$A B$] but not #math.equation(block: false, alt: "B A")[$B A$]. Even if #math.equation(block: false, alt: "A B")[$A B$] and #math.equation(block: false, alt: "B A")[$B A$] are both defined, does not mean that they are equal. For example, take #math.equation(block: false, alt: "A equals [ 1, 1; 1, 1 ]")[$A = [ 1 & 1 \ 1 & 1 ]$] and #math.equation(block: false, alt: "B equals [ 1, 0; 0, 2 ]")[$B = [ 1 & 0 \ 0 & 2 ]$]: #math.equation(block: true, alt: "A B equals [ 1, 1; 1, 1 ] [ 1, 0; 0, 2 ] equals [ 1, 2; 1, 2 ] ⧸ equals [ 1, 1; 2, 2 ] equals [ 1, 0; 0, 2 ] [ 1, 1; 1, 1 ] equals B A .")[$A B = [ 1 & 1 \ 1 & 1 ] [ 1 & 0 \ 0 & 2 ] = [ 1 & 2 \ 1 & 2 ] #h(2em) "⧸" = #h(2em) [ 1 & 1 \ 2 & 2 ] = [ 1 & 0 \ 0 & 2 ] [ 1 & 1 \ 1 & 1 ] = B A .$] === Inverse A couple of other algebra rules you know for numbers do not quite work on matrices: + #math.equation(block: false, alt: "A B equals A C")[$A B = A C$] does not necessarily imply #math.equation(block: false, alt: "B equals C")[$B = C$], even if #math.equation(block: false, alt: "A")[$A$] is not 0. + #math.equation(block: false, alt: "A B equals 0")[$A B = 0$] does not necessarily mean that #math.equation(block: false, alt: "A equals 0")[$A = 0$] or #math.equation(block: false, alt: "B equals 0")[$B = 0$]. For example: #math.equation(block: true, alt: "[ 0, 1; 0, 0 ] [ 0, 1; 0, 0 ] equals [ 0, 0; 0, 0 ] equals [ 0, 1; 0, 0 ] [ 0, 2; 0, 0 ] .")[$[ 0 & 1 \ 0 & 0 ] [ 0 & 1 \ 0 & 0 ] = [ 0 & 0 \ 0 & 0 ] = [ 0 & 1 \ 0 & 0 ] [ 0 & 2 \ 0 & 0 ] .$] To make these rules hold, we do not just need one of the matrices to not be zero, we would need to by a matrix. This is where the #emph[matrix inverse]comes in. Suppose that #math.equation(block: false, alt: "A")[$A$] and #math.equation(block: false, alt: "B")[$B$] are #math.equation(block: false, alt: "n times n")[$n × n$] matrices such that #math.equation(block: true, alt: "A B equals I equals B A .")[$A B = I = B A .$] Then we call #math.equation(block: false, alt: "B")[$B$] the inverse of #math.equation(block: false, alt: "A")[$A$] and we denote #math.equation(block: false, alt: "B")[$B$] by #math.equation(block: false, alt: "A to the power minus 1")[$A^(− 1)$]. Perhaps not surprisingly, #math.equation(block: false, alt: "open parenthesis A to the power minus 1 close parenthesis to the power minus 1 equals A")[$attach(( A^(− 1) ), t: − 1) = A$], since if the inverse of #math.equation(block: false, alt: "A")[$A$] is #math.equation(block: false, alt: "B")[$B$], then the inverse of #math.equation(block: false, alt: "B")[$B$] is #math.equation(block: false, alt: "A")[$A$]. If the inverse of #math.equation(block: false, alt: "A")[$A$] exists, then we say #math.equation(block: false, alt: "A")[$A$] is #emph[invertible]. If #math.equation(block: false, alt: "A")[$A$] is not invertible, we say #math.equation(block: false, alt: "A")[$A$] is #emph[singular]. If #math.equation(block: false, alt: "A equals [ a ]")[$A = [ a ]$] is a #math.equation(block: false, alt: "1 times 1")[$1 × 1$] matrix, then #math.equation(block: false, alt: "A to the power minus 1")[$A^(− 1)$] is #math.equation(block: false, alt: "a to the power minus 1 equals the fraction 1 over a")[$a^(− 1) = frac(1, a)$]. That is where the notation comes from. The computation is not nearly as simple when #math.equation(block: false, alt: "A")[$A$] is larger. The proper formulation of the cancellation rule is: #emph[If #math.equation(block: false, alt: "A")[$A$] is invertible, then #math.equation(block: false, alt: "A B equals A C")[$A B = A C$] implies #math.equation(block: false, alt: "B equals C")[$B = C$].] The computation is what you would do in regular algebra with numbers, but you have to be careful never to commute matrices: #math.equation(block: true, alt: "A B equals A C ,; A to the power minus 1 A B equals A to the power minus 1 A C ,; I B equals I C ,; B equals C .")[$A B = A C , \ A^(− 1) A B = A^(− 1) A C , \ I B = I C , \ B = C .$] And similarly for cancellation on the right: #emph[If #math.equation(block: false, alt: "A")[$A$] is invertible, then #math.equation(block: false, alt: "B A equals C A")[$B A = C A$] implies #math.equation(block: false, alt: "B equals C")[$B = C$].] The rule says, among other things, that the inverse of a matrix is unique if it exists: If #math.equation(block: false, alt: "A B equals I equals A C")[$A B = I = A C$], then #math.equation(block: false, alt: "A")[$A$] is invertible and #math.equation(block: false, alt: "B equals C")[$B = C$]. We will see later how to compute an inverse of a matrix in general. For now, let us note that there is a simple formula for the inverse of a #math.equation(block: false, alt: "2 times 2")[$2 × 2$] matrix #math.equation(block: true, alt: "[ to the power a, b; c, d equals the fraction 1 over a d minus b c [ d, minus b; minus c, a ] .")[$\[^(a & b \ c & d) = frac(1, a d − b c) \[ d & − b \ − c & a \] .$] For example: #math.equation(block: true, alt: "[ to the power 1, 1; 2, 4 equals the fraction 1 over 1 times 4 minus 1 times 2 [ 4, minus 1; minus 2, 1 ] equals [ 2, the fraction minus 1 over 2; minus 1, the fraction 1 over 2 ] .")[$\[^(1 & 1 \ 2 & 4) = frac(1, 1 · 4 − 1 · 2) \[ 4 & − 1 \ − 2 & 1 \] = \[ 2 & frac(− 1, 2) \ − 1 & frac(1, 2) \] .$] Let’s try it: #math.equation(block: true, alt: "[ 1, 1; 2, 4 ] [ 2, the fraction minus 1 over 2; minus 1, the fraction 1 over 2 ] equals [ 1, 0; 0, 1 ] and [ 2, the fraction minus 1 over 2; minus 1, the fraction 1 over 2 ] [ 1, 1; 2, 4 ] equals [ 1, 0; 0, 1 ] .")[$[ 1 & 1 \ 2 & 4 ] [ 2 & frac(− 1, 2) \ − 1 & frac(1, 2) ] = [ 1 & 0 \ 0 & 1 ] #h(2em) "and" #h(2em) [ 2 & frac(− 1, 2) \ − 1 & frac(1, 2) ] [ 1 & 1 \ 2 & 4 ] = [ 1 & 0 \ 0 & 1 ] .$] Just as we cannot divide by every number, not every matrix is invertible. In the case of matrices however we may have singular matrices that are not zero. For example, #math.equation(block: true, alt: "[ 1, 1; 2, 2 ]")[$[ 1 & 1 \ 2 & 2 ]$] is a singular matrix. But didn’t we just give a formula for an inverse? Let us try it: #math.equation(block: true, alt: "[ to the power 1, 1; 2, 2 equals the fraction 1 over 1 times 2 minus 1 times 2 [ 2, minus 1; minus 2, 1 ] equals ?")[$\[^(1 & 1 \ 2 & 2) = frac(1, 1 · 2 − 1 · 2) \[ 2 & − 1 \ − 2 & 1 \] = ?$] We get into a bit of trouble; we are trying to divide by zero. So a #math.equation(block: false, alt: "2 times 2")[$2 × 2$] matrix #math.equation(block: false, alt: "A")[$A$] is invertible whenever #math.equation(block: true, alt: "a d minus b c ⧸ equals 0")[$a d − b c "⧸" = 0$] and otherwise it is singular. The expression #math.equation(block: false, alt: "a d minus b c")[$a d − b c$] is called the #emph[determinant] and we will look at it more carefully in a later section. There is a similar expression for a square matrix of any size. === Diagonal Matrices A simple (and surprisingly useful) type of a square matrix is a so-called #emph[diagonal matrix]. It is a matrix whose entries are all zero except those on the main diagonal from top left to bottom right. For example a #math.equation(block: false, alt: "4 times 4")[$4 × 4$] diagonal matrix is of the form #math.equation(block: true, alt: "[ d sub 1, 0, 0, 0; 0, d sub 2, 0, 0; 0, 0, d sub 3, 0; 0, 0, 0, d sub 4 ] .")[$[ d_(1) & 0 & 0 & 0 \ 0 & d_(2) & 0 & 0 \ 0 & 0 & d_(3) & 0 \ 0 & 0 & 0 & d_(4) ] .$] Such matrices have nice properties when we multiply by them. If we multiply them by a vector, they multiply the #math.equation(block: false, alt: "k to the power th")[$k^("th")$] entry by #math.equation(block: false, alt: "d sub k")[$d_(k)$]. For example, #math.equation(block: true, alt: "[ 1, 0, 0; 0, 2, 0; 0, 0, 3 ] [ 4; 5; 6 ] equals [ 1 times 4; 2 times 5; 3 times 6 ] equals [ 4; 10; 18 ] .")[$[ 1 & 0 & 0 \ 0 & 2 & 0 \ 0 & 0 & 3 ] [ 4 \ 5 \ 6 ] = [ 1 · 4 \ 2 · 5 \ 3 · 6 ] = [ 4 \ 10 \ 18 ] .$] Similarly, when they multiply another matrix from the left, they multiply the #math.equation(block: false, alt: "k to the power th")[$k^("th")$] row by #math.equation(block: false, alt: "d sub k")[$d_(k)$]. For example, #math.equation(block: true, alt: "[ 2, 0, 0; 0, 3, 0; 0, 0, minus 1 ] [ 1, 1, 1; 1, 1, 1; 1, 1, 1 ] equals [ 2, 2, 2; 3, 3, 3; minus 1, minus 1, minus 1 ] .")[$[ 2 & 0 & 0 \ 0 & 3 & 0 \ 0 & 0 & − 1 ] [ 1 & 1 & 1 \ 1 & 1 & 1 \ 1 & 1 & 1 ] = [ 2 & 2 & 2 \ 3 & 3 & 3 \ − 1 & − 1 & − 1 ] .$] On the other hand, multiplying on the right, they multiply the columns: #math.equation(block: true, alt: "[ 1, 1, 1; 1, 1, 1; 1, 1, 1 ] [ 2, 0, 0; 0, 3, 0; 0, 0, minus 1 ] equals [ 2, 3, minus 1; 2, 3, minus 1; 2, 3, minus 1 ] .")[$[ 1 & 1 & 1 \ 1 & 1 & 1 \ 1 & 1 & 1 ] [ 2 & 0 & 0 \ 0 & 3 & 0 \ 0 & 0 & − 1 ] = [ 2 & 3 & − 1 \ 2 & 3 & − 1 \ 2 & 3 & − 1 ] .$] And it is really easy to multiply two diagonal matrices together—we multiply the entries: #math.equation(block: true, alt: "[ 1, 0, 0; 0, 2, 0; 0, 0, 3 ] [ 2, 0, 0; 0, 3, 0; 0, 0, minus 1 ] equals [ 1 times 2, 0, 0; 0, 2 times 3, 0; 0, 0, 3 times open parenthesis minus 1 close parenthesis ] equals [ 2, 0, 0; 0, 6, 0; 0, 0, minus 3 ] .")[$[ 1 & 0 & 0 \ 0 & 2 & 0 \ 0 & 0 & 3 ] [ 2 & 0 & 0 \ 0 & 3 & 0 \ 0 & 0 & − 1 ] = [ 1 · 2 & 0 & 0 \ 0 & 2 · 3 & 0 \ 0 & 0 & 3 · ( − 1 ) ] = [ 2 & 0 & 0 \ 0 & 6 & 0 \ 0 & 0 & − 3 ] .$] For this last reason, they are easy to invert, you simply invert each diagonal element: #math.equation(block: true, alt: "[ to the power d sub 1, 0, 0; 0, d sub 2, 0; 0, 0, d sub 3 equals [ d 1 minus 1, 0, 0; 0, d 2 minus 1, 0; 0, 0, d 3 minus 1 ] .")[$\[^(d_(1) & 0 & 0 \ 0 & d_(2) & 0 \ 0 & 0 & d_(3)) = \[ d_(1)^(− 1) & 0 & 0 \ 0 & d_(2)^(− 1) & 0 \ 0 & 0 & d_(3)^(− 1) \] .$] Let us check an example #math.equation(block: true, alt: "[ to the power 2, 0, 0; 0, 3, 0; 0, 0, 4 ⏟ A to the power minus 1 [ 2, 0, 0; 0, 3, 0; 0, 0, 4 ] ⏟ A equals [ the fraction 1 over 2, 0, 0; 0, the fraction 1 over 3, 0; 0, 0, the fraction 1 over 4 ] ⏟ A to the power minus 1 [ 2, 0, 0; 0, 3, 0; 0, 0, 4 ] ⏟ A equals [ 1, 0, 0; 0, 1, 0; 0, 0, 1 ] ⏟ I .")[$limits(underbrace(\[^(2 & 0 & 0 \ 0 & 3 & 0 \ 0 & 0 & 4)))_(A^(− 1)) limits(underbrace(\[ 2 & 0 & 0 \ 0 & 3 & 0 \ 0 & 0 & 4 \]))_(A) = limits(underbrace(\[ frac(1, 2) & 0 & 0 \ 0 & frac(1, 3) & 0 \ 0 & 0 & frac(1, 4) \]))_(A^(− 1)) limits(underbrace(\[ 2 & 0 & 0 \ 0 & 3 & 0 \ 0 & 0 & 4 \]))_(A) = limits(underbrace(\[ 1 & 0 & 0 \ 0 & 1 & 0 \ 0 & 0 & 1 \]))_(I) .$] It is no wonder that the way we solve many problems in linear algebra (and in differential equations) is to try to reduce the problem to the case of diagonal matrices. === Transpose Vectors do not always have to be column vectors, that is just a convention. Swapping rows and columns is from time to time needed. The operation that swaps rows and columns is the so-called #emph[transpose]. The transpose of #math.equation(block: false, alt: "A")[$A$] is denoted by #math.equation(block: false, alt: "A to the power T")[$A^(T)$]. Example: #math.equation(block: true, alt: "[ to the power 1, 2, 3; 4, 5, 6 equals [ 1, 4; 2, 5; 3, 6 ] .")[$\[^(1 & 2 & 3 \ 4 & 5 & 6) = \[ 1 & 4 \ 2 & 5 \ 3 & 6 \] .$] Transpose takes an #math.equation(block: false, alt: "m times n")[$m × n$] matrix to an #math.equation(block: false, alt: "n times m")[$n × m$] matrix. A key feature of the transpose is that if the product #math.equation(block: false, alt: "A B")[$A B$] makes sense, then #math.equation(block: false, alt: "B to the power T A to the power T")[$B^(T) A^(T)$] also makes sense, at least from the point of view of sizes. In fact, we get precisely the transpose of #math.equation(block: false, alt: "A B")[$A B$]. That is: #math.equation(block: true, alt: "open parenthesis A B close parenthesis to the power T equals B to the power T A to the power T .")[$attach(( A B ), t: T) = B^(T) A^(T) .$] For example, #math.equation(block: true, alt: "open parenthesis [ 1, 2, 3; 4, 5, 6 ] [ 0, 1; 1, 0; 2, minus 2 ] close parenthesis to the power T equals [ 0, 1, 2; 1, 0, minus 2 ] [ 1, 4; 2, 5; 3, 6 ] .")[$attach(( [ 1 & 2 & 3 \ 4 & 5 & 6 ] [ 0 & 1 \ 1 & 0 \ 2 & − 2 ] ), t: T) = [ 0 & 1 & 2 \ 1 & 0 & − 2 ] [ 1 & 4 \ 2 & 5 \ 3 & 6 ] .$] It is left to the reader to verify that computing the matrix product on the left and then transposing is the same as computing the matrix product on the right. If we have a column vector #math.equation(block: false, alt: "x →")[$arrow(x)$] to which we apply a matrix #math.equation(block: false, alt: "A")[$A$] and we transpose the result, then the row vector #math.equation(block: false, alt: "x → to the power T")[$arrow(x)^(T)$] applies to #math.equation(block: false, alt: "A to the power T")[$A^(T)$] from the left: #math.equation(block: true, alt: "open parenthesis A x → close parenthesis to the power T equals x → to the power T A to the power T .")[$attach(( A arrow(x) ), t: T) = arrow(x)^(T) A^(T) .$] Another place where transpose is useful is when we wish to apply the dot product#math.equation(block: false, alt: "to the power 1")[$1$] to two column vectors: #math.equation(block: true, alt: "x → times y → equals y → to the power T x → .")[$arrow(x) · arrow(y) = arrow(y)^(T) arrow(x) .$] That is the way that one often writes the dot product in software. We say a matrix #math.equation(block: false, alt: "A")[$A$] is #emph[symmetric] if #math.equation(block: false, alt: "A equals A to the power T")[$A = A^(T)$]. For example, #math.equation(block: true, alt: "[ 1, 2, 3; 2, 4, 5; 3, 5, 6 ]")[$[ 1 & 2 & 3 \ 2 & 4 & 5 \ 3 & 5 & 6 ]$] is a symmetric matrix. Notice that a symmetric matrix is always square, that is, #math.equation(block: false, alt: "n times n")[$n × n$]. Symmetric matrices have many nice properties#math.equation(block: false, alt: "squared")[$2$], and come up quite often in applications. === Footnotes \[1\] As a side note, mathematicians write #math.equation(block: false, alt: "y → to the power T x →")[$arrow(y)^(T) arrow(x)$] and physicists write #math.equation(block: false, alt: "x → to the power T y →")[$arrow(x)^(T) arrow(y)$]. Shhh…don’t tell anyone, but the physicists are probably right on this. \[2\] Although so far we have not learned enough about matrices to really appreciate them.