Topic 2 Matrices
Topic 2 Matrices
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.
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 65 29 96
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.
4
(3x2) x (2x4) = (3x4)
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,
AI = 1 6 1 0 1 1 60 1 0 6 1
2 3 0 1 2 1 30 2 0 31
1 6
=
2 3
Similarly IA = 1 0 1 6 1 1 02 1 6 0 3
0 1 2 3 0 1 1 2 0 6 13
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
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 23 / 2 1 1 2 1 / 2
I.e. x
3 4 3 / 2 1/ 2 3 2 43 / 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
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