FACULTY OF MATHEMATICAL STUDIES MATHEMATICS FOR PART I ENGINEERING Lectures MODULE 16
MATRICES I
1. Notation and basic definitions 2. Matrix multiplication 3. Determinants
1. Notation and basic definitions Matrices are an extremely important tool in solving large systems of simultaneous linear equations, and the latter arise in the solution of many engineering problems. Matrices also form the basis of many computer graphical packages, and occur in a variety of other situations. A rectangular array of elements is called a matrix. The elements can be numbers (real or complex) or letters: 2 3 1 d e e.g , . −1 0 4 f g A matrix A with m rows and n columns has order m × n , said “ m by n ”. The element in the ith row and jth column of A is written aij . We denote a matrix by A or (aij ) (or sometimes as [aij ] ). When m = n then we obtain a square matrix, since the number of rows equals the number of columns. b1 b2 . A m × 1 matrix B = is also called a column vector, whilst a 1 × n matrix C = . . bm ( c1 c2 . . . cn ) is called a row vector. Before defining the operations of addition and subtraction for matrices it is necessary to define equality. Equality Two matrices A and B are equal if and only if (i) they have the same order, and (ii) corresponding elements in both matrices are equal (i.e. aij = bij for all i and j ). Addition and subtraction To add (or subtract) two matrices A and B of the same order then add (or subtract) corresponding elements in the matrices: i.e. Properties (i) (ii)
given A = (aij ),
B = (bij ),
then A ± B = (aij ± bij ) .
It is easy to see from the above definition that
A + B = B + A, (A + B) + C = A + (B + C).
These properties show that matrices can be added in any order.
1
Multiplication by a scalar
If A = (aij ) and λ is a scalar then λA = (λaij ).
The above definition means that the matrix 3A , for instance, is found by multiplying ALL elements in A by 3. Let us now give an example which illustrates the above definitions.
0 −1 2 0 −1 2 Ex 1. If A = , B = , −3 4 5 −3 6 5 B − 2A for each combination that exists.
C =
0 3
1 4
, find A + B, A + C and
It is obvious from the sizes of the matrices that A is 2 × 3 , B is 2 × 3 and C is 2 × 2 , so A + B exists and 0 −2 4 0+0 −1 + (−1) 2 + 2 , = A+B= −6 10 10 −3 + (−3) 4+6 5+5 A + C does NOT exist, B−2A exists and 0 − 2(0) −1 − 2(−1) 2 − 2(2) B−2A = −3 − 2(−3) 6 − 2(4) 5 − 2(5) 0 − 0 −1 + 2 2 − 4 0 1 −2 B−2A = = −3 + 6 6 − 8 5 − 10 3 −2 −5
→
Def.
A zero matrix has all elements zero. Denote such a matrix by 0 .
Note that a zero matrix can have any order. Def.
From any matrix A we define its transpose, AT , by (AT )ij = (A)ji .
The above states that the ijth element of AT = jith element of A or, more simply, the rows in the matrix A become columns in AT . For example,
if
0 1 A = 2 3 4 5
then
AT =
0 2 1 3
4 5
.
From the definition of the transpose it is easy to see that (i) if A has order m × n then AT has order n × m , (ii) (A + B)T =AT +BT , (iii) (AT )T =A. There are three other important types of matrix which must be defined. Def. A unit matrix is a square matrix with unit elements along the principal diagonal (the one that goes from top left to bottom right) and zero elsewhere. Examples of such matrices are
1 0 0 1
1 0 0
,
0 0 1 0. 0 1
All unit matrices are usually written I , without a subscript, since the order is normally obvious. Def.
A is symmetric if AT =A (a necessary condition for this is that A must be square).
Def. A is skew-symmetric (or in some books anti-symmetric) if AT =−A (again A must be square). 2
To illustrate these types of matrix
1 4 4 2 5 6
5 6 3
0 1 −1 0 −2 3
is symmetric,
2 −3 0
is skew-symmetric.
Hence a matrix is symmetric if it remains the same after reflection in the principal diagonal. A skewsymmetric matrix must have zeros along the principal diagonal and have additional minus signs when reflected about this diagonal. 2. Matrix multiplication The simple basic matrix operations have been defined in the previous section. In this section we consider the very important, but less straightforward, definition for multiplying matrices. Def. then
Given A is m × n and B is p × q then the matrix product AB exists if and only if n = p , and (AB)ij = ai1 b1j + ai2 b2j + ... + ain bnj ,
and the final product matrix has order m × q . The above states, in words, that the element in the ith row and jth column in the product AB is found from the ith row of A and jth column of B by adding together the products of the corresponding elements in this row and column. The restriction that n = p means that the number of elements in the row equals the number of elements in the column. Another way of interpreting the product is to note that, in vector terminology, it is the scalar product of the ith row and jth column. Since the number of elements in a row equals the number of columns in the matrix, and similarly the number of elements in a column equals the number of rows in the matrix, we can say that the product AB exists only when “the number of columns in A equals the number of rows in B ”. 0 1 0 −1 2 calculate whichever of AC or CA that exists. and C= Ex 2. If A = 3 4 −3 4 5 Since A is 2 × 3 and C is 2 × 2 then AC which is (2 × 3) × (2 × 2) DOES NOT exist, CA which is (2 × 2) × (2 × 3) DOES exist and will have order 2 × 3 ,
CA =
0 1 3 4
0 −1 2 −3 4 5
0(0) + 1(−3) 0(−1) + 1(4) 0(2) + 1(5) 3(0) + 4(−3) 3(−1) + 4(4) 3(2) + 4(5) 0−3 0+4 0+5 −3 4 5 = = 0 − 12 −3 + 16 6 + 20 −12 13 26
=
Note that the order is 2 × 3 as expected. Properties The above definition of matrix multiplication leads to the following properties (i) A(B + C) = AB + AC, (ii) (A + B)C = AC + BC, (iii) (AB)C = A(BC), (iv) AB 6= BA, in general, (this is very important and means that retaining the order of the matrices during multiplication is crucial), (v) AI = IA = A, (vi) (AB)T = BT AT (this result can be generalised to a string of matrices, for instance, (ABC)T = CT BT AT etc.). 3
Ex 3.
If A =
1 1 2 2
and B =
−1 1 1 −1
determine AB and BA .
Both A and B are 2 × 2 and so the two products exist: 1 1 −1 1 1(−1) + 1(1) 1(1) + 1(−1) AB = = 2 2 1 −1 2(−1) + 2(1) 2(1) + 2(−1) 0 0 −1 + 1 1 − 1 , = = 0 0 −2 + 2 2 − 2 BA = =
−1 1 1 −1
−1(1) + 1(2) −1(1) + 1(2) 1 1 = 1(1) + (−1)2 1(1) + (−1)2 2 2 −1 + 2 1 1 = . 1−2 −1 −1
−1 + 2 1−2
The above example illustrates that AB 6= BA , in general, even when both products exist. Ex 3. also shows that AB = 0 does NOT imply that A = 0 or B = 0 since in the example both A and B are non-zero. It is also important to note that matrices cannot be cancelled in the same way as numbers. Suppose that AC = BC but we know that C 6= 0 . The equation can be rearranged as AC − BC = (A − B)C = 0, but we have seen above that this does NOT usually imply that A − B = 0 , i.e. A = B . Thus we cannot, in general, cancel the matrix C from both sides of the original equation AC = BC , as one might have hoped. Let us consider another example. Ex 4.
If A =
1 0 2 1
−1 2
−1 0 and B = 1 1 2 2
evaluate AB and BA .
Here the matrices A and B have orders 2 × 3 and 3 × 2 respectively, and so both products exist. −1 0 −3 −2 −1 + 0 − 2 0 + 0 − 2 1 0 −1 = 1 1 = AB = 3 5 −2 + 1 + 4 0 + 1 + 4 2 1 2 2 2
−1 0 1 0 BA = 1 1 2 1 2 2
−1 2
−1 + 0 = 1+2 2+4
0+0 1+0 −1 0 0 + 1 −1 + 2 = 3 1 0 + 2 −2 + 4 6 2
1 1. 2
In the above example the two products exist but because the original matrices were not square then the two answers are matrices of different order, and obviously different. 3. Determinants A determinant is a single quantity that is defined only for a square matrix. Before giving the general definition let us consider the answers for small matrices: 1 × 1 matrix A,
Def.
|A| = |a11 | = a11 .
Note that the notation used for a determinant is usually a pair of vertical straight lines, although it is sometimes written det A . 4
Let us now give definitions for larger matrices: 2 × 2 matrix A,
Def.
a12 = a11 a22 − a12 a21 . a22
a |A| = 11 a21
determinant of a 3 × 3 matrix A is given below: a13 a22 a23 a21 a23 a − a12 + a13 21 a23 = a11 a a a a a31 32 33 31 33 a33
The usual formula for finding the a11 a12 |A| = a21 a22 a31 a32
a22 a32
= a11 (a22 a33 − a23 a32 ) − a12 (a21 a33 − a23 a31 ) + a13 (a21 a32 − a22 a31 ). The calculations can be expressed in a more general, and sometimes more useful, form but first we need to introduce some further definitions. Def. The minor associated with the element aij of the matrix A is the determinant of the matrix formed from A by deleting the ith row and jth column. Denote this minor by Mij . Def. The cofactor, Aij , associated with the element aij of the matrix A is found from the corresponding minor through the formula Aij = (−1)i+j Mij (i.e. the value of the cofactor is the same as the minor except possibly for a change in sign). 2 4 find 3
Ex 5. (i)
1 1 Given that A = 2 3 5 1
(iii) A32 .
2 3 = 2(1) − 3(5) = 2 − 15 = −13 = 5 1
This time remove the second row and second column 2+2
A22 = (−1) (iii)
(ii) A22 ,
M13 is obtained by first removing from A the first row and third column. Hence, M13
(ii)
(i) M13 ,
M22
2 = 1 {1(3) − 2(5)} = 3 − 10 = −7 3
1 = (−1) 5 4
Removing the third row and second column 3+2
A32 = (−1)
M32
1 = (−1) 2 5
2 = −1 {1(4) − 2(2)} = −1(4 − 4) = 0. 4
In general, it is possible to calculate the determinant of a matrix using any row or column. Having chosen a row (or column) the determinant is found by adding together the products of each element in the row (or column) and the cofactor corresponding to that element. In other words, in vector notation, the determinant is the scalar product of each row (or column) and the same row (or column) of the corresponding cofactors. For example, expanding by the first row of a matrix A gives, in the above notation, |A| = a11 A11 + a12 A12 + . . . + a1n A1n . The corresponding expression, expanding by the third column, can be written |A| = a13 A13 + a23 A23 + . . . + an3 An3 It is easily shown that these general definitions reproduce the earlier definitions for the determinants of the small matrices when you expand by the first row. 5
Ex 6. (i)
Hence, (ii)
Hence,
1 Evaluate 2 5
1 2 3 4 by expanding using (i) the first row, 1 3
(ii) the second column.
First work out the relevant cofactors 1+1 3 4 A11 = (−1) 1 3 = 1 {3(3) − 1(4)} = 9 − 4 = 5 1+2 2 4 A12 = (−1) 5 3 = −1 {2(3) − 5(4)} = −1(6 − 20) = −1(−14) = 14 2 3 = 1 {2(1) − 5(3)} = 2 − 15 = −13 A13 = (−1)1+3 5 1 |A| = 1(5) + 1(14) + 2(−13) = 5 + 14 − 26 = −7 The cofactors required here are A12 (found in (i)), A22 and A32 . 2+2 1 2 A22 = (−1) 5 3 = 1(1(3) − 5(2)) = 3 − 10 = −7 1 2 = −1(1(4) − 2(2)) = −1(4 − 4) = 0 A32 = (−1)3+2 2 4 |A| = 1(14) + 3(−7) + 1(0) = 14 − 21 + 0 = −7
Obviously the two answers agree, as they must. Using the general method for calculating the determinant it is clearly helpful to have as many zeros as possible in some row (or column) of the matrix, since evaluation using this row (or column) then means that the cofactors corresponding to each of the zero elements need not be calculated. Choosing to expand the determinant using the row (or column) with the most zeros therefore cuts down the calculations required. It is also possible, using a number of the properties of the determinant (stated below), to increase the number of zeros appearing in a row (or column) before calculating the determinant. Properties (i) If a matrix A has a zero row (or column) then |A| = 0, (ii) |A| = AT , (iii) if each element in a row (or column) of A is multiplied by a quantity K , then the value of the determinant is multiplied by K , (iv) if two rows (or columns) are interchanged then the sign of the determinant is changed, (v) if two rows (or columns) in a matrix are identical then its determinant is zero, (vi) if a scalar multiple of a row (or column) is added to any other row (or column) then the determinant is unchanged, (vii) |AB| = |A| |B|, (viii) |A + B| 6= |A| + |B| . Properties (vi) and (vii) are used the most often in practice. Let us consider a simple 10 Ex 7. Evaluate 2 5
example which illustrates the use of some of the above properties. 10 20 3 4 . 1 3
Clearly we could evaluate the determinant directly, without too much effort, but here we use the above properties to simplify the matrix so that there are less cofactors to calculate. There is a common factor in the first row, so using property (iii) 6
1 1 2 10 10 20 2 3 4 = 10 2 3 4 . 5 1 3 5 1 3 Property (vi) can be used to produce more zeros in the first row. Making new second and third columns by subtracting 1 × (col.1) from col.2 and subtracting 2 × (col.1) from col.3 respectively we deduce that 1 1 1 2 0 0 1 0 10 2 3 4 = 10 2 5 −4 −7 5 1 3 If we expand by the first row there is now only one non-zero element there and hence only one cofactor to evaluate (you could equally well use the third column and its one non-zero element – try this and compare the results). Hence 1 0 0 1 0 1 0 = 10 1 (−1)1+1 10 2 + 0 + 0 = 10 {1(−7 − 0)} = −70. −4 −7 5 −4 −7 The above example shows the manipulations necessary in order to reduce the number of cofactors to be calculated, but in this case the overall workload is probably higher than calculating the determinant directly. In some situations, however, particularly when letters are involved or the matrix is larger, the simplifications can be useful. This module is completed with a further definition, which is useful in module 17. Def.
The adjoint matrix, adjA is the transpose of the matrix of cofactors, i.e. adjA = (Aij )T .
rec/00lm1
7