Lecture 01
Matrices
Dr Kissani Perera
Department of Mathematics
In this lesson, we will study
•Define a matrix
•Types of matrices
•Matrix operations-
• add matrices
• multiply a matrix by a scaler
Matrices - Introduction
Definition:
A matrix is a set or group of numbers arranged in a square or
rectangular array enclosed by two brackets (square
brackets/round brackets)
1 1 1 1
3 0
a b
c d
1 1 a b
3 0 c d
Applications:
The numbers in a matrix can represent data, and they can also
represent mathematical equations
Matrices are used to solve simultaneous equations
Matrices are so useful in computer science since every graph can
be represented by using a matrix
Example: Matrix can represent sales of a company:
Sales of car Sales of van
Month January 100 20
Month Febraury 30 28
Matrices - Introduction
Properties:
•A specified number of rows and a specified number of
columns
•Two numbers (rows x columns) describe the dimensions
or size or order of the matrix.
Examples:
A matrix A with two rows and two columns, looks like :
The first row has elements a and b, the
a b
A
second row has elements c and d.
c d The first column has elements
a and c; the second column has elements b
and d
A is a two by two matrix (2 X 2 )
A matrix can be denoted by an uppercase letter such as
A,B ,C ,…
A matrix can be denoted by a representative element
enclosed in brackets such as [𝑎𝑖𝑗 ]
Matrix A with elements aij (i=1 to m ; j=1 to n)
Number of rows= m number of columns =n
Hence the size is m x n
a11 a12 ... a1 j a in
a a 22 ... a 2 j a2n
A
21
a a mn
m1 a m 2 a mj
Exercise 1:
Find the size of the following matrices:
1 3 5 a b c d
(ii ) ( iii ) 1 1
(i ) 2 1 6 0 e f 0
2 3 3
TYPES OF MATRICES
1. Column matrix or vector:
The number of rows may be any integer but the number of
columns is always 1
1 a11
4 1 a 21
3
2
a m1
2. Row matrix or vector
Any number of columns but only one row
1 0 3 0 3 5 2
a11 a12 a13 a1n
3. Rectangular matrix
Contains more than one element and number of rows is not
equal to the number of columns
1 1 1 0 2 7 0
3 2 5 0 3 3 0
7 5
5 2x5
6
4x2
4. Square matrix
The number of rows is equal to the number of columns
(a square matrix A has an order of m)
mxm
1 1 1
1 1 9 9 0
3 0
6 6 1
5. Diagonal matrix
A square matrix where all the elements are zero except those on
the main diagonal
1 0 0 3 0 0 0
0 2 0 0 2 0 0
0 0 1 0 0 5 0
0
0 0 9
Main diagonal
6. Unit or Identity matrix - I
A diagonal matrix with ones on the main diagonal
1 0 0 0 1 0 a11 0
0
1 0 0 0 1 0
a22
0 0 1 0
0 0 0 1
7. Null (zero) matrix - 0
All elements in the matrix are zero
0 0 0 0
0 aij 0 For all i,j
0 0 0
0
0 0 0
8. Triangular matrix
A square matrix whose elements above or below the main
diagonal are all zero
1 0 0 1 0 0 1 8 9
2 1 0 2 1 0 0 1 6
5 2 3 5 2 3 0 0 3
8a. Upper triangular matrix
A square matrix whose elements below the main
diagonal are all zero
a11 a12 a13 1 2 3 4
0 a 0 1 7 4
22 a 23
0 0 2 8
0 0 a33
0
0 0 3
8b. Lower triangular matrix
A square matrix whose elements above the main diagonal are all
zero
a11 0 0 1 0 0
a a22 0 3 2 0
21
a31 a32 a33 5 2 3
9. Scalar matrix
A diagonal matrix whose main diagonal elements are
equal to the same scalar
A scalar is defined as a single number or constant
a11 0 0 1 0 0 6 0 0 0
0 a22 0 0 1 0 0
6 0 0
0 a33 0 0 1
0 0 0 6 0
0 0 0 6
Matrix Operations
EQUALITY OF MATRICES
Two matrices are said to be equal only when all corresponding
elements are equal
Therefore their size or dimensions are equal as well
A= 1 0 0 1 0 0
2 1 0
B= 2 1 0 A=B
5 2 3 5 2 3
Example :
Some properties of equality:
•If A = B, then B = A for all A and B
•If A = B, and B = C, then A = C for all A, B and C
b11 b12 b13
A=
1 0 0 b
2 1 0 B=
21 b22 b23
b31 b32 b33
5 2 3
If A = B then aij bij
ADDITION AND SUBTRACTION OF MATRICES
The sum or difference of two matrices, A and B of the same
size yields a matrix C of the same size
cij aij bij
Matrices of different sizes cannot be added or subtracted
Example:
A is 3x3 matrix and B is 3x2. We cannot
add since the size is different
Commutative Law:
A+B=B+A
Associative Law:
A + (B + C) = (A + B) + C = A + B + C
7 3 1 1 5 6 8 8 5
2 5 6 4 2 3 2 7 9
A B C
2x3 2x3 2x3
A+0=0+A=A
A + (-A) = 0 (where –A is the matrix composed of –aij as elements)
6 4 2 1 2 0 5 2 2
3 2 7 1 0 8 2 2 1
SCALAR MULTIPLICATION OF MATRICES
When working with matrices, real numbers are referred to as
scalars. You can multiply a matrix by a scalar c by multiplying
each entry in a matrix by c
You can use –A to represent the scalar product (-1)A.
If A and B are of the same size, A-B represents the sum of A and
(-1)B
That is,
A-B=A+(-1)B
Example: