Topic 1.2: Matrices: (Or Elements) (Read As M by N) (M N Square)
Topic 1.2: Matrices: (Or Elements) (Read As M by N) (M N Square)
1. INTRODUCTION
Definition: A matrix is a rectangular array of numbers. The numbers in the array are called the
entries (or elements) in the matrix.
A matrix with only one row is called a row matrix (example: matrix U), and a
matrix with only one column is called a column matrix (example matrix W).
w1
w
U = u1 u2 un W = 2
wm
U=(…)
An entry of a row i and a column j of a matrix A is denoted as aij.
n columns
A matrix with n rows and n columns is called a square matrix of order n, and
the entries a11, a22, a33, …, ann are known as the main diagonal of A
2. OPERATION ON MATRICES
Equality of Matrices
Definition: Two matrices A = [aij] and B = [bij] are equal if they have the same
size and their corresponding entries are equal (aij = bij for all i and j).
Example 1:
2 3 2 3
A= , B= ==> A = B only when x = 4
4 9 x 9
EXERCISE: Find values for the p, q, r, and s if the matrices A and B are equal.
1 − 1 p −1
A = 2r − 3 , B = 2 q + 3
0 5 0 s − 9
Solution:
If A = B, then
p=1 , q+3 = –3 , 2r = 2 , s–9=5
q = –6 r=1 s = 14
Definition: If A = [aij] and B = [bij] are matrices both of sizes m n, then their
sum, A+B is an m n matrix resulting from the addition of the entries B to the
corresponding entries A i.e.
A + B = [aij + bij].
Their differences, A-B is an m n matrix obtained by subtracting the entries of
B from the corresponding entries of A i.e.
A − B = [aij − bij]
Example 2:
2 1 0 3 − 4 3 5 1
1 2 3
Let A = − 1 0 2 4 , B = 2 2 0 − 1 , C =
4 − 2 7 0 3 2 − 4 5 2 1 0
Find A+B and A-B. Also, find A+C, B+C, A−C and B−C.
A is 3 X 4, C is 2 x 3
Solution:
2 + ( −4) 1+ 3 0+5 3+1
A + B = −1+ 2 0+2 2+0 4 + ( −1)
4 + 3 − 2 + 2 7 + ( −4) 0 + 5
− 2 4 5 4
= 1 2 2 3
7 0 3 5
2 − ( −4) 1 − 3 0−5 3 −1
A − B = −1− 2 0−2 2−0 4 − ( −1)
4 − 3 − 2 − 2 7 − ( −4) 0 − 5
6 −2 −5 2
= − 3 − 2 2 5
1 − 4 11 − 5
Scalar Multiplication
Definition: If A = [aij] is an m n matrix and c is a scalar, the scalar multiple of
A by c is the m n matrix given by
cA = c[aij]
The symbol -A represents the scalar product (−1)A. Moreover, if A and B are of
the same size, then A−B represents the sum of A and (−1)B. That is,
A−B = A + (−1)B
Example 3:
1 2 4 0 2 7 9 − 6 3
Let A = , B = − 1 3 − 5 , C=
2 6 0 3 0 12
1 2 4 0 2 7 9 − 6 3 29 − 16 10
2 A − B + 3C = 2 − + 3 =
2 6 0 − 1 3 − 5 3 0 12 14 9 41
Matrix Multiplication
Definition: If A = [aij] is an m x n matrix and B = [bij] is an n p matrix, the
product AB is an m p matrix
AB = [cij] where,
n
cij = aik bkj = ai1b1 j + ai 2b2 j + ai 3b3 j + ... + ainbnj
k =1
In order for the product of two matrices to be defined, the number of columns of
the first matrix must equal the number of rows of the second matrix.
Am x n x Bn x p = Cm x p
must be same
size of C
AB BA
1
Example 4: Let A = 2 4 6 , B = 2 . Find A B and B A .
3
Solution:
A1 x 3 x B3 x 1 = C1 x 1
1
A B = 2 4 6 2
3
= (2 1) + (4 2) + (6 3)
= 28
B3 x 1 x A1 x 3 = C3 x 3
1
B A = 2 2 4 6
3
(1 2) (1 4) (1 6)
B A = (2 2) (2 4) (2 6)
(3 2) (3 4) (3 6) cBA = c12
2 4 6
= 4 8 12
6 12 18
4 1 4 3
1 2 4
Example 5: Let A = , B = 0 − 1 3 1 . Find A B .
2 6 0
2 7 5 2
Solution:
A2 x 3 x B3 x 4 = C2 x 4 Roti Canai Row Columns
AB = C
c c c c
= 11 12 13 14
c21 c22 c23 c24
c11 c12 c13 c14
c21 c22 c23 c24
AB = 1 2 4 4 1 4 3
2 6 0 0 − 1 3 1
2 7 5 2
j=1 j=2 j=3 j=4
i=1 ij = 11 12 13 14
1(4) + 2(0) + 4(2) 1(1) + 2(-1) + 4(7) 1(4) + 2(3) + 4(5) 1(3) + 2(1) + 4(2)
i=2 2(4) + 6(0) + 0(2) 2(1) + 6(-1) + 0(7) 2(4) + 6(3) + 0(5) 2(3) + 6(1) + 0(2)
Transpose of a Matrix
Definition: If A is an m n matrix, the transpose matrix denoted by AT , is an n
m matrix whose rows are the columns of A in the same order. In other words, AT
is obtained from A by interchanging the rows and columns of A.
1 − 2 4
Example 6: Find transpose of A = 3 7 0 .
− 5 8 6
1 3 − 5
Solution: AT = − 2 7 8
4 0 6
1
= 2 4 6 2
3
= (2 1) + (4 2) + (6 3)
= 28
AT B = 2 4 6 1 2 3
T
2
= 4 1 2 3
6
2×1 2×2 2×3
= [4 × 1 4×2 4 × 3]
6×1 6×2 6×3
2 4 6
= [4 8 12]
6 12 18
Theorem: Transpose of Matrix
Let A and B denotes matrices of the same size, and let k denote a scalar.
1. If A is an m n matrix, then AT is an n m matrix
2. (AT ) = A
T
3. (kA ) = kAT
T
4. ( A + B)T = AT + B T
3. DETERMINANT
Let A be a square matrix. The determinant is denoted by det(A) or A , and we
define det(A) to be a real number. The number det(A) can determine whether the
square matrix is singular or non-singular.
Order 1: A = [4]
det(A) = 4
Minor of an entry
Minor of entry aij is given by the symbol M ij . It is the determinant of a square
matrix of order n −1 obtained by deleting the entries in the row and column in
which the given entry lies.
a12 a13
M 21 = = a12a33 − a13a32
a32 a33
Cofactor of an entry
Cofactor , cij of the entry aij is Cij = (−1)i + j M ij
NOTE:
The only difference between a cofactor and a minor is the factor (−1)i+ j where
+ 1 , i + j = even
(−1) i + j =
− 1 , i + j = odd
Hence, we may write “+1” as just “+” and “–1” as “–”.
A quick way for determining whether to use ‘+’ or “–” is as follows:
+ − + − +
− + − + −
+ − + − +
− + − + −
+ − + − +
Example 11:
4 1 0
Let A = − 9 3 4 . Find the cofactor matrix of A.
− 3 8 1
Solution:
c11 c12 c13
Cofactor matrix of A = cij = c21 c22 c23
c31 c32 c33
The cofactor of each of the entry are
c11= + c12= - c13 = +
c21= - c22= + c23= -
c31= + c32= - c33= +
3 4 −9 4 −9 3
c11 = + c12 = ( − 1 )1+ 2 c13 = ( − 1 )1+3
8 1 −3 1 −3 8
= +3(1) − 4(8) = − − 9 − 4(− 3) = +− 9(8) − 3(− 3)
= −29 = −3 = −63
c 21 = c 22 = c 23 =
4 1 0
A = − 9 3 4
− 3 8 1
3 4 −9 4 −9 3
c11 = ( − 1 )1+1 c12 = ( − 1 )1+ 2 c13 = ( − 1 )1+3
8 1 −3 1 −3 8
= +3(1) − 4(8) = − − 9 − 4(− 3) = +− 9(8) − 3(− 3)
= −29 = −3 = −63
1 0 4 0 4 1
c21 = − c22 = + c23 = −
8 1 −3 1 −3 8
= −1(1) − 0(8) = 4(1) − 0(− 3) = −4(8) − 1(− 3)
= −1 =4 = −35
1 0 4 0 4 1
c31 = + c32 = − c33 = +
3 4 −9 4 −9 3
= 4−0 = −(16 − 0 ) = 12 − (− 9)
=4 = −16 = 21
− 29 − 3 − 63
Hence,
cij = − 1 4 − 25
4 − 16 21
12 − 1 3 4 1 0
a) A = − 3 1 − 1 b) A = − 9 3 4
− 10 2 − 3 − 3 8 1
Solution:
a) By choosing the first row,
1 −1 − 3 −1 −3 1
c12 = (− 1) c13 = (− 1)
1+ 2 1+3
c11 = +
2 −3 − 10 − 3 − 10 2
= (1)(− 3) − (− 1)(2) = −(− 3)(− 3) − (− 1)(− 10 ) = (− 3)(2) − 1(− 10 )
= −1 =1 =4
Thus,
A = a11c11 + a12c12 + a13c13
= (12 )(− 1) + (− 1)(1) + (3)(4)
= −1
OR, (as in cross product of 2 vectors)
1 −1 −3 −1 −3 1
A = 12 − (−1) + 3
2 −3 − 10 −3 − 10 2
= (− 1)12 + 1(− 1) + 4(3)
= −1
Exercise: Try to get the determinant of this matrix by using other row/column.
NOTE: The determinant of a matrix remains the same no matter which row/
column is used. A tip to save calculation steps is to use the row or column with
many zeros if any.
Properties:
1. If A has a zero row (or column), |A|= 0.
2. If two rows (or columns) of A are identical, |A|= 0.
3. If A is upper (or lower) triangular, then |A| is equal to the product of the main
diagonal entries.
1 2 3
B = 0 5 6 → det(B)=1x5x9 = 45
0 0 9
Example 8: Determinants of 2 2 and 3 3 Matrices
Find the determinant for the following matrices:
1 2 3 1 0 1
3 1
(a) A= (b) B = − 4 5 6 (c) A = 1 1 2
4 − 2 7 − 8 9 1 2 1
Solution:
3 1
(a) det(A) = =3(-2) – 4(1) = -10
4 −2
1 2 3
(b) B = − 4 5 6
7 − 8 9
By selecting 1st row,
5 6 −4 6 −4 5
det(B) = 1 −2 +3
−8 9 7 9 7 −8
= 1[(5)(9)- (6)(–8)] -2[(–4)(9)-(6)(7)] + 3[(–4)(–8) –(5)(7)]
= 1(93) − 2(−78) + 3(−3)
= 240
1 0 1
(c) A = 1 1 2
1 2 1
By selecting 1st row,
1 0 1
1 2 1 1
A = 1 1 2 =1 − 0 +1 = −2
2 1 1 2
1 2 1
Example 9:
0 1 4
Calculate A for matrix .
A = − 2 2 2
2 5 3
Solution:
To save calculation steps, we can expand along the 1st row or 1st column because
it contains one zero as compare with other rows or columns. Now, let’s say we
expand along 1st column, thus the solution is
0 1 4
A = −2 2 2
2 5 3
1 4 1 4
= 0 − ( −2) +2
5 3 2 2
= 2(3-20)+2(2-8)
= - 46
The Inverse
Definition: Let A be an n n square matrix. If there exists a matrix B of same size
such that
AB = BA = I
Example 10:
− 5
2 3 5
Let A = , B=
− 1 3 1 2
2 − 5 3 5 1 0 3 5 2 − 5 1 0
AB = = = I BA = = = I
− 1 3 1 2 0 1 1 2 − 1 3 0 1
Example 12:
1 − 1 0
Find the inverse of A = 1 0 − 1 .
6 − 2 − 3
Cij
roti canai → row column
Solution:
Step 1: Find cofactor of matrix of A, (Cij).
Cij = (−1)i + j M ij
c11= + c12= - c13= +
c21= - c22= + c23= -
c31= + c32= - c33= +
0 −1 1 −1 1 0
C11 = (−1)1+1 C12 = (−1) 1+ 2 C13 = (−1)1+3
−2 −3 6 −3 6 −2
= 0 − (−2)( −1) = −(1)( −3) − (6)( −1) = +(1)(−2) − (0)(6)
= −2 = −3 = −2
−1 0 1 0 1 −1
C 21 = (−1) 2+1 C 22 = (−1) 2+ 2 C 23 = (−1) 2+3
−2 −3 6 −3 6 −2
= −(−1)( −3) − (−2)(0) = +(1)( −3) − (6)(0) = −(1)(−2) − (6)(−1)
= −3 = −3 = −4
−1 0 1 −1
C31 = (−1)3+1 C32 = (−1) 3+ 2 1 0 C33 = (−1)3+3
0 −1 1 −1 1 0
= +(−1)(−1) − (0)(0) = −(1)(−1) − (1)(0) = +(1)(0) − (1)(−1)
=1 =1 =1
− 2 − 3 − 2
Therefore, cij = − 3 − 3 − 4
1 1 1
NOTE:
− 2 − 3 − 2 − 2 − 3 1
adj(A) = − 3 − 3 1
cofactor = − 3 − 3 − 4 transpose
1 1 1 − 2 − 4 1
NOTE: Remember that, the determinant is the sum of the product of cofactors
and entries.
NOTE: Notice that a square matrix A is invertible if and only if the det(A) 0.
Linear Equations
Definition: A linear equation in n variables x1 , x2 ,..., xn is an equation of the
following form:
a1 x1 + a 2 x2 + ... + a n xn = b
where a1 , a 2 ,..., a n and b are scalars (real numbers). The variables, x1 , x2 ,..., xn , are
called unknowns.
2x – 5y + 7 = 0
x-5y – 2 = 9
Systems of Linear Equations
A finite set of linear equations is called a system of linear equations:
a11x1 + a12 x2 + ... + a1n xn = b1
a21x1 + a22 x2 + ... + a2 n xn = b2
A sequence of numbers s1, s2 ,s3 ,…,sn is called the solution to the system of
equations if x1 = s1 , x2 = s 2 , x3 = s3 ,..., xn = s n is a solution of all the equations in the
system.
y y y
L1 L1 and L2
L1
L2
L2
x x x
matrix).
For example,
System Augmented Matrix Matrix Equation
x1 − 4 x2 + 3x3 = 5 1 −4 3 5 1 − 4 3 x1 5
− 1 3 − 1 − 3 − 1 3 − 1 x = − 3
− x1 + 3x2 − x3 = −3 2
2 0 − 4 6 2 0 − 4 x3 6
2 x1 − 4 x3 = 6
−1
NOTE: A =
1
A
adjA =
1
A
cij T
Example 13:
Solve the following system:
x1 − x2 = −2
x1 − x3 = −3
6 x1 − 2 x2 − 3x3 = −10
Solution:
Step 1: Write the system into matrix equation form.
AX = B
1 − 1 0 x1 − 2
1 0 − 1 x = − 3
2
6 − 2 − 3 x3 − 10
1 − 1 0 x1 −2
Note that, A = 1 0 − 1 , X = x2 and B = − 3 .
6 − 2 − 3 x3 − 10
− 2 − 3 − 2 − 2 − 3 1
adj(A) = − 3 − 3 1
cofactor = − 3 − 3 − 4 transpose
1 1 1 − 2 − 4 1
Step 4: Solve the system using X = A−1B .
Therefore, X = A −1 B
1
= adj( A) B
A
− 2 − 3 1 − 2
= − 3 − 3 1 − 3
1
1
− 2 − 4 1 − 10
(−2)( −2) + (−3)( −3) + (1)( −10)
= (−3)(−2) + (−3)(−3) + (1)(−10)
(−2)(−2) + (−4)( −3) + (1)(−10)
4 + 9 − 10
= 6 + 9 − 10
4 + 12 − 10
x1
3
X = x2
= 5
x3
6
Hence x1 = 3, x2 = 5 and x3 = 6.
Example 14:
Solve the following system of linear equations:
x + 2y = 2
x − y = −1
Solution:
AX = B
1 2 x 2
1 − 1 y = − 1
As A is a matrix order 2, we may directly proceed to step 3 due to its cofactor is
1 d − b
actually already given in the formula of its inverse: A−1 =
ad − bc − c a
Hence, X = A−1B .
1 − 1 − 2 2
= [It is better to multiple the two matrices first.]
− 3 − 1 1 − 1
1 (− 1)(2) + (− 2)(−1)
=
− 3 (− 1)(2) + (1)(−1)
1 0
=
− 3 − 3
0
=
1
Hence, x = 0, y = 1 .
EXERCISE:
Solve the following linear system by using the inverse.
4 x − 5 y − 6 z = −1
3x − 2 y = −5
(a) x − 2 y − 5 z = −12 (b)
x + 3 y = 13
2x − y = 7
4 x − 5 y − 6 z = −1
Given x − 2 y − 5 z = −12
2x − y = 7
AX = B
4 − 5 − 6 x − 1
1 − 2 − 5 y = − 12
2 − 1 0 z 7
−2 −5 1 −5 1 −2
c11 = + c12 = − c13 = +
−1 0 2 0 2 −1
= 0 − (−5)( −1) = −0 − (−10) = −1 − (−4)
= −5 = −10 =3
−5 −6 4 −6 4 −5
c21 = − c22 = + c23 = −
−1 0 2 −0 2 −1
= −0 − 6 = 0 − (−12) = −− 4 − (−10)
=6 = 12 = −6
−5 −6 4 −6 4 −5
c31 = + c32 = − c33 = +
−2 −5 1 −5 1 −2
= 25 − 12 = −− 20 − (−6) = −8 − (−5)
= 13 = 14 = −3
Cofactors of A,
− 5 − 10 3
cij = 6 12 − 6
13 14 − 3
(b) AX = B
3 −2 x −5
1 3 y = 13
1 d − b
A−1 =
ad − bc − c a
1 3 2
=
9 − (− 2 ) − 1 3
1 3 2
=
11 − 1 3
1 3 2 − 5
X = A−1B =
11 − 1 3 13
1
=
4
Hence, x = 1, y =4