Topic 2 Matrices

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

2.

1 Objectives
By the end of the topic learners should be able to
 Define a Matrix
 Add, Subtract and Multiply Matrices and Vectors
 Describe Zero and Unity Matrices
 Invert a Matrix
 Evaluate Probability Transition Matrices.

2.2 Presentation of information


Accountants and businessmen are well versed with presenting information in tabular form or
writing information in rows and columns. Often one set of information in tabular form e.g.
depreciation by category of fixed asset, is worked upon to produce a subsequent set of
information based upon the first table, e.g. depreciation by category of fixed asset spread over
cost centre’s. Although not generally referred to as such the above are examples of matrices. An
understanding of matrices and matrix algebra may provide short cut methods of calculation and
will provide further insights into improved methods of presenting and manipulating data.
2.3 Matrix definition
A matrix is a rectangular array of numbers whose value and positioning in the matrix is
significant. A matrix is usually, but not always, shown in brackets thus,
1 8 
 
3 7
Example 1
The size of a matrix is given by the number of rows and the number of columns, i.e. rows x
columns. The symbols most commonly used being m (columns) x n (rows). The matrix in
Example 1 is a 2 x 2 matrix, and as the number of columns equals the number or rows, it is
known as square matrix.
The following are further examples matrices:
 x1 x2   8 12 6 
   5 9 16   
 x3 x4     9 5 1
x x   2 8 4 7 0 2
 5 6  
Example 2 Example 3 Example 4
(a 3 x 2 matrix) (a 2x 3 matrix) (a 3x 3 matrix i.e. squire)
The standard notation for an element in a matrix is as follows
Xi,j = the element in Row i Column j
Thus
X2,3 = the element in the second row, column three.
2.4 Vectors
A single row matrix is called a row vector and a single column matrix is called a column vector

Example 5 (row vector) (9 5 8 2)

1
 16 
 
5
Example 6 (column vector)  
2 
 
9 
2.5 Matrix algebra
The particular rules applying the manipulation of data in matrix form are given in the following
sections on matrix addition, matrix addition, matrix subtraction, matrix multiplication and matrix
inversion. As a form of shorthand matrices are often referred to by capital letters, for example
1 6 
 
A =5 2
8 3 
 
3 2
C =  Example 7
1 6 
2.6 Matrix addition
The only rule is that matrices to be added (or subtracted) must be the same size as one another,
i.e. they must have the same number of columns and the same number of rows, for example.
1 11 2 
A=  
6 2 9
2 0 7
B=  
5 9 6 
 1 11 2   2 0 7 
  
 6 2 9  5 9 6 

1  2 11  0 2  7
 
A+B 65 29 96

 3 11 9 
A B   
 11 11 15 
It will be noted that numbers in the same locations have been added giving a matrix with the
same dimensions as those added, i.e a 2 x 3 matrix. Note that A+B = B + A, i.e. it does not
matter in which sequence the matrices are added. It follows that any number of matrices can be
added together provided they are the same size. If the matrices are not the same size they cannot
be added, for example.
1 4  6
If X=   and Y =   Example 9
8 2  5
X+Y have no meaning because the matrices involved are not the same size.

2
2.7 Matrix subtraction
Matrix subtraction uses the same general rules as matrix addition. For example, using the same
matrices as in Example 8 calculate
A-B
 11 2   2 0 7 
1
i.e.   
6 2 9 5 9 6
1  2 11  0 2  7 
A-B =   Example 10
6  5 2  9 9  6
 1 11  5 
= 
 1  7 3
It will be seen that minus numbers appear in the final matrix. If minus numbers appear in the
original matrix then the usual rules of arithmetic apply, for example minus a minus equal a plus.
It is important to note that whereas A+B =B+A, A-B  B-A, for example reversing Example 10
above to calculate
B - A gives
 2 0 7  1 11 2 
i.e.   
5 9 6  6 2 9
 2  1 0  11 7  2 
B –A =  
5  6 9  2 6  9

 1  11 5 
  Example 11
 1 7  3
It will be seen that this is a different result to that in Example 10.

2.8 Matrix multiplication


There are two aspects of matrix multiplication, the multiplication of a matrix by a single number,
called a scalar, and the multiplication of a matrix by another matrix.

2.9 Scalar multiplication


A scalar is an ordinary number such as 3,6,8,2 etc. The rule for this is simply-multiply each
element in the matrix by the scalar, for example.
5 2
Let A =  
8 3 
And it required to find 4 x A
5 2  20 8 
4xA=4x  =   example 12
8 3   32 12 
2.10 Matrix multiplication
The main rule to be remembered when it is required to multiply a matrix by another matrix is
that the number of columns in the 1st matrix must equal the number of rows in the 2nd matrix, i.e.
a 2x3 matrix can be multiplied with a 3x2 matrix (i.e. the number of columns, 3= number of
rows, 2) but a 2x3 matrix cannot be multiplied with another 2x3 matrix. The method of matrix
multiplication will be shown using the following matrices as a basis.
3
3 1
 
A=  2 4  i.e. a 3 x 2 matrix
7 4 

8 0 5 4
B =  i.e. a 2x4 matrix
3 2 11 1 

Calculate AB, i.e. AxB


Rows Columns
First check if feasibleA= 3 x 2
B= 2 x 4
 No. of columns of A= No. of rows of B.  Multiplication is feasible.
The new matrix AB is produced by the following steps

 38  13 30  1 2 35  111 3 4  11 


AB=  28  43 20  4 2 25  411 2 4  41
 
 7 8  43 7 0  4  2 7 5  4 11 7  4  4 1 
 
 27 2 26 13 
 
AB =  28 8 54 12 
 68 32 
 8 79 
Which, of course would normally be shown in the usual more compact form
2 7 2 26 13
 
AB =  2 8 8 54 1 2
6 8 32 
 8 79
The steps obtained AB were:
Multiply 1st element in 1st row in A by 1st element in 1st column in B (i.e. 3x8).
Multiply 2nd element in 1st row in A by 2nd element in 1st column in B (i.e. 1x3)
(This multiplication process would be continued until the nth element in 1st row of the first
matrix had been multiplied by the n element in the first column of the second matrix).
All these products are added to give the 1st element in 1st row and 1st column of the new matrix
AB
i.e. (3x8)+ (1x3) = 27
Then every number in the 2nd row of matrix A is multiplied with every number in the 1st column
of matrix B i.e. (2x8) and (4x3) and these are added to give the second element in the first
column of matrix AB, i.e. 28
This process is continued until every row of matrix A has been multiplied by the columns of
matrix B. when this is done, the new matrix, AB, has its first column. The process of multiplying
each row of matrix A with each column of matrix B continues until all the elements of the new
matrix, AB, are calculated.
Note: The size of AB is 3x4 i.e. it has the number of row of A and the number of columns of B.
I.e. Ax = AB

4
(3x2) x (2x4) = (3x4)

Must be the same


for multiplication
to be possible

size of final matrix


Notes
a) AxB does not equal BxA. This is unlike ordinary multiplication of numbers where
3x6=18 and so does 6x3=18.
b) If AxB is possible it does not follow that BxA is possible.

2.11 Vector multiplication


The process to be followed when multiplying a matrix by a vector is the same as detailed in 2.10
above. This will be shown by the following example:
4 3
 
A=  5 6 7  B=  1 2 
8 9 
 
i.e a 1x3 matrix (or row vector)
i.e. a 3 x2 matrix
4 3
 
 AB = 5 6 7 x  1 2 
8 9 
 
=  5 x 4  6 x1  7 x8 5x3  6 x2  7 x9 
AB =  82 90  i.e. a 1x2 matrix or row vector
2.12 An example of matrix multiplication
A group operates a chain of filling stations in each of which are employed cashiers, attendants
and mechanics as shown.
Types of filling station
Large Medium Small
Cashier 4 2 1
Attendants 12 6 3
Mechanics 6 4 2
(Matrix A, i.e. 3x3)
The numbers of filling stations are
NAIROBI MOMBASA
Large stations 3 7
Medium stations 5 8
Small stations 12 4
(Matrix B, i.e. 3x2)

5
How many of the various types of staff are employed in Nairobi and in Mombasa?
2.13 Zero Matrixes.
In matrix algebra a zero is represented by the zero matrixes which are any square matrix in
which every element is zero. As with normal numbers if a matrix is multiplied by a zero matrix
we obtain a zero matrix,

i.e.  3 4   0 0   (30)  (4 0) (30)  (4 0) 


    
5 6   0 0   (50)  (6 0) (50)  (6 0) 
0 0
 
0 0
2.14 Unity matrix
In matrix algebra unity is any square matrix whose top left to bottom right diagonal consists of
1st where all the rest of matrix consists of zeros. This matrix is important and is always given the
symbol I thus.
 1000 
 100   
   0100 
1 0  or  010  or
   001   0010 
 0 1    
 0001 
Matrices are only equal where they are the same size and have the same elements in the same
place, i.e.
1 0 0 
1 0   
   0 1 0
 0 1   
 0 0 1
As with normal numbers where a number multiplied by one equals itself (3x1=3) so with
matrices. A matrix multiplied by the unity matrix equals itself, i.e.
AI =A and IA =A
1 6 
A =  for example
 2 3

AI = 1 6  1 0  1 1  60 1 0  6 1 
    
 2 3   0 1  2 1  30 2 0  31
1 6 
= 
 2 3

Similarly IA = 1 0  1 6  1 1  02 1 6  0 3 
    
 0 1  2 3   0 1  1 2 0 6  13 
1 6 
  Thus proving that AI =IA=A
 2 3
Note: the unit matrix, I, must always be square

6
2.15 Matrix inversion
In matrix algebra the function of division is changed to that of inversion. The inverse (or
reciprocal) of a matrix has the same property as that of the inverse of an ordinary number. The
inverse of 8 is 1/8 so that
8x 1/8 =1=1/8x8
In matrix algebra the inverse of a matrix is denoted A-1x A
Only square matrices can have inverses which follow from
A X A -1 =A-1 X A
This expression implies that rows and columns are equal

2.16 Finding the inverse


Several methods exist for finding A-1 given A, but the following step by step method is simplest
and is quite manageable for the size off matrices likely to be encountered in examinations.
Assume that it is required to find the inverse of matrix A.

 a 11 a 12  1 2 
A=   
 a 21 a 22   3 4 
This is done by carrying out row by row operations on A with the objective of transforming it
into a unity matrix, I. At the same time the same row by row operations are carried out on a unity
matrix which at the end of the operations becomes A-1
Step 1 Place a unity matrix alongside A
1 2  1 0 
   
3 4  0 1 
Step 2 As a11 is already 1 we wish to make a21 into zero, i.e. Row 2-(3x Row 1)
1 2  1 0
Row 2-(3xRow 1) gives    
 0  2   3 1 
Step 3 We now require a22 to be 1, we multiply Row 2 by -1/2
1 2  1 0
Row 2x-1/2 gives    
0 1   3 / 2  1/ 2 
Step 4 finally we wish to make a12 into zero, i.e. Row 1-(2xRow 2)
1 0   2 1
Row 1 – (2xRow 2) gives Row 2-(3xRow 1) gives    
0 1   3 / 2  1/ 2 
A becomes I and the original I becomes A-1
Note: the row by row operations shown are similar to those used in the Simplex method of
solving LP problems given earlier.
To prove that the matrix obtained in Step 4 is A-1 we can multiply it by A and we should obtain a
unity matrix, i.e.
A x A-1=1
1 2   2 1  1   2  23 / 2 1 1  2  1 / 2
I.e.   x   
3 4   3 / 2  1/ 2   3  2  43 / 2 3 1 4  1 / 2

7
1 0
  1
0 1
Note.
 1 1
a) Not every square matrix has an inverse, for example   has no inverse.
 1 1
b) The product of two matrices, neither of which is a zero matrix, may give a zero matrix as an
answer, for example
1 1  1  1
A=   and B =  
1 1  1 1 
 1 1  1  1
AB=  x 
1 1  1 1 
0 0
= 
0 0
2.17 Finding the inverse using determinants
An alternative method of finding an inverse uses determinants. A determinant of matrix A is
denoted by A or Det A and is defined as follows (for a 2x2 matrix):
a b
If A =   then A  ad  bc
c d 
For example, matrix A from para 16 is
1 2 
   A = (1x4)-(3x2) =-2
3 4
A determinant is used as follows:
1 2  -1 1 d b 
If A =   then A =  
3 4 A  c a 
This procedure will be used to invert matrix A from Para 16 for which the determinant is -2, as
calculated above.
1 2 
A=   and A = -2
3 4
1  4  2
 A-1 = -  
2  3 1 
Which, multiplied in the usual manner, gives
 2 1
-1
A =  
1 1  1 
 2 2
Which is the same result obtained by using the row by row operations in the preceding paragraph
In three dimensions

2.18 Solving simultaneous equations by matrix algebra

8
Matrix algebra can be useful for solving simultaneous equations. To be able to find a unique
solution there must be an equal number of equations and unknowns (or more equations than
unknown) so that a square matrix can be established. The solutions method is similar to the
method of finding the inverse of a matrix, i.e. row by row operations. This will be demonstrated
using the following example:
Solve, using matrix algebra, the following simultaneous equations.
3x+4y = 10
2x+7y = 11
Setting out the problem in matrix form gives
 3 4 10 
  
 2 7 11 
From which it is required to produce
1 0  x 
  
 0 1  y 
Giving a numeric answer for x and y
Step 1. Set out the equations in matrix form (i.e. as above)
 3 4 10 
  
 2 7 11 
Step 2 Make a11 into 1 by subtracting Row 2.
1  3  1
Row 1- Row 2 gives   
 2 7 11 
Step 3 Make a21 into a zero by subtracting 2 x Row 1
1  3  1
Row 2-(2x Row 1) gives   
 0 13 13 
Step 4 Make a22 into 1 by dividing Row 2 by 13
1  3  1
Row 2  13 gives   
 0 1  1 
Step 5 Make a12 into zero by adding to Row 1 three times Row 2
 1 0  2 
Row 1+ (3xRow 2) gives   
 0 1 1 
x  2 y 1
Which can be checked by substituting in the original equations
3x+4y = 10
2x+7y =11
i.e. 3x2+4x1 =10
2x2+7x1 =11
In three dimensions
https://www.cliffsnotes.com/study-guides/algebra/algebra-ii/linear-sentences-in-two-
variables/linear-equations-solutions-using-matrices-with-two-variables

Cramers Rule
https://www.chilimath.com/lessons/advanced-algebra/cramers-rule-with-three-variables/

9
2.22 Exercise
1. How is the size of a matrix described?
2. What is a vector
3. What is the rule regarding the size of matrices that are to be added?
4. Does A-B = B-A?
5. What is scalar multiplication?
6. What is the size rule for matrix multiplication?
7. How is matrix multiplication carried out?
8. What is the unity matrix?
9. Does A x A-1 = A-1 x A?
10. What are the steps in matrix inversion?
11. What are the essential conditions for simultaneous equations to be solved by
matrix algebra
12. What are probability transition matrices and what are they used for?
 3 11 6  1 2 0
   
13. X = 9  3 8  Y = 0  4 5 
5 0 9  5 8 7
  
Calculate a) X+Y
b) X-Y
14. Multiply the matrices X and Y given in question 13
6 4
15. Let M=  
3 1 
Find M-1 using determinants and check your answer using row by row operations

10

You might also like