Documente Academic
Documente Profesional
Documente Cultură
Matrix Algebra
Dr Ioannis Moutzouris
1
1. What is a Matrix?
For example, the test scores for a class of five students on three examinations. The best way to
report these scores is to use the following table.
Student test 1 test 2 test 3
1 75 82 86
2 91 95 100
3 65 70 68
4 59 80 99
5 75 76 74
75 82 86
91 95 100
65 70 68
In matrix form the test scores are: S = 59 80 99
75 76 74
2
a1,1 a1, 2 a1, j
a2,1 a2, 2 a2, j
A
Therefore the general form of a matrix is
ai ,1 ai , 2 ai , j
A is a (i x j ) matrix and ai,j represents the element in the i row and j column.
Example: Identify the following elements s1,3, s5,3 and s4,1 , in the S matrix.
75 82 86 S1,3
91 95 100
S 65 70 68
S4,1 59 80 99
75 76 74 S5,3
3
2. Special types of matrices
There are special type of matrices according to the dimension, elements and the pattern of the elements
inside the matrix. So we have vectors, square matrices, diagonal etc.
2.1. Vectors
A row vector, R, is a matrix which has dimension of (1 x n) e.g. R = [ r1,1 ... r1,n ]
c1,1
A column vector, C, is a matrix which has dimension of ( n x 1) e.g. C =
cn ,1
75
91
65
As an example consider the test 1 scores of the students: S2 =
59
75
4
2.2. Square matrix
A matrix with equal number of rows and columns is known as a square matrix.
1 3 5
1 3
= 5 11
A(1 x1) = [21] B(2 x2)
7 C(3 x3) = 7 9
13 15 17
In a square matrix, the elements which have the same number of rows and columns, ai,j where i=j, are
known as diagonal elements.
Consequently, a matrix with non-zero diagonal elements and zeros elsewhere is called a diagonal matrix.
1 0 0
0 9 0
D(3 x3) =
0 0 17
5
2.4. Identity Matrix
The most familiar diagonal matrix is the Identity Matrix, in which the diagonal elements are equal to one
and all off diagonal elements are zero.
1 0 0
0 1 0 1 if i j
I ai , j
or if i j
0
0 0 1
1 3 5
3 9 11
Y=
5 11 17
6
3. Transpose of a Matrix
The transpose of a matrix A, where A is (m n) with elements ai,j , is an (n m) matrix with elements equal
to aiT, j a j ,i and is denoted by A’ (or AT).
a1,1 a1,2
a1,1 a2,1 a3,1
A a2,1 a2,2 A'
a a1,2 a2,2 a3,2
3,1 a3,2
1 4
1 3 5
A 3 6 A'
5 8 4 6 8
When matrix A transposed to A’, the columns of A will become the rows of AT and vice versa.
Transpose of a row vector is a column vector and transpose of a column vector is a row vector.
Transpose of a symmetric matrix is equal to the matrix itself.
Transpose of a transposed matrix is equal to the original matrix, (A’)’=A
(A B)’= B’A’
7
4. Matrix Operations
Two matrices can be added or subtracted if and only if they have same dimensions.
Only the corresponding elements are added together or subtracted from each other.
1 3 2 4
Consider A (22) = 5 7 B(22) =
6 8
1 3 2 4 1 + 2 3 + 4 3 7
C(22) = A (22) B (22) = 6 8 5 + 6 7 + 8 = 11 15
5 7
These properties hold for matrix subtractions too, knowing that A-B=-B+A.
8
4.2 Scalar multiplication
When a scalar (a scalar is a single number) is multiplied by a matrix, then each element of the matrix is
multiplied by that scalar:
For example the test scores of the students can be scaled by 0.2, i.e. multiplying the score matrix by 0.2:
9
4.3. Matrix multiplication
To multiply two matrices, A and B and get AB, the necessary and sufficient condition is that the number of
the rows in B should be equal to the number of columns in A, otherwise the product of the two matrices is
not defined.
A B A B = C
(m n) (p q)
(m n) (p q) (m q)
The matrices can be multiplied if and only if n=p
a b w x aw by ax bz
c d x y z cw dy cx dz
(2 2) x (2 2) = (2 2)
10
Example 1
1 3 2
2 3 4
Consider the following matrices: A = and B = 2 4 1
5 6 7 5 6 3
Note that the number of columns in A is equal to the rows in B. therefore we can perform the multiplication.
2(1) 3(2) 4(5) 2(3) + 3(4) + 4(6) 2(2) + 3(1) + 4(3) 28 42 19
C AB
5(2) + 6(1) + 7(3) 52 37
=
5(1) + 6(2) + 7(5) 5(3) + 6(4) + 7(6) 81
11
Example 2
10
and the column vector of vessels owned (quantities): Q 5
1
12
Then:
10
a) The value of the portfolio is given by: V PQ 150 60 50 5 $1,850
1
10
V *
P *
Q 120 48 55 5 120(10) 48(5) 55(1) $1,495
The new value of the portfolio is:
1
Therefore the change in the value of the portfolio is V*- V = $1,495-$1,850 = -$355
The % change in the value of the portfolio is (V*- V)/V = ($1,495-$1,850)/ $1,850 = -%19.2
13
4.3.1 Properties of matrix multiplication
1. Commutative law: ABBA and kA=Ak
Check:
1 3 2
- 2 4 1 0 0
1 0 0
P( 43) I ( 33)
5 0 3
1
0 0 1
2 1 -1
14
Example
Suppose an oil company manufactures three types of gasoline: premium unleaded, regular unleaded and
regular leaded. These are produced by mixing two types of crude oil: WTI and Brent. The number of gallons
of crude oil required to manufacture 1 gallon of gasoline is represented in Table 1. If the company wants to
produce 10 gallons of premium unleaded, 6 gallons of regular unleaded, and 5 gallons of regular leaded,
what are the company’s crude oil requirements?
10
3 / 4 2 / 3 1 / 4
A(23) = 1 / 4 1 / 3 3 / 4 B(31) = 6
5
3 2 1
10 4 (10) ( 6) (5)
3 / 4 2 / 3 1 / 4 4
= 12.75
3
C(21) A (23)B (31)
6= 8.25
1 / 4 1 / 3 3 / 4 5
1 (10) 1 (6) 3 (5)
4 3 4
15
5. The Determinant
For every square matrix, A(nn) , a real number can be computed from the elements which is called
determinant of that matrix and is denoted as |A| or DA .
When the determinant of a square matrix is equal to zero, |A| = 0 , the matrix is called singular.
A matrix is singular when there is a linear dependence between at least two rows or columns of
the matrix.
When the determinant of a matrix is not zero, |A| 0, the matrix is non-singular and the rows
and columns of the matrix are linearly independent.
The concept of determinant is quite important and useful in matrix operations and solving simultaneous
equations.
The determinant of a (1 x 1) matrix is the value of the element inside the matrix. For example;
16
5.1 How to find the determinant of a 2 x 2 matrix
For a (2 x 2) matrix the determinant can be computed by deducting the product of the elements on the
secondary diagonal of A from the product of the elements on the principal diagonal of A. Therefore,
determinant of A can be computed by the following formula
Secondary diagonal
a1,1 a1,2
+
A= a1,1a22 a1, 2 a2,1
a2,1 a2,2
Main diagonal
As an example calculate the determinant of A:
2 - 2
A A = 2(1) - (-2)(3) = 8
3 1
2 6
A A = 2(9) - 6(3) = 0
3 9
It can be seen that in the second example, the determinant turn out to be zero and the matrix is singular.
17
5.2 The determinant of a (3 x 3) matrix
The determinant of a (3 x3) matrix can be computed using the following procedure;
1) Rewrite the first two columns of the matrix on the right hand side of the matrix.
2) Add the products of the elements on the primary diagonals (P1 P2 P3 ).
3) Add the products of the elements on the secondary diagonals (S1 S2 S3 ).
4) Deduct the result from stage 3 from the result from 2.
S1 S2 S3
a1,1 a1,2 a1,3 a1,1 a1,2
A = a 2,1 a 2,2 a 2,3 a 2,1 a 2,2
a a32 a3,3 a3,1 a32
3,1
P1 P2 P3
A a1,1 a 2 ,2 a 3,3 a1,2 a 2 ,3 a 3,1 a1,3 a 2 ,1 a 3,2 a 3,1 a 2 ,2 a1,3 a 3,2 a 2 ,3 a1,1 a 3,3 a 2 ,1 a1,2
18
As an example, compute the determinant of the following (3 x 3) matrix;
3 1 2
a) A - 1 2 4
3 - 2 1
S1 S2 S3
3 1 2 3 1
- 1 2 4 - 1 2
3 - 2 1 3 - 2
P1 P2 P3
The determinant of A is
|A|=[(3)(2)(1)+(1)(4)(3)+(2)(-1)(-2)]-[(3)(2)(2)+(-2)(4)(3)+(1)(-1)(1)]
= [(6+12+4)-(12-24-1)]=22-(-13)=35
19
5.2.1 Method of cofactors in finding determinants
A more general method of finding the determinant of a square matrix is the method of cofactors.
Definition: For any square matrix A, there exist a matrix of cofactors with the same dimension as A, which
is denoted as Ac.
Therefore, for each element in A, ai,j , there is a corresponding element in Ac , a’i,j, which are called
cofactors. In order to find the cofactor of the i,jth element of matrix A, we follow this procedure;
1) First cross of the ith row and jth column of the matrix.
2) Find the determinant of the remaining sub-matrix of the original matrix.
3) Call this determinant the minor of the i,jth element.
4) Multiply the minor of the i,jth element by (-1)(i+j). This means that if i+j is even, then the sign
assigned to the minor is positive. Similarly, if the sum of i+j is an odd number, then the sign
assigned to the minor should be negative.
20
Let us find the matrix of cofactors for a (3 x 3) matrix, A,
3 1 2
A - 1 2 4
3 - 2 1
21
To find sub-matrix using formula cofactor
(11)
a’1,1 3 1
- 1
2 a' 1,1 ( 1) (10)
2 4 = (-1) 2 (10) 10
3 - 2 1
10
a’1,2 3 1 2 a' 1,2 ( 1) (1 2 ) ( 13)
-1 2 4
= (-1) 3 ( 13) 13
3 -2 1
13
a’1,3 3 1 2 a' 1, 3 ( 1) (1 3) ( 4) Therefore the matrix of
-1 2 4
= (-1) ( 4) 4
4
cofactors for A(3 x3) is:
3 -2 1
-4
a’2,1 3
-1
1 2 a' 2 ,1 ( 1) ( 2 1) (5) 10 13 -4
4
A c - 5 9
2 = (-1) (5) 5
3
3 -2 1
-5 -3
a' 2 ,2 ( 1) ( 2 2 ) ( 3) 0 - 14 7
a’2,2 3
-1
1 2
2 4 = (-1) 4 ( 3) 3
3 -2 1
-3
a’2,3 3
-1
1 2 a'2,3 (1) ( 23) (9)
2 4 = (-1)5 (9) 9
3 -2 1
9
a’3,1 3 1 2 a' 3,1 ( 1) ( 31) ( 0)
-1 2 4
= (-1) 4 ( 0) 0
3 -2 1
0
a’3,2 3 1 2 a' 3,2 ( 1) ( 3 2 ) (14)
-1 2 4
= (-1) 5 (14) 14
3 -2 1
-14
Therefore, selecting the first row of A, in the above example, the determinant of A can be computed as
follows;
This general method can be used to find the determinant of any matrix with dimension greater than 2.
23
5.2.3 Properties of determinants
If any two column s or rows of a matrix are linearly dependent, then the
determinant of the matrix is zero.
The determinant of a matrix will be zero, if all the elements of one row or column
of that matrix are zero.
If two rows or columns of a matrix are interchanged, the sign of the determinant
of that matrix will change.
24
5.3 Inverse of a Matrix
If the determinant of a matrix is not zero, i.e. the matrix is non-singular, there can be identified a unique
square matrix with the same dimension as the original matrix known as the inverse and denoted as A-1 ,
with the following property.
AA 1 A 1 A I
The necessary and sufficient condition for the inverse to exist is that all rows and columns of A should be
linearly independent. This condition is the same as the condition for the determinant to be different from
zero. As an example for an inverse matrix consider the following (2 x 2) matrices.
2 3 8 -3
A
8
B=
5 - 5 2
25
5.3.1 How to find the inverse of a square matrix
If the determinant of the matrix is non zero, |A| 0, then find the adjoint matrix,
A j A' C , which is the transpose of matrix of cofactors.
Dividing each element in the adjoint matrix, Aj, by the determinant of the matrix,
|A|, yields the inverse matrix, A-1.
26
3 7
A
Example: Find the inverse of
2 5
5 - 2
1) Matrix of cofactors AC
-7 3
2) Determinant of A |A|=(3)(5)-(7)(2)=15-14=1
5 - 7
3) Adjoint matrix A j A' C
-2 3
5 - 7
1 1 5 -7
A -1 = A j 1
4) The inverse of A |A| - 2 3 - 2 3
1 1
27
0 1 2
Example: Find the inverse of B - 1 1 0
2 - 1 3
3 -5 -2 3 -5 -2
B j 3 - 2 3 - 2
1 1
B -1 = -4 -4
4) The inverse: |B| 1
- 1 2 1 - 1 2 1
0 1 2 3 -5 - 2 1 0 0
BB-1 -1 1 0 3 -4 - 2 0 1 0 =I
4) Verify the answer:
2 -1 3 -1 2 1 0 0 1
28
5.3.2 Using the inverse in solving the system of equations
Consider a system of equations in a matrix form:
AX B
If we multiply both sides of the equation by the inverse of the parameter matrix, i.e. A-1, we can write:
A-1 AX A-1 B
Therefore, a system of simultaneous equations can be solved by pre-multiplying the inverse of the parameter
matrix by the column vector of constants.
The only condition for the system to have a solution is for the parameter matrix to be non-singular.
In other words, the determinant of the parameter matrix should be different from zero for the system to have
a solution.
29
Example:
Find the values of x and y, which satisfy the following system of equations
3x 2 y 80
x 2 y 40
The above equation can be written in a matrix form by separating the variables and parameters as follows:
3 2 x 80
1
2 y 40 or AX=B
2 2
2 -2 4 (80) 4 ( 40) ( 40) ( 20)
4 4 80 20
X A 1 B
and the values of x and y :
1 3 40 ( 20) (30) 10
4 4 1 (80) 3 ( 40)
4 4
30
5.3.2.1 Using Cramer’s rule
An alternative and relatively easy way to solve simultaneous equations is to use Carmer’s Rule. This method
is based writing the equations in matrix form and use the determinant to find the solutions.
3x 2 y 80
x 2 y 40
The above equation can be written in a matrix form by separating the variables and parameters
as follows;
3 2 x 80
1
2 y 40 or AX=B
In order to find the value of x, a new matrix, Ax, is defined by replacing the elements in the first
column of A by the elements in B in the following form;
31
80 2 3 80
Ax Ay
40 2 1 40
80 2
Ax 40 2 (80)(2) (2)(40) 160 80 80
x 20
A 3 2 ( 3)(2) (2)(1) 6 2 4
1 2
3 80
Ay 1 40 ( 3)(40) (80)(1) 120 80 40
y 10
A 3 2 ( 3)(2) (2)(1) 6 2 4
1 2
Note that Carmer’s rule has a solution for the system of simultaneous equations as long as the
matrix A is a non-singular matrix, i.e. its determinant is not zero, |A|0.
32
5.3.3 Solving the system of equations (3x3)
Solve the following system of equations using the a) inverse matrix method and b) Cramer’s rule
y + 2z = 25
- x + y =4
2x - y + 3z = 27
0 1 2 x 25 0 1 2 25
-1 0 y 4
1
A -1 1 0 B = 4
2 -1 3 z 27 2 -1 3 27
33
a) The inverse of A, A-1 can be found by cofactor method as:
3 3 -1
1. Matrix of cofactors A C -5 -4 2 2. Determinant of A= |A|=1
-2 -2 1
3 -5 -2 3 -5 - 2
A j 3 - 2
- 2
4. Inverse matrix: A = 3 -4
-1
3. Adjoint matrix -4
- 1 2 1 -1 2 1
75 20 54 1
75 16 54 5
25 8 27 10
34
c) Cramer’s rule:
Determinant of A= |A|=1
25 1 2 0 25 2 0 1 25
A 4 1 0 , A y - 1 4 0 , A z - 1 1 4
Define Ax, Ay and Az: x
27 -1 3 2 27 3 2 -1 27
25 1 2
Ax
x Ax 4 1 0 =[(25*1*3)+(1*0*27)+(2*4*-1)]-[(2*1*27)+(25*0*-1)+(1*4*3)]=67-66= 1
| A|
27 - 1 3
0 25 2
Ay
y A y -1 4 0 =[(0*4*3)+(25*0*2)+(2*-1*27)]-[(2*4*2)+(0*0*27)+(25*-1*3)]=-54-(-59)=5
| A|
2 27 3
0 1 25
Az
z A z -1 1 4 =[(0*1*27)+(1*4*2)+(25*-1*-1)]-[(25*1*2)+(0*4*-1)+(1*-1*27)]=33-23= 10
| A|
2 - 1 27
35