{VERSION 3 0 "IBM INTEL LINUX" "3.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 }{CSTYLE "2D Output" 2 20 "" 0 1 0 0 255 1 0 0 0 0 0 0 0 0 0 } {PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Text Output" -1 2 1 {CSTYLE "" -1 -1 "Courier" 1 10 0 0 255 1 0 0 0 0 0 1 3 0 3 }1 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Warning" 2 7 1 {CSTYLE "" -1 -1 "" 0 1 0 0 255 1 0 0 0 0 0 0 1 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 } {PSTYLE "Error" 7 8 1 {CSTYLE "" -1 -1 "" 0 1 255 0 255 1 0 0 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Maple Output" 0 11 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 3 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {EXCHG {PARA 0 "" 0 "" {TEXT -1 17 "MATRIX OPERATIONS" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 92 "We begin \+ by loading the linalg package which defines most of the matrix functio ns used here." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "with(linal g):" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 333 "In Maple, a matrix can be defined by feeding a list of lists to the function \"matrix\". An mx n matrix (with m rows and n columns) corresponds to a list of m e lements (a column vector) each of which is a list of n numbers (the \+ rows of the matrix). For example, we specify the 2x3 matrix M with \+ rows [1,1,1] and [2,1,3] by" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "M := matrix([[1,1,1],[2,1,3]]);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"MG-%'matrixG6#7$7%\"\"\"F*F*7%\"\"#F*\"\"$" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 132 "Alternatively, we can specify the number of ro ws and columns of the matrix, and then provide the elements in order i n a single list:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "M := ma trix(2,3,[1,1,1,2,1,3]);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"MG-%'m atrixG6#7$7%\"\"\"F*F*7%\"\"#F*\"\"$" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 123 "Individual elements of a matrix can be addressed using two ind ices, the first indicating the row and the second the column:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "M[2,1]; M[2,3];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"#" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\" \"$" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 139 "The transpose T of the ma trix M is the 3x2 matrix whose rows are the columns of M. It is calculated using the \"transpose\" function: " }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 18 "T := transpose(M);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"TG-%'matrixG6#7%7$\"\"\"\"\"#7$F*F*7$F*\"\"$" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 450 "The product, AB, of two matrices \+ is calculated using the binary operator \"&*\"; that is we calculate \+ A &* B. Of course, the number of columns of A must be equal to the nu mber of rows of B. The resulting matrix product will be left in symbo lic form (i.e. as A &* B) unless we force its evaluation by using the \+ function \"evalm\". Here we calculate the product of M and its tran spose T, and then evaluate it with evalm. The result is a 2x2 matri x" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "P := M &* T; evalm(P) ;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"PG-%#&*G6$%\"MG%\"TG" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#-%'matrixG6#7$7$\"\"$\"\"'7$F)\"#9" }} }{EXCHG {PARA 0 "" 0 "" {TEXT -1 45 "On the other hand, T &8* M is a 3x3 matrix:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "Q := evalm( T &* M);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"QG-%'matrixG6#7%7%\"\" &\"\"$\"\"(7%F+\"\"#\"\"%7%F,F/\"#5" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 146 "Observe that both M &* T and T &* M are symmetric, square \+ matrices. (This is always true of the matrix product of a matrix and \+ its transpose." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 112 "The determinant of a square matrix (one with equal numb ers of rows and columns) is given by the \"det\" function:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 50 "A := matrix([[1,1,1],[2,1,3],[5,-1, -2]]); det(A);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"AG-%'matrixG6#7 %7%\"\"\"F*F*7%\"\"#F*\"\"$7%\"\"&!\"\"!\"#" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"#8" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 81 "The invers e of a nonsingular square matrix A can be calculated as \"inverse(A) \"." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "Ainv := inverse(A); " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%%AinvG-%'matrixG6#7%7%#\"\"\"\"# 8F*#\"\"#F,7%#\"#>F,#!\"(F,#!\"\"F,7%F2#\"\"'F,F4" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 18 "evalm(A &* Ainv); " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#-%'matrixG6#7%7%\"\"\"\"\"!F)7%F)F(F)7%F)F)F(" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 93 "When a matrix is multiplied on the right by a list, Maple treats the list as a column vector." }}{PARA 0 "" 0 "" {TEXT -1 89 "When a matrix is multiplied on the left by a li st, Maple treats the list as a row vector." }}{PARA 0 "" 0 "" {TEXT -1 56 "In either case, the result can be simplified by \"evalm\"" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 42 "evalm(A &* [x,y,z]); evalm( [x,y,z] &* A);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#-%'vectorG6#7%,(%\"x G\"\"\"%\"yGF)%\"zGF),(F(\"\"#F*F)F+\"\"$,(F(\"\"&F*!\"\"F+!\"#" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#-%'vectorG6#7%,(%\"xG\"\"\"%\"yG\"\"#% \"zG\"\"&,(F(F)F*F)F,!\"\",(F(F)F*\"\"$F,!\"#" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 179 "A set of n linear equations in n variables can be written in the form AX=B where A is an nxn matrix and X and B are co lumn n-vectors. Thus the solution can be calculated as " }}{PARA 0 " " 0 "" {TEXT -1 40 "X := Ainv &* B. For example, the system" }}{PARA 0 "" 0 "" {TEXT -1 30 " x + y + z = 2" }}{PARA 0 "" 0 "" {TEXT -1 27 " 2x + y + 3z = 9" }}{PARA 0 "" 0 "" {TEXT -1 26 " 5x - y - 2z = 1" }}{PARA 0 "" 0 "" {TEXT -1 85 "has \+ has the matrix A defined above, and B = [2,9,1]. The solution of th e system is" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "X := evalm(A inv &* [2,9,1]);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"XG-%'vectorG6# 7%\"\"\"!\"#\"\"$" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 95 "that is, x \+ = 1, y = -2, z = 3. Maple provides a simpler way of solving the sys tem AX = B; " }}{PARA 0 "" 0 "" {TEXT -1 46 "we just need to use the \+ function linsolve(A,B)" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "X := linsolve(A,[2,9,1]);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"XG-%'v ectorG6#7%\"\"\"!\"#\"\"$" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 160 "\"l insolve\" is better at solving linear systems than is matrix inversion , since it can solve some systems for which the matrix is singular: C onsider the systems" }}{PARA 0 "" 0 "" {TEXT -1 85 " x + y = 1 x + y = 1" } }{PARA 0 "" 0 "" {TEXT -1 80 " 2x + 2y = 2 \+ 2x + 2y = 1" }}{PARA 0 "" 0 "" {TEXT -1 97 "The first has a one parameter family of solutions x = t, y = 1-t . The second has no solutions." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 54 "L := matrix([[1,1],[2,2]]); C1 := [1,2]; C2 := [1,1];" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"LG-%'matrixG6#7$7$\"\"\"F*7$\"\"#F ," }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%#C1G7$\"\"\"\"\"#" }}{PARA 11 " " 1 "" {XPPMATH 20 "6#>%#C2G7$\"\"\"F&" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "X := linsolve(L,C1);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"XG-%'vectorG6#7$,&\"\"\"F*&%#_tG6#F*!\"\"F+" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "X := linsolve(L,C2);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"XG6\"" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 165 "Now \+ X is undefined, indicating no solutions for LX=C2. But the matrix \"i nverse(L)\" does not exist, so the solution of LX=C1 cannot be found a s X := inverse(L) &* C1" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 " X := inverse(L) &* C1;" }}{PARA 8 "" 1 "" {TEXT -1 35 "Error, (in inve rse) singular matrix" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 158 "The lina lg package has procedures for finding the eigenvalues and eigenvectors of matrices. For a real symmetric matrix, the eigenvalues are always real. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 41 "K := matrix([ [3,1,-1],[1,4,1],[-1,1,3]]);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"KG -%'matrixG6#7%7%\"\"$\"\"\"!\"\"7%F+\"\"%F+7%F,F+F*" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "eigenvals(K); evalf(%);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6%\"\"%,&\"\"$\"\"\"*$-%%sqrtG6#F%\"\"\"F&,&F%F&F'!\" \"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6%$\"\"%\"\"!$\"+330KZ!\"*$\"+#>\\ zE\"F(" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "eigenvectors(K); " }}{PARA 11 "" 1 "" {XPPMATH 20 "6%7%,&\"\"$\"\"\"*$-%%sqrtG6#F%\"\" \"F&F&<#-%'vectorG6#7%F&,&F&F&F'F&F&7%,&F%F&F'!\"\"F&<#-F.6#7%F&,&F&F& F'F4F&7%\"\"%F&<#-F.6#7%F4\"\"!F&" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{MARK "35 0 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 }