Study Advice Service Mathematics Worksheet Matrices This is one of a series of worksheets designed to help you increase your confidence in handling Mathematics. This worksheet contains both theory and exercises which cover:1. Introduction 3. Equality 5. Identity and Inverse 2. Order, Addition and subtraction 4. Multiplication 6. Echelon Method There are often different ways of doing things in Mathematics and the methods suggested in the worksheets may not be the ones you were taught. If you are successful and happy with the methods you use it may not be necessary for you to change them. If you have problems or need help in any part of the work then there are a number of ways you can get help. For students at the University of Hull Ask your lecturers Contact the Study Advice Service in the Brynmor Jones Library where you can access the Mathematics Tutor, or contact us by email. Students on the Scarborough campus can book appointments via the Keith Donaldson library. Come to a Drop-In session organised for your department Look at one of the many textbooks in the library. For others Ask your lecturers Access your Study Advice or Maths Help Service Use any other facilities that may be available. If you do find anything you may think is incorrect (in the text or answers) or want further help please contact us by email. Tel: 01482 466199 Web: www.hull.ac.uk/studyadvice Email: studyadvice@hull.ac.uk 1. Matrices – introduction A matrix is an array of numbers each element of which gives a single piece of information. Consider the following % marks gained by students in, say, the first half of semester 1: module module module 1 2 3 Andy 40 58 83 Mary 32 43 73 Bill 56 65 66 Nancy 21 45 34 40 32 M1 = 56 21 This can be written as 58 83 43 73 65 66 45 34 The marks for the second half: Andy Mary Bill Nancy module 1 34 56 23 78 module 2 40 45 57 43 module 3 67 56 70 67 34 40 67 56 45 56 M2 = 23 57 70 78 43 67 Adding the results together, using the matrices, gives can be represented in matrix form as 40 32 M1 + M2 = 56 21 58 83 34 43 73 56 + 65 66 23 45 34 78 40 67 74 45 56 88 = 57 70 79 43 67 99 98 150 88 129 122 136 88 101 This is an example of matrix addition. Often results of this kind are held on a spreadsheet and the addition is very simple. To add two matrices you add the corresponding elements i.e. add the element in row m column n in the first matrix to the element in row m column n in the second. The total above gives marks out of 200. To convert back to percentages we need to divide all the values by 2. (i.e. multiply each element by 0.5). So to multiply a matrix by k you multiply all the elements by k . 74 1 88 Final mark = 2 79 99 98 150 37 88 129 44 122 136 39.5 88 101 49.5 49 75 44 64.5 61 68 44 50.5 (Every element has been halved) page 1 The final figures would probably be rounded to the nearest whole number. It may be decided that the marks should be weighted, so that the marks in semester 2 count for 60% and those in semester 1 count for 40%. This can be done by calculating 0.4M1 0.6M2 giving the total % (to nearest whole number): 40 32 0.4 56 21 58 83 34 43 73 56 0 . 6 23 65 66 78 45 34 40 67 36 45 56 46 57 70 36 43 67 55 47 73 44 63 60 68 44 54 (This can be done quite easily on a Spreadsheet.) 2. Order, addition and subtraction The matrices above have the same order or size. Each has 4 rows and 3 columns and are described as 4 by 3 (or 4 3 ) matrices. As each element refers to the mark for a particular person and module it can be seen that matrices can only be added or subtracted if they have the same order (and refer to the same thing). Examples 3 3 0 2 2 3 B C D 2 Given A 1 4 3 5 2 0 find, where possible, (i) A + B, (ii) A + C, (iii) B + D, (iv) C - A, (v) 3D (i) (ii) (iii) (iv) (v) 3 0 2 can’t be done (different order) A B 1 4 3 3 0 2 3 5 3 A C 1 4 5 2 4 6 B + D can’t be done (different order) 2 3 3 0 1 3 C A 5 2 1 4 6 2 3 9 3D 3 2 6 0 0 3. Equality of matrices Two matrices can only be equal if all the elements in the first matrix are the same as the corresponding elements in the second. This can be seen from the definition. Example 2 3 3 0 z 3 find the values of x , y and z . Given 5 y x 4 6 2 1 3 z 3 Subtracting the matrices gives 5 x y 4 6 2 page 2 Equating corresponding elements gives: 1 z, 5 x 6 x 1, y 4 2 y 2 (Note that the 4th element is –3 in both matrices. If it hadn’t been then the matrices could not have been equal) Exercise 1 2 2 3 B 1. A 2 2 3 4 1 5 E 3 2 F 2 4 5 1 1 3 C 1 4 2 1 4 G 0 2 5 Evaluate, where possible, (i) C + D (iv) D - F (v) A + B + C (vi) E + 2F 2 1 5 4 1 D 0 1 2 3 4 2 3 1 2 1 3 (ii) F + 2E (iii) A - 2B (vii) 2D + 3C (viii) 3G 1 2 4 5 1 2 B C 2. A 1 3 2 1 4 1 Verify that A + (B + C) = (A + B) + C = (C + A) + B 3. Find the matrices A, B and C in the following 3 2 5 8 2 1 5 4 ii 2 B i 2 A 4 5 2 5 1 3 1 2 iii 0 9 1 2 3 2C C 3 2 5 0 4 6 4 4. Multiplication of matrices Returning to the example of marks it may be decided that the marks in the different modules should not all carry that same weight. For instance marks for modules 1, 2, 3 might be weighted 3, 2, 3. We can represent Andy’s marks and the weightings by the following matrices (40 58 83) and (3 2 3) and the total mark would be 40 × 3 + 58 × 2 + 83 × 3 = 485 (out of 800) In matrix multiplication this would be written as: 3 40 58 83 2 40 3 58 2 83 3 485 3 page 3 For Mary the total would be given by 3 32 43 73 2 32 3 43 2 73 3 401 3 The two sets of results can be combined as 3 40 58 83 40 3 58 2 83 3 485 2 32 43 73 3 32 3 43 2 73 3 401 and the whole group (of four students) as 40 32 56 21 58 83 40 3 58 2 83 3 485 3 43 73 32 3 43 2 73 3 401 or, in percentages 2 65 66 56 3 65 2 66 3 496 3 45 34 21 3 45 2 34 3 255 61 50 62 % 32 Someone suggested that the weighting should be (2 3 2); 420 339 Show that this gives (out of 700) 439 245 This sort of calculation can be easily done using a computer. The multiplications can be put together and converted to percentages to compare the marks (note the first column of the product is out of 800, the second is out of 700): 40 32 56 21 58 83 485 420 3 2 401 339 43 73 or in percentages 2 3 65 66 496 439 3 2 255 245 45 34 61 50 62 32 60 48 % 63 35 Examples 3 3 0 2 2 3 B C D 2 Given A 1 4 3 5 2 0 Evaluate, where possible (i) AB (ii) AC (iii) CA (iv) DA 3 0 2 3 2 0 (3) 6 (i) AB 1 4 3 (1) 2 4 (3) 14 3 (3) 0 2 6 9 3 0 2 3 3 2 0 5 (ii) AC 1 4 5 2 (1) 2 4 5 (1) (3) 4 2 18 11 page 4 2 3 3 0 2 3 (3) (1) 2 0 (3) 4 9 12 (iii) CA 5 0 2 4 13 8 5 2 1 4 5 3 2 (1) 3 0 3 (iv) DA 2 impossible 4 0 1 Given two matrices S and T, then the product ST exists only if the number of columns in S is the same as the number of rows in T. We notice from above A is a ( 2 2 ) matrix and B is a ( 2 1) matrix and the product AB is a ( 2 1) matrix. Matrix BA does not exist. Also if M is 3 2 and N is 2 5 then MN is 3 5 and NM does not exist. In general if S is a p q matrix and T is a q r matrix then ST exists and will be a p r matrix. Matrix S Matrix T Matrix ST p × q q × r p × r Also, given matrices S and T, where ST exists, then the element in, say, the 3rd row and 2nd column of ST comes from multiplying the 3rd row of S with the 2nd column of T. Exercise 2 Find the following products where they exist 1 0 3 1. 1 2 2. 1 2 3. 3 2 2 2 4 2 4. 1 2 2 0 5 3 1 0 2 1 3 7. 0 3 1 4 1 2 3 2 3 1 3 5. 1 2 4 3 8. 2 2 0 4 2 0 4 1 3 3 2 0 4 1 0 2 1 3 0 3 6. 1 4 2 2 3 3 5 9. Given the following matrices 4 1 2 1 3 1 3 2 1 5 4 1 B C D 3 2 E A 2 2 1 3 4 0 1 2 3 4 4 5 2 3 5 1 2 F 2 4 G 0 1 2 H 5 1 5 2 1 3 Find, where possible (i) AB (ii) BA (iii) BC (iv) FB (v) BF (vii) GB (viii) GD (ix) EH (x) CF (xi) DE (vi) EG 1 2 5 2 1 0 B C 10. Given A 2 5 2 1 0 1 find (i) AB (ii) BA (iii) AC (iv) CB (v) BC page 5 5. Identity and Inverse 2 × 2 matrices The matrix I such that MI M IM is called the identity matrix, see question 10 (iv) and (v) above. For MI and IM to be equal then both M and I must be square matrices. 1 0 because Under multiplication, the 2 2 identity matrix is 0 1 a b 1 0 a b 1 0 a b a b and c d 0 1 c d 0 1 c d c d Matrices such as A and B in question 10 above are called inverse matrices. 1 2 5 2 1 0 5 2 1 2 1 0 and BA AB 2 5 2 1 0 1 2 1 2 5 0 1 so as AB BA I so A B1 and B A1 a) Finding inverse 2 × 2 matrices: 3 1 a b Let M 1 Given M 1 1 c d 3 1 a b 1 0 Then M × M -1 = 1 1 c d 0 1 hence 3a c 3b d 1 0 a c b d 0 1 If two matrices are equal then corresponding elements are equal hence 3a c 1 3b d 0 ac 0 bd 1 solving gives a 14 , b 14 , c 14 , d hence M 1 1 14 4 3 4 14 1 1 1 3 4 1 3 4 3 5 N 6 2 2 3 Then it can be shown that N 1 1 8 6 5 Similarly if page 6 1 1 3 1 Compare M = with M 1 1 4 1 3 1 1 3 5 2 3 with N 1 1 and N = 8 5 6 2 6 You should notice that the numbers in the leading diagonal appear to have been swapped over and the elements in the other diagonal have changed sign. But what about the fraction? The 4 and 8 above are called the determinant of the matrix, possibly because it determines if the matrix has an inverse or not. If the determinant of matrix A is zero then, A1 does not exist (see below). 3 1 and [3 × 1] - [1 × (-1)] = 4 In the first example we have M 1 1 3 5 and [5 × (-2)] - [3 × (-6)] = 8 In the second example N 6 2 a b In general, if P the determinant of P, c d written as |P| or det P giving P 1 a b c d is ad bc d c ad bc b a 1 Check by multiplication that that P P1 I Note that the inverse only exists if ad bc 0 Exercise 3 Find the inverses of the following matrices where they exist. 2 3 3 1 3 2 B C A 1 2 2 1 2 0 2 5 5 4 E D 6 15 2 3 page 7 b) Using inverse matrices to solve equations Matrices can be used to solve simultaneous equations. ax by c a b x c x c or M can be written as dx ey f d e y f y f Multiplying both sides by the inverse matrix ( M 1 ) gives x c M 1M M 1 y f x c x c I M 1 M 1 y f y f The example here is of solving 2 equations in 2 unknowns using 2 2 matrices but the method extends to n equations in n unknowns, as long as you can find the inverse matrix. Example Solve the equations 3x 2 y 2, x 4 y 9 3 2 x 2 Method 1 In matrix form 1 4 y 9 3 2 4 2 1 4 2 1 is The inverse of 1 4 3 4 2 1 1 3 10 1 3 Multiply both sides by the inverse 1 4 2 3 2 x 1 4 2 2 10 1 3 1 4 y 10 1 3 9 1 0 x 1 4 2 2 9 0 1 y 10 1 2 3 9 x 1 10 1 y 10 25 2.5 x 1, y 2.5 These values can, of course be checked by substitution into the equations. page 8 Method 2 Using the echelon method – a more general method used by computers to solve sets of, say, 100 equations in 100 unknowns! Write the equation if the echelon form The technique is to change the 2 2 matrix into the identity matrix Divide the top row by 3 to make the term in row 1, column 1 = 1 Subtract row 1 from row 2 to make the term in row 2, column 1 = 0 Divide row 2 by 10 (ie multiply by 3 ) to make the term in row 2, 3 10 column 2 = 1 Subtract 2 row 2 from row 1 to make the term in 3 row 1, column 2 = 0 3 2 2 1 4 9 1 1 1 0 1 0 2 3 2 3 4 9 2 3 10 3 2 3 1 2 3 25 3 2 3 5 2 1 0 1 0 1 5 2 And the solution at the end is, as before, x 1 , y 2.5 Exercise 4 Solve the following pairs of simultaneous equations by both methods. 1. x y 3 2. 2 x 4 y 9 3. 2 x 4 y 9 2x 3y 4 4x y 2 7x y 1 6. Identity and Inverse 3 3 matrices 1 0 0 The 3 3 identity matrix is 0 1 0 0 0 1 Finding the inverse of a a11 Given M a21 a 31 3 3 a12 a22 a32 matrix is not as easy as for a 2 2 matrix. a13 a23 a33 The determinant of M , written as M is defined as a11 a12 a21 a22 a31 a32 a13 a a23 a11 22 a32 a33 a23 a a a a a12 21 23 a13 21 22 a33 a31 a33 a31 a33 We also define co-factors. The co-factor Amn is the determinant of the matrix left when row m and column n are deleted from the square matrix M and with the appropriate sign. The sign is ( 1)m n . Note that the signs alternate along rows and columns as shown. page 9 This gives a A11 22 a32 a23 a33 a A21 12 a32 a13 a A31 12 a 22 a33 a11 a12 It can be proved that if M a21 a22 a 31 a32 a13 a 23 a a A23 11 12 etc. a31 a32 a13 A11 1 1 a23 then M A12 M a33 A13 A21 A22 A23 A31 A32 A33 where Amn is the co-factor of amn Note 1. If the determinant of M 0 then the inverse does not exist 2. The first row of M is a11 a12 a13 - first column of M 1 is A11 A12 A13 ; the rows and columns are transposed. 1 4 1 Example: Find the inverse of M 0 2 3 1 3 2 The cofactors are 2 3 A11 5, 3 2 A21 A31 4 1 3 2 4 1 2 3 A12 11, 14, A22 0 3 1 2 1 1 1 A32 2 A13 3, A23 1 1 0 3 0 2 3, 3, A33 1 3 2 1 4 1 3 1 4 0 2 1 2 1 4 1 M 0 2 3 14 9 40 3 10 2 9 1 3 2 Hence M -1 = M 1 5 11 14 1 3 3 3 9 2 2 1 page 10 Check MM 1 1 4 1 5 11 14 1 0 2 3 3 3 3 1 3 2 9 2 1 2 5 12 2 11 12 1 14 12 2 1 066 063 066 9 5 9 4 11 9 2 14 9 4 9 0 0 1 0 0 1 0 9 0 0 1 0 I 9 0 0 9 0 0 1 6b. Inverse of a 3 × 3 matrix using the echelon method In the echelon method, you start with a matrix M and a unit matrix and, by simple arithmetic, change M into the unit matrix and the unit matrix into the inverse. Using r1, r2 , r3, c1, c2 , c3 to describe rows and columns, the technique is to start with the element in r1, c1 and make it 1 (by division) and then use this term to make the other elements in c1 0 (by adding or subtracting). Move to the element in r2 , c2 and make that 1(by division) and then use this term to make the other elements in c2 0 (by adding or subtracting). Go on to the element in r3, c3 and repeat the process. It sounds much more complex than it really is! 2 1 2 1 0 0 Let M 0 2 1 and we have I 0 1 0 1 3 2 0 0 1 write M and the Identity matrix as 2 1 2 0 2 1 1 3 2 Divide r1 by 2 to make the term in r1, c1 1 (sometimes called the 1st pivot element) 1 0 1 1 0 0 1 0 0 Subtract r1 from r3 to make the term in r3, c1 0 Term in r2 , c1 is already 0 Divide r2 by 2 to make the element in r2 , c2 1 (the 2nd pivot element) 1 1 2 3 1 2 1 1 2 31 1 1 1 1 1 1 31 2 1 2 2 2 2 2 1 0 0 0 1 0 0 0 1 1 0 0 2 0 1 0 0 0 1 0 0 0 1 0 1 0 1 2 1 0 0 2 0 1 0 2 1 0 1 2 1 2 page 11 Add 1 2 r2 to r1 to make the term in r1, c2 0 and take 3 12 r2 from r3 to make term in r3, c2 0 Divide r3 by 2 3 (i.e. multiply by 4 ) to make the 4 11 term in r3, c3 1 (the 3rd pivot element) Subtract 3 4 r3 from r1 to make the term in r1, c3 0 and add 1 2 r3 to r2 to make the term in r2 , c3 0 7 11 Inverse matrix 1 11 2 11 8 11 2 11 7 11 1 0 0 1 0 0 3 4 1 2 3 2 4 0 1 0 3 4 1 2 0 1 0 1 1 0 0 0 1 0 0 0 1 1 2 0 1 2 1 2 0 2 11 7 11 1 11 2 11 1 4 1 2 7 4 1 4 1 2 7 11 8 11 2 11 7 11 0 0 1 0 0 4 11 3 11 2 11 4 11 3 8 3 7 11 2 1 1 2 2 11 11 2 7 4 4 11 Exercise 5 Find the inverses of the following 5 10 8 2 1 0 1 2 1 1 3 2 A 4 7 6 B 0 1 1 C 3 2 1 D 0 2 1 3 6 0 4 3 1 1 5 0 2 2 1 6c. Solving equations using the echelon method From the equations 2 x1 2 x2 4 x3 4 3x1 5 x2 3x3 4 4 x1 we can write Reduce to echelon form divide r1 by 2 to make the term in r1, c1 1 take 3r1 from r2 to make the term in r2 , c1 0 2 3 4 2 5 0 2 2 3 5 4 0 1 1 3 5 4 0 1 1 0 8 4 0 3x3 10 4 x1 4 3 x2 4 3 x3 10 4 3 3 2 3 3 2 9 3 4 4 10 2 4 10 2 10 10 page 12 take 4r1 from r3 to make the term in r3, c1 0 Divide r2 by 8 to make the term in r2 , c2 1 Take 4r2 from r3 to make the term in r3, c2 0 Add r2 to r1 to make the term in r1, c2 0 Divide r3 by 13 to make the term in r3, c3 1 2 Add Take 9 8 r3 to r2 to make the term in r2 , c3 0 7 r 8 3 from r1 to make term r1, c3 0 This gives the solution (this can be checked by substituting into the original equations) 1 1 0 8 0 4 1 1 0 1 0 4 2 10 18 2 9 11 2 5 4 18 2 9 8 11 1 1 2 0 1 9 8 0 0 13 2 7 1 0 8 0 1 9 8 0 0 13 2 7 1 0 8 0 1 9 8 1 0 0 1 0 7 8 0 1 0 0 0 1 1 0 0 1 0 0 0 0 1 2 5 4 13 13 3 4 5 4 2 3 4 1 2 3 4 5 4 1 1 2 x1 1 x2 1 x 2 3 Exercise 6 Using the echelon method solve the following simultaneous equations 3a 2b 3c 10 4 x 6 y 8 z 1 2 x1 x2 x3 3 1. a 4b 2c 1 2. 3 x 3 y 4 z 1 3. 2 x1 x2 2 x3 4 5a 6b 4c 11 8x 4 y 1 2 x 3x 3x 7 2 3 1 page 13 Answers Exercise 1 8 6 2 (ii ) 1. (i ) 6 3 5 13 4 8 0 (iii ) 7 5 4 0 (iv ) not possible (v ) not possible 8 4 14 5 19 14 5 (viii ) (vi) 7 6 (vii) 16 6 11 2 5 3 1 3 3. (i ) A (ii ) B 2 0 1 5 5 2 1 2 9 3 6 0 3 6 6 3 9 2 1 2.They all equal 7 1 1 1 1 (iii ) C 1 2 3 Exercise 2 1. 5 15 4. Not possible 5. Not possible 3. 6 1 3 2 6 0 9 15 7. 3 12 3 8. 4 0 6 10 7 14 9 8 0 12 20 2. 4 1 4 6 6. 3 6 7 5 9. (i ) 8 8 8 5 (ii ) 8 7 (v ) Not possible 3 15 4 (vi) 10 3 12 (ix ) Not possible 12 3 ( x ) 19 3 1 0 10. (i ) & (ii ) 0 1 1 2 (iii ) 2 5 1 13 (iv ) 2 10 2 14 10 20 (vii) Not possible (viii ) 11 8 23 15 5 6 4 (iii ) 9 2 4 22 19 0 ( xi) 11 6 11 30 31 16 5 2 (iv ) & (v ) 2 1 Exercise 3 2 3 1 1 1 1 1 0 2 1 3 4 B C D impossible E 1 1 A1 4 2 7 2 3 5 1 2 2 3 Exercise 4 1. x 1, y 2 Exercise 5 1 2 1 A 2 1 4 0 4 2 5 32 2. x 17 , y 18 18 B 1 7 0 14 0 1 61 3. x 13 , y 30 30 3 1 6 2 8 2 C 1 4 1 8 4 0 7 3 2 2 2 4 D 1 0 2 1 1 2 1 1 1 1 page 14 Exercise 6 1. a 1, b 1, c 3 2. x 12 , y 43 , z 167 3. x1 2, x2 6, x3 7 We would appreciate your comments on this worksheet, especially if you’ve found any errors, so that we can improve it for future use. Please contact the Maths tutor by email at studyadvice@hull.ac.uk Updated 2nd December 2004 The information in this leaflet can be made available in an alternative format on request. Telephone 01482 466199 © 2009 page 15