Introduction to Matrices for Engineers C.T.J. Dodson, School of Mathematics, Manchester Universit 1 What is a Matrix? A matrix is a rectangular arra of elements, usuall numbers, e.g. 1 0-8 4 0-1 1 0 11 The above matrix is a 4 matrix, i.e. it has three columns and four rows. 1.1 Wh use Matrices? We use matrices in mathematics and engineering because often we need to deal with several variables at once eg the coordinates of a point in the plane are written x, or in space as x,, z and these are often written as column matrices in the form: x and x z It turns out that man operations that are needed to be performed on coordinates of points are linear operations and so can be organized in terms of rectangular arras of numbers, matrices. Then we find that matrices themselves can under certain conditions be added, subtracted and multiplied so that there arises a whole new set of algebraic rules for their manipulation. In general, an n m matrix A looks like: A a 11 a 1 a 1... a 1,m 1 a 1,m a 1 a a... a,m 1 a,m a 1 a a... a,m 1 a,m.................. a n 1,1 a n 1, a n 1,... a n 1,m 1 a n 1,m a n,1 a n, a n,... a n,m 1 a n,m Here, the entries are denoted a ij ; e.g. in Example 4.1.1 we have a 11 1, a, etc. Capital letters are usuall used for the matrix itself. 1. Dimension In the above matrix A, the numbers n and m are called the dimensions of A. Based on original lecture notes on matrices b Lewis Pirnie 1
Introduction to Matrices 1. Addition It is possible to add two matrices together, but onl if the have the same dimensions. In which case we simpl add the corresponding entries: 1 0-8 4 0-1 1 0 11 + 4 0 1 0-8 - 5 1-1 1-50 5 1-0 -1 9 1-1 1 6 If two matrices don t have the same size dimensions then the can t be added, or we sa the sum is not defined. 1.4 Example 1 0-1 0 - + 6 1 4 1 0 0 + 4 0-4 1 0 is undefined Multipling Matrices.1 Wh should we want to? We can motivate the process b looking at rotations of points in the plane. Consider the point P on the x-axis at x x, 0, so it has coordinates x 0 Now, let P be the point obtained b rotating P round the origin in an anticlockwise direction through angle θ, keeping the distance from the origin which is actuall the square root of the sum of squares of the coordinates constant. What are the coordinates of the point P? It is not difficult trigonometr to work out that these are: x cos θ x sin θ Next consider the point Q on the -axis with coordinates 0 and rotate this point round the origin in an anticlockwise direction through angle θ, keeping the distance from the origin constant. We find that the new coordinates are: sin θ cos θ Now the paoff, it is actuall a matrix that does the rotating here because the operation is linear on the coordinate components. We can express the rotation of an point with coordinates x, as the following matrix equation: cos θ sin θ sin θ cos θ x x cos θ sin θ x sin θ + cos θ Can ou guess what will be the matrix for rotation in a clockwise direction?
C.T.J. Dodson. Exercise on Trigonometr 1. Three common right angled triangles can be used to obtain the following values for the trigonometric functions: 0 π 6 45 π 4 60 π sin π 6 1 sin π 4 1 sin π cos π 6 cos π 4 1 cos π 1 tan π 6 1 tan π 4 1 tan π. Obtain the rotation matrices explicitl for rotations of θ ±0, ±45, ±60, ±90, ±180.. Rules When multipling matrices, keep the following in mind: la the first row of the first matrix on top of the first column of the second matrix; onl if the are both of the same size can ou proceed. The rule for multipling is: go across the first matrix, and down the second matrix, multipling the corresponding entries, and adding the products. This new number goes in the new matrix in position of the row of the first matrix, and the column of the second matrix. For example: 1 4 0 1 5 1. +.1 1.0 +.5 1. +.. + 4.1.0 + 4.5. + 4. 4 10 1 10 5 Smbolicall, if we have the matrices A and B as follows: A a 11 a 1 a 1... a 1,m a 1 a a... a,m a 1 a a... a,m............... a n 1,1 a n 1, a n 1,... a n 1,m a n,1 a n, a n,... a n,m, B b 11 b 1 b 1... b 1,q b 1 b b... b,q b 1 b b... b,q............... b p 1,1 b p 1, b p 1, b p 1,q 1 b p 1,q b p,1 b p, b p,... b p,q then the product AB is given b: m i1 a m 1ib i1 i1 a m 1ib i... i1 a m 1ib iq i1 a m ib i1 i1 a m ib i... i1 a ib iq............ m i1 a m nib i i1 a m nib i... i1 a nib iq where m i1 a 1ib i1 stands for a 11 b 11 + a 1 b 1 + a 1 b 1 +... + a 1n b n1, etc. Note that we must have m p, i.e. the number os columns in the first matrix must equal the number of rows of the second; otherwise, we sa the product is undefined.
4 Introduction to Matrices.4 Example We multipl the following matrices: -1 0 i 1 0-1 1.1 +.0 + 0. 1. +. 1 + 0.5 4 1-4.1 + 1.0 +. 4. + 1. 1 +.5 5 4 0 ii 1-8 -1 is undefined 1 4 1 iii 4. + 1. 1 4. + 1.4 1-1 4. + 1. 1. + 1.4 iv -1 1 0 0-1 1 0-1 1 4 1.0 + 1. 1. 1 + 1. 1. + 1.0 1.1 + 1. 1 0.0 +. 0. 1 +. 0. +.0 0.1 +. 1 1.0 + 4. 1. 1 + 4. 1. + 4.0 1.1 + 4. 1 1 6 8-1 -5-10 1 8 - - 6 14 0-1 - 1 0 1. + 0.5 v 1 5. + 1.5 11 4 0 1 6 1 0 vi 0-8 - 0-8 5 1-1 1.4 +.0 + 0.5 1.0 +. 8 + 0.1 1.1 +. + 0. 1.6 +.0 + 0.1.4 + 8.0 +.5.0 + 8. 8 +.1.1 + 8. +..6 + 8.0 +.1 4-4 -8 6-6 -0-10 We see from the examples: i Product of matrix with a matrix is a matrix. iii Product of matrix with a matrix is a matrix. iv Product of matrix with a 4 matrix is a 4 matrix. v Product of matrix with a 1 matrix is a 1 matrix. vi Product of matrix with a 4 matrix is a 4 matrix. Note that the two middle numbers must be the same if the product is defined; and then the dimensions of the answer is just the two outer numbers. Thus, the product of an n m matrix with a m q matrix is an n q matrix. Scalar Multiplication There is another tpe of multiplication involving matrices called scalar multiplication. This means just multipling each entr of the matrix b a number. For example: -1 0-6 0 4 1-1 -6.1 Rules There are some rules which matrix addition and multiplication obe: Associative A + B + C A + B + C Commutative A + B B + A
C.T.J. Dodson 5 Distributive Distributive Associative Non Commutative Moving Constants AB + C AB + AC A + BC AC + BC ABC ABC AB BA usuall AλB λab Assuming that the sums and products are defined in all cases.. Example Let A 1 0-1 4, B 1 -, C Consider the following: AB BA 1 0-1 4 1 - -1 4 1-1 0 1. 1 + 0.1 1.4 + 0.. 1 +.1.4 +. 1.1 + 4. 1.0 + 4. 1.1 +. 1.0 +. -1 4-1 8 11 8-5 -4 Now, AB BA, and we see that two matrices are not the same if the are multiplied the other wa around. Also consider: AC BC AB + BC A + B 1 0-1 4 1-1 0 A + BC 1 10 + -4-1 4 + 1-0 4 4 0 and we notice that A + BC AC + BC as required. 1 10-4 1 8 0 4 4 0 1 8 4 Transpose Another operation on matrices is the transpose. This just reverses the rows and columns, or equivalentl, reflects the matrix along the leading diagonal. The transpose of A is normall written A t thus a 11 a 1 a 1... a 1,m 1 a 1,m a 1 a a... a,m 1 a,m A a 1 a a... a,m 1 a,m.................., a n 1,1 a n 1, a n 1,... a n 1,m 1 a n 1,m a n,1 a n, a n,... a n,m 1 a n,m
6 Introduction to Matrices A t a 11 a 1 a 1... a m 1,1 a m,1 a 1 a a... a m 1, a m, a 1 a a... a m 1, a m,.................. a 1,n 1 a,n 1 a,n 1... a m 1,n 1 a m,n 1 a 1,n a,n a,n... a m 1,n a m,n Note that the transpose of a n m matrix is a m n matrix. 4.1 Example As an example of the transpose: A 4-1 0 5 0, A t 4-1 5 5 Square Matrices Given a number n, n n matrices have ver special properties. Note that if we have two n n matrices, the product is defined and will also be an n n matrix. 5.1 The Identit Matrix There also exists a special matrix, known as the identit, I n n : I 1 0 0 1, I 1 0 0 0 1 0 0 0 1, I 4 4 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1, etc. which has 1 s on the main diagonal, and 0 s everwhere else. This matrix has the propert that, given an n n matrix A: AI n n A and I n n A A i.e. multipling b the identit on either side doesn t change the matrix. This is similar to the propert of 1 when multipling numbers. We usuall abbreviate I n n to just I when it s obvious what n is. 5. Example Let A 1 1 0, I I 0 1 Now, we check the properties of the identit: as required. AI IA 1 1 0 0 1 1 0 0 1 1 1.1 +.0 1.0 +.1.1 +.0.0 +.1 1.1 + 0. 1. + 0. 0.1 + 1. 0. + 1. 1 1
C.T.J. Dodson 6 Determinants One of the most important properties of square matrices is the determinant. This is a number obtained from the entries. 6.1 Determinant of a Matrix a b Let A. Then, the determinant of A, denoted det A or A is given b ad bc. c d 6. Example det.5.1 10 1 5-1 det 1 6. 6 6 0-6 Before we go on to larger matrices, we need to define minors. 6. Minors Let A be the n n matrix A a 11 a 1 a 1... a 1,m 1 a 1,m a 1 a a... a,m 1 a,m a 1 a a... a,m 1 a,m.................. a n 1,1 a n 1, a n 1,... a n 1,m 1 a n 1,m a n,1 a n, a n,... a n,m 1 a n,m Then, the minor m ij, for each i, j, is the determinant of the n 1 n 1 matrix obtained b deleting the i th row and the j th column. For example, in the above notation: 6.4 Example m 11 det m 1 det We compute all the minors of A a a... a,m 1 a,m a a... a,m 1 a,m............... a n 1, a n 1,... a n 1,m 1 a n 1,m a n, a n,... a n,m 1 a n,m a 1 a 1... a 1,m 1 a 1,m a a... a,m 1 a,m............... a n 1, a n 1,... a n 1,m 1 a n 1,m a n, a n,... a n,m 1 a n,m 0 4 1-1 -5 0 - m 11 4 0-8 m 1 m 1 1-1 0 - m 0-5 - 15 m 1-1 -5-9 m 0 4-5 0 0 1-5 0 5
8 Introduction to Matrices m 1 1-1 4 m -1 0 6 m 1 0 4 8 6.5 Minors and Cofactors The numbers called cofactors are almost the same as minors, except some have a minus sign in accordance with the following pattern: + +... + +... + +... + +.................. The best wa to remember this is as an alternating or chessboard pattern. The cofactors from the previous example are: c 11 m 11 8 c 1 m 1 15 c 1 m 1 0 c 1 m 1 c m 9 c m 5 c 1 m 1 c m 6 c m 8 Determinant of a Matrix In order to calculate the determinant of a matrix, choose an row or column. Then, multipl each entr b its corresponding cofactor, and add the three products. This gives the determinant..1 Example Letting A 0 4 as before, we compute the determinant using the top row: 1-1 -5 0 - det A a 11 c 11 + a 1 c 1 + a 1 c 1. 8 + 1. 15 + 1.0 16 15 0 51 Suppose, we use the second column instead: det A a 1 c 1 + a c + a c 1. 15 + 4. 9 + 0. 6 15 6 0 51 It doesn t matter which row or column is used, but the top row is normal. Note that it is not necessar to work out all the minors or cofactors, just three.. Example Let B - 1 0. We compute the determinant of B: 1 0 4 1 det - 1 0 1 0 4 1 1 1 0 1 0-0 1 + 4-1 11 0 0 0 + 4 4 1 8
C.T.J. Dodson 9 8 Determinant of an n n Matrix The procedure for larger matrices is exactl the same as for a matrix: choose a row or column, multipl the entr b the corresponding cofactor, and add them up. But of course each minor is itself the determinant of an n 1 n 1 matrix, so for example, in a 4 4 determinant, it is first necessar to do four determinants quite a lot of work! 9 Inverses Let A be an n n matrix, and let I be the n n identit matrix. Sometimes, there exists a matrix A 1 called the inverse of A with the propert: A A 1 I A 1 A In this section, we demonstrate a method for finding inverses. 9.1 Inverse of a Matrix a b Let A. Then, the inverse of A, A c d 1 is given b: A 1 1 d b ad bc c a To check, we multipl: A 1 1 d b a b 1 da bc db bd A ad bc c a c d ad bc ca + ac cb + ad 1 ad bc 0 1 0 ad bc 0 ad bc 0 1 In a similar fashion we could show that A A 1 I. Of course, the inverse could also be written A 1 1 d b det A c a Note, that if det A 0, then we have a division b zero, which we can t do. In this situation there is no inverse of A. 9. Inverse of and higher Matrices Recall the definition of a minor from Section 4..: given an n n matrix A, the minor m ij is the determinant of the n 1 n 1 matrix obtained b omitting the i th row and the j th column. 9. Example Let A - 1 0. We calculate the minors: 1 0 4 1 m 11 1 1 1 m 1 m 1 1 1 11 m m 1 0 4 1 0 4 m 1 4-0 8 m 1 0-1 1
10 Introduction to Matrices Recall also the pattern of + and signs from which we obtain the cofactors: + + + + + Now, we put the minors into a matrix and change their signs according to the pattern to get the matrix of cofactors: 8 11 1 4 8 1 The next stage is take the transpose: 11 8 1 8 4 1 and finall we must divide b the determinant, which is, from Example 4..8: A 1 1 1 8 4 1 8 4 11 8 11 8 1 1 This shows how to calculate the inverse of a matrix. We check the result: A 1 A 1 1 8 4 1 0 4 1 16 1 0 + 8 8 4 + 0 4 11 8-1 0 + 4 0 11 16 8 + 0 8 1 1 + 4 + 0 + 8 + 0 + 1 as required. 1-0 0 0-0 0 0 - The same procedure works for n n matrices. 1 0 0 0 1 0 0 0 1 I II III IV Work out the minors. Put in the signs to form the cofactors. Take the transpose. Divide b the determinant. Furthermore, an n n matrix has an inverse if and onl if the determinant is not zero. So, it s a good idea to calculate the determinant first, just to check whether the rest of the procedure is necessar. 10 Linear Sstems We discuss one ver important application of finding inverses of matrices. 10.1 Simultaneous Equations Often, when solving problems in mathematics, we need to solve simultaneous equations, e.g. something like: x + 5x +
C.T.J. Dodson 11 from which we would obtain x and 1. The process we have used up until now is a little mess: we combine the equations to tr and eliminate one of the unknown variables. There is a more sstematic wa using matrices. We can write the equations in a slightl different wa: x + 5x + Now we can check that the first matrix is equal to the product: x + 1 x 5x + 5 and so altogether we have a matrix equation: 1 x 5 The next stage is to use the inverse of the matrix, so let s calculate that now. Let A 1 5, then A 1 1-1. 1.5-5 Now, we take the matrix equation above, and multipl b A 1 1 5 x -1-5. -1-5 Then, doing the multiplication: 1 0 0 1 1 5 x x. + 1. 5. +. -1-5 1 x 1 and so x and 1, as required. So, provided we can work out the inverse of the matrix of coefficients, we can solve simultaneous equations. 11 Larger Sstems The same thing works with equations in x, and z. Suppose we have x + + z 1 z x + 8z Then, the matrix form is 1 0 - -1 8 x z -1 Now, we denote the matrix b A, and calculate the inverse of A. The minors are as follows:
1 Introduction to Matrices m 11 - -1 8 m 1 0-8 4 m 1 0-1 6 m 1-1 8 18 m 1 8 4 m 1-1 5 m 1-10 m 1 0 - m 1 0 Recall the chessboard pattern: + + + + + So we have the following matrix of cofactors: 4 6 18 4 5 10 We can calculate the determinant b taking an row or column, and multipling the original matrix entr b its corresponding cofactor, and then adding let s choose the top row: det A 1. +. 4 +. 6 8 1 and so the determinant is, and so we will be able to find the inverse. From the matrix of cofactors, we take the transpose, and then divide b the determinant to get A 1 : A 1 1 18 10 11 9 5 4 4 1 6 5 5 Now, we return to solving the simultaneous equations, where we had: 1 x -1 0 - -1 8 z Multipling both sides on the left b A 1, we have: 11 9 5 1 x 1 0 - -1 8 z 5 11 9 5 1 5-1 and we know that A 1 A I, so 1 0 0 0 1 0 0 0 1 x z x z 11. 1 + 9. + 5.. 1 +. + 1.. 1 + 5. +. 64 1 and so we get x 64, 1 and z. It s a ver good idea to check calculations like this! x + + z 64 + 1 + 64 + 6 + 1 z 1 9 x + 8z 64 1 + 8 18 1 + 148 as required.
C.T.J. Dodson 1 1 Appendix 1.1 Scientific Wordprocessing with L A TEX This pdf document with its hperlinks was created using L A TEX which is the standard free mathematical wordprocessing package; more information can be found via the webpage: http://www.ma.umist.ac.uk/kd/latextut/pdfbex.htm 1. Computer Algebra Methods The computer algebra package Mathematica can be used to manipulate and invert matrices. See: http://www.ma.umist.ac.uk/kd/mmaprogs/areadmefile for beginning Mathematica. Similarl, Maple and Matlab also can be used for working with matrices.