Matrix Algebra - ComMSc
Matrix Algebra - ComMSc
In Computer Science
Matrix
Algebra
Naleen Ganegoda
Department of Mathematics
University of Sri Jayewardenepura
1
Matrices
For what ?
2
A static problem...
3
An electric circuit.... (Kirchhoff's laws)
The algebraic sum of currents in a network meeting at a point is zero.
The directed sum of the voltages around any closed loop is zero.
4
Learning outcomes
• Define a matrix
• Understand what is meant by the equality of two matrices
• Add and subtract two matrices
• Multiply a matrix by a scalar and multiply two matrices
together
• Obtain the transpose of a matrix
• Recognize special types of matrix
• Obtain the determinant, cofactors and adjoint of a square
matrix
• Obtain the inverse of a matrix
• Solve a set of linear equations using inverse matrices
• Eigenvalues and Eigenvectors
5
Matrices
Definition: A matrix is a set of numbers (or elements)
arranged in rows and columns to form rectangular array.
6
Ex: Find the order
2 1
i. 5 9
4 0
8 1 9
ii.
2 5 2
0 2 1
iii . 4 2 1
7 1 6
7
Special Matrices
Row matrix: A row matrix consists of one row only.
eg. 4 2 3 4 is a row matrix of order 14.
8
Matrix notation
Double suffix notation: each element in a matrix has its own
particular ‘address’ or location which can be defined by a
system of double suffixes, the first indicating the row, the
second the column. Thus a 23 matrix has the notation:
9
Matrix notation ctd…
eg.
a11 a12
a13
can be denoted by aij or
a21 a22 a23 23
simply by a
ij
Similarly, x1 x
can be denoted by orx
x i 21 i
2
10
Equality of Matrices
Two matrices are said to be equal if corresponding elements
throughout are equal.
a11 a12 3 2
So, if
a21 a22 4 1
11
Addition & Subtraction of Matrices
i )1 4 2 1 3 0
3 4 2 3
ii )
1 8 3 8
4 2 3 1 8 9
iii )
5 7 6 3 5 4
7 4 6 7 1 2
iv )
1 7 5 8 3 7
13
Multiplication of matrices
There are two types of multiplication.
1. Scalar multiplication
2. Matrix multiplication
14
Multiplication of matrices ctd…
1. Scalar multiplication
To multiply a matrix by a single number (i.e. a scalar),
each individual element of the matrix is multiplied by
that number:
eg.
3 2 5 12 8 20
4
6 1 7 24 4 28
In general,
k aij kaij
Ex:
2 4 2 2 2 3
i ) 3 ii ) 2
7 5 1 9 6 2
15
Multiplication of matrices ctd…
2. Matrix multiplication
Two matrices can be multiplied together only when the
number of columns in the first is equal to number of
rows in the second.
b1
a11 a a
eg. if 12 13
and B b2
a21 a a
22 23 b
3
Then, b1
B a11
a a13 a11 b1 a12 b2 a13 b3
a23 b2 a21b1 a22 b2 a23 b3
12
a 21 a
b3
22
Here,
order (2 3) order (3 1) order (2 1)
16
Matrix multiplication ctd…
3
Ex: i ) 2 6
5
2 5 3 5
ii )
1 9
4 1
2
3 4 2
iii )
8
5
7 5
0
1 0 3
Ex: If A 2 1 4 , then find A 2.
2 4 5
17
Matrix multiplication ctd…
eg. 1 2 0 1
A B
3 4 6 7
19
Transpose of a matrix
If the rows and columns are interchanged, then the new matrix
so formed is called the transpose of the original matrix.
Here, the 1st row becomes the 1st column, the 2nd row becomes
2nd column, etc.
eg. 3 1
3 8 9
A AT 8 0
1 0 4
9 4
21
More special matrices
Square matrix: a matrix whose number of rows and
number of columns are equal.
eg.
1 2 5
6 8 9
1 7 4
24
Determinant of a square matrix
The determinant of a square matrix is the determinant having the same
elements as those of the matrix.
2 1 2 1
e.g. Determinant of is which has the value 8.
4 6 4 6
2 0 0
1 2 1 0
i) ii) iii) 0 3 0
-1 3 0 1 0 0 5
iv) Show that A A T for any square matrix A.
Result: If A and B are two square matrices of same order, then |AB| = |A| |B|.
Cofactors of a square matrix
Each element of a square matrix has a cofactor, which is simply the minor of the element in the
determinant together with its place sign.
2 3 5
eg. Let A 4 1 6 .
1 4 0
1 6
Cofactor
Try to find all theof is
other2cofactors. 24
4 0
4 6
Cofactor of 3 is 6
1 0
Adjoint of a square matrix
Adjoint of a matrix A is a matrix which is formed by the
transpose of the matrix of cofactors of A .
a11 a a
12 13
eg. A a 21 a 22 a23
a31 a 32 a33
1
B is called the inverse of A and denoted by A .
Finding the inverse
Method 1
2 5
eg. Find the inverse of A
1 3
Thus, we have to find B such that AB I.
2 5 a b 1 0
1 3 c d 0 1
2a 5c 2b 5d 1 0
a 3c b 3d 0 1
2a 5c 1 , a 3c 0 a 3, c -1
2b 5d 0 , b 3d 1 b -5, d 2
1 3 5
Inverse of A : A
1 2
Finding the inverse ctd…
Method 2
1
-1
Using the formula A adj A .
A
Remark : In case A 0, A is not invertible
eg.
2 3 5 - 24 20 13
A 4 1 6 adj A 6 - 5 8 and A 45
1 4 0 15 - 5 - 10
- 24 20 13
- 24 20 13 45 45 45
-1 1 1 6 -5 8
A adj A 6 - 5 8
A 45 45 45 45
15 - 5 - 10 15 -5 - 10
45 45 45
Result: If A and B are invertible, then (AB) 1 B 1A 1.
2 3 1 0 1 4
i) ii) iii)
4 5 0 2 2 8
2 7 4 1 2 3
iv) 3 1 6 v) 4 1 5
5 0 8 6 4 2
Solving a system of linear equations using
matrix inverse.
eg. 2 x 5 y 1
x 3 y 4
2 5 x 1
(matrix representa tion of the system)
1 3 y 4
This is of the type Ax b, where
2 5 x 1
A , x , b
1 3 y 4
Solving a system using matrix inverse ctd…
Ax b
multiply both sides by A 1
A 1Ax A 1 b
(A 1A)x A 1b
I x A 1b
x A 1b
Then, the solution of the system can be obtained by A 1b
3 5 1 17
Then, x
1 2 4 7
x 17
i.e.
y 7
x 17 , y 7.
Ex: Solve the following systems using matrix inverse.
i) 2 x 3 y 8 ii) x 2 y z 4
3 x 4 y 5 3 x 4 y 2 z 2
5 x 3 y 5 z 1
iii) 2 x1 x2 3 x3 2
x1 3 x2 x3 11
2 x1 2 x2 5 x3 3
Eigenvalues and Eigenvectors
Equation of the form Ax = λx, (where A is a square matrix, x
is a column matrix and λ is a number) can be seen in many
technological applications involving oscillation, vibration,
chemical bonds etc.
Result : For the above set of homogeneous linear equation (i.e. right-hand
constants all zero) to have a non-trivial solution, |A- λI| must be zero.
Characteristic equation: | A I | 0
4 1 1 0 4 1
A I
2 1 0 1 2 1
4 1
A I 0 0
2 1
(4 )(1 ) 2 0
2 5 6 0
2 or 3
4 1 x1 x1
Ax x 2
2 1 x2 x2
4 x1 x2 2 x1 (consideri ng the 1st row)
2 x1 x2 0