Transcription of Matrix Primer - Stanford University
1 Lecture 2 Matrix operations transpose, sum & difference, scalar multiplication Matrix multiplication , Matrix -vector product Matrix inverse2 1 Matrix transposetransposeofm nmatrixA, denotedATorA , isn mmatrix with AT ij=Ajirows and columns ofAare transposed inATexample: 0 47 03 1 T= 0 7 34 0 1 . transpose converts row vectors to column vectors, vice versa AT T=AMatrix Operations2 2 Matrix addition & subtractionifAandBare bothm n, we formA+Bby adding corresponding entriesexample: 0 47 03 1 + 1 22 30 4 = 1 69 33 5 can add row or column vectors same way (but never to each other!) Matrix subtraction is similar: 1 69 3 I= 0 69 2 (here we had to figure out thatImust be2 2) Matrix Operations2 3 Properties of Matrix addition commutative:A+B=B+A associative:(A+B) +C=A+ (B+C), so we can write asA+B+C A+ 0 = 0 +A=A;A A= 0 (A+B)T=AT+BTMatrix Operations2 4 Scalar multiplicationwe can multiply a number ( ) by a Matrix by multiplying everyentry of the Matrix by the scalarthis is denoted by juxtaposition or , with the scalar on the left:( 2) 1 69 36 0 = 2 12 18 6 12 0 (sometimes you see scalar multiplication with the scalar onthe right) ( + )A= A+ A;( )A= ( )( A) (A+B) = A+ B 0 A= 0;1 A=AMatrix Operations2 5 Matrix multiplicationifAism pandBisp nwe can formC=AB, which ism nCij=pXk=1aikbkj=ai1b1j+ +aipbpj, i= 1.
2 , m, j= 1, .. , nto formAB, #cols ofAmust equal #rows ofB; calledcompatible to findi, jentry of the productC=AB, you need theith row ofAand thejth column ofB form product of corresponding entries, , third component ofith rowofAand third component ofjth column ofB add up all the productsMatrix Operations2 6 Examplesexample 1: 1 69 3 0 1 1 2 = 6 11 3 3 for example, to get1,1entry of product:C11=A11B11+A12B21= (1)(0) + (6)( 1) = 6example 2: 0 1 1 2 1 69 3 = 9 317 0 these examples illustrate that Matrix multiplication is not (in general)commutative: we don t (always) haveAB=BAMatrix Operations2 7 Properties of Matrix multiplication 0A= 0,A0 = 0(here0can be scalar, or a compatible Matrix ) IA=A,AI=A (AB)C=A(BC), so we can write asABC (AB) = ( A)B, where is a scalar A(B+C) =AB+AC,(A+B)C=AC+BC (AB)T=BTATM atrix Operations2 8 Matrix -vector productvery important special case of Matrix multiplication :y=Ax Ais anm nmatrix xis ann-vector yis anm-vectoryi=Ai1x1+ +Ainxn, i= 1.
3 , mcan think ofy=Axas a function that transformsn-vectors intom-vectors a set ofmlinear equations relatingxtoyMatrix Operations2 9 Inner productifvis a rown-vector andwis a columnn-vector, thenvwmakes sense,and has size1 1, , is a scalar:vw=v1w1+ +vnwnifxandyaren-vectors,xTyis a scalar calledinner productordotproductofx,y, and denotedhx, yiorx y:hx, yi=xTy=x1y1+ +xnyn(the symbol can be ambiguous it can mean dot product, or ordinarymatrix product) Matrix Operations2 10 Matrix powersif matrixAis square, then productAAmakes sense, and is denotedA2more generally,kcopies ofAmultiplied together givesAk:Ak=A A A|{z}kby convention we setA0=I(non-integer powers likeA1/2are tricky that s an advanced topic)we haveAkAl=Ak+lMatrix Operations2 11 Matrix inverseifAis square, and (square) matrixFsatisfiesF A=I, then Fis called theinverseofA, and is denotedA 1 the matrixAis calledinvertibleornonsingularifAdoesn t have an inverse, it s calledsingularornoninvertibleby definition,A 1A=I; a basic result of linear algebra is thatAA 1=Iwe define negative powers ofAviaA k= A 1 kMatrix Operations2 12 Examplesexample 1: 1 11 2 1=13 2 1 1 1 (you should check this!)
4 Example 2: 1 1 2 2 does not have an inverse; let s see why: a bc d 1 1 2 2 = a 2b a+ 2bc 2d c+ 2d = 1 00 1 .. but you can t havea 2b= 1and a+ 2b= 0 Matrix Operations2 13 Properties of inverse A 1 1=A, , inverse of inverse is original Matrix (assumingAis invertible) (AB) 1=B 1A 1(assumingA,Bare invertible) AT 1= A 1 T(assumingAis invertible) I 1=I ( A) 1= (1/ )A 1(assumingAinvertible, 6= 0) ify=Ax, wherex RnandAis invertible, thenx=A 1y:A 1y=A 1Ax=Ix=xMatrix Operations2 14 Inverse of2 2matrixit s useful to know the general formula for the inverse of a2 2matrix: a bc d 1=1ad bc d b ca providedad bc6= 0(ifad bc= 0, the Matrix is singular)there are similar, but much more complicated, formulas for the inverse oflarger square matrices, but the formulas are rarely usedMatrix Operations2 15