Supplement for Lab 7: Matrix Manipulations restart: with(linalg): Let us illustrate how to work with matrices in Maple. First, suppose you want to define a rotation matrix in 3 dimensions. In particular, suppose you want to rotate every vector in the space about the z axis by some angle phi. You would type the following to define the transformation matrix: R := matrix([[cos(phi),-sin(phi),0],[sin(phi),cos(phi),0],[0,0,1]]); Suppose you are only interested in a specific case (instead of the general case), like rotating clockwise about the z-axis by 45?. You can evaluate the specific case where phi = Pi/2 using the substitution command: R45 := subs(phi=Pi/2,matrix(R)); simplify(R45); Next, let's introduce a couple of rotation matrices, first through angle phi1 and second through phi2. R1 := matrix([[cos(phi1),-sin(phi1),0],[sin(phi1),cos(phi1),0],[0,0,1]]); R2 := matrix([[cos(phi2),-sin(phi2),0],[sin(phi2),cos(phi2),0],[0,0,1]]); We claim that multiplying matrix R1 by R2 gives a 3 x 3 matrix representing a rotation through angle phi1 + phi2. Let's check it. The syntax to multiply matrices in the specific order R2 times R1 is the following Rnet := evalm(R2&*R1); Convinced? Check against the formulas for the sine and cosine of the sum of two angles. Good, it works! The idea is true in general that multiplying matrix operations results in a net operation describing the first operation followed by the second. Notice that the reverse could end up with a different result. For example, if you put your socks on before your shoes you clearly have a different result as compared to putting on your shoes first, then your socks. So, order of matrices can be important, and that's the reason for the ampersand star; it instructs Maple to keep the order as specified instead of turning it around. The next piece of needed syntax for us today is the notion of an inverse for a matrix. Suppose you want to find the inverse of matrix R. You would type Rinv:= evalm(1/R); simplify(%); To convince yourself that this is really the inverse, do the following: evalm(R &* Rinv); simplify(%); Good! To multiply a matrix by a vector, say the ihat vector, you would do the following: ihat := vector([1,0,0]); ihatprime := evalm(R &* ihat); You are now in position to do today's lab. Have fun!