# MAPLE ASSIGNMENT Matrix part 2 # The first command loads the matrix algebra operations into Maple. # Change the : to ; if you wish to see all the commands in this package. > with(linalg): # The arithmetic operations for matrices are + , - , &* , ^ .The # following shows how Maple calculates a determinant. You can of course # put any numbers that you like into M > M:=matrix(3,3,[1,0,-1,3,6,2,3,-3,1]); > det(M); # The next command allows you to check that you can calculate a 3X3 # determinant by hand. Fill in the 4 missing terms. > (1*6*1)-((-1)*6*3) # Diagonal matrices are created with the diag command. This can be used # to create an identity matrix. > iden:=diag(1,1,1); # Inverse matrices are either M^(-1) or inverse(M). The following # calculate the inverse, check that it # works and illustrate the properties of inverses. > M1:=M^(-1); > evalm(%); > evalm(M&*M1-iden); > evalm(M1&*M-iden); > evalm(M1^(-1)); # To check that you understand how to calculate the inverse matrix by # hand replace the ? in the command below by appropriate entries from M > evalm(M); > M1??:=((-1)^?)*det(matrix(2,2,[?,?,?,?]))/det(M); > > evalm(M1); # The next commands illustrate the correct and the incorrect way to get # the inverse of the product of two matrices. > M2:=evalm(M+M1); > evalm((M&*M2)^(-1)); > evalm((M2^(-1))&*(M^(-1))); > evalm((M^(-1))*(M2^(-1))); > evalm((M^(-1))+(M2^(-1))); > evalm((M+M2)^(-1)); # The last two commands have illustrated a dumb artihmetical mistake you # should not make even with numbers. # PROPERTIES OF DETERMINANTS # The commands below check some of the properties of determinants. You # should look to see that the new matrices being created are what you # expect them to be. > evalm(M); > M3:=transpose(M); > det(M3); > M4:=swaprow(M,1,3); > det(M4); > M5:=swapcol(M4,1,2); > det(M5); > M6:=mulrow(M5,3,0.3); > det(M6); > det(M5)*0.3; > M7:=mulcol(M6,2,3); > det(M7); > det(M6)*3; > M8:=addrow(M7,1,3,.5); > det(M8); > M9:=addcol(M8,3,2,1.5); > det(M9); # A matrix with two identical rows or two identical columns has a zero # determinant. Change the ? below to create such a matrix and then check # this property out. > M10:=matrix(3,3,[?,?,?,?,?,?,?,?,?]); > det(M10); # M1 was the inverse matrix of M > det(M); > det(M1); # The determinant of the product is the product of the determinants. # This does not work with sums however. > det(M&*M9); > det(M)*det(M9); > det(M+M9); > det(M)+det(M9);