You are on page 1of 52

Matrices

Outline

• What is a matrix?
• Different types of matrices
• Matrix Operations
• Solving a System of Linear Equations using Matrix Inversion
Matrices
• What is a matrix?
A matrix is a rectangular array of numbers. The numbers in the array are
called the entries of the matrix.

 a11 a12 ... a1n 


a a22 ... a2 n 
A =  21 
 ... ... ... ... 
a am 2 ... amn 
 m1 mn

Usually, we specify a position in the matrix as row, column. The size of a


matrix A is written in terms of the number of its rows x the number of its
columns.
aij is called ij-entry or ij element appears in row i and column j.
We also denote the above matrix as A= [aij ]m x n
Q
• Identify the sizes of the following matrices

2 1   − 1 2 0 1 2 
A= 
 3 2  B =  2 3 0 C = 2 0
   
 4 2 1 0 1 

1 0 1  1 0 1 0 1 
D=  E= 
0 1 0   2 1 0 1 2 

 2
F = 0  G = 2 0 1 1
 
1 
Square matrix
• A square matrix is a matrix with same number of rows as columns.
An n x n square matrix is said to be of order n and is sometimes called
an n-square matrix

1 2 3 4
1 0 2 − 2
• E.g.  2 4 0 1 2
A=  B = 3 1 0 C= 
1 3    3 1 0 3
3 0 1  1
 4 3 − 1

• The operations of addition, multiplication, scalar multiplication, and


transpose can be performed on any n x n matrices would result in
an n x n matrix.
Identity Matrix
• The n-square identity or unit matrix, denoted by In, or simply I, is the n-
square matrix with 1’s on the diagonal and 0’s elsewhere.
• For any square matrix A,

AI = IA = A
• Examples for identity matrices:

1 0  1 0 0 
0 1  0 1 0 
 
 
0 0 1
Matrix Operations
Matrix addition
Let A=[aij] and B=[bij] be two matrices with the same size, say m x n
matrices. The sum of A and B, written A+B, is the matrix obtained by
adding corresponding elements from A and B. That is
 a11 a12 ... a1n   b11 b12 ... b1n 
a a22 ... a2 n  b b22 ... b2 n 
A =  21 B =  21
 ... ... ... ...   ... ... ... ... 
   
am1 am 2 ... amn  mn bm1 bm 2 ... bmn  mn

 a11 + b11 a12 + b12 ... a1n + b1n 


a +b a22 + b22 ... a2 n + b2 n 
A + B =  21 21
 ... ... ... ... 
 
am1 + bm1 am 2 + bm 2 ... amn + bmn  mn
Matrix Addition
• Example:

2 1  5 1 
A=  B= 
 3 2   2 0 

 2 + 5 1 + 1  7 2 
A+ B =   = 
3 + 2 2 + 0   5 2 

2 − 5 1 − 1  − 3 0
A− B =   = 
3 − 2 2 − 0   1 2 
Matrix Operations
Scalar Multiplication
The product of the matrix A by a scalar k, written kA is the
matrix obtained by multiplying each element of A by k. That
is,

 ka11 ka12 ... ka1n 


 ka ka22 ... ka2 n 
kA =  21 
 ... ... ... ... 
ka kam 2 ... kamn 
 m1 mn
Scalar Multiplication
• Example:

2 1  2 1  10 5 
A=  5A = 5    = 
 3 2 3 2 15 10

 − 1 2 0  − 1 2 0  2 − 4 0 
B =  2 3 0 − 2B = −2   2 3 0 = − 4 − 6 0 
     
 4 2 1  4 2 1  − 8 − 4 − 2
Multiplying Two Matrices
1 2 3 3 − 1
If A*B =C A=  B = 2 0 
Steps:  4 5 6 
1 1 
1. Check whether the two matrices are compatible for multiplication.
A is a 2 x 3 matrix. B is a 3 x 2 matrix.
(No. of columns of A = No. of rows of B)

2. Identify the dimension of the resultant matrix. (2 x 2)


𝑐11 𝑐12
𝐶= 𝑐 𝑐22
21 2 ×2
Example: Multiplying Two Matrices
If A*B =C
Steps:
3. 𝑐𝑖𝑗 = dot product between ith row of A and jth column of B.

1 2 3 3 − 1
A=  B = 2 0 
 4 5 6 
1 1 

𝑐11 𝑐12 3 + 4 + 3 𝑐12


𝐶= 𝑐 𝑐22 𝐶=
21 2 ×2 𝑐21 𝑐22 2 ×2

10 𝑐12
𝐶=
𝑐21 𝑐22 2 ×2
Example: Multiplying Two Matrices
If A*B =C
Steps:
3. 𝑐𝑖𝑗 = dot product between ith row of A and jth column of B.

1 2 3 3 − 1
A=  B = 2 0 
 4 5 6 
1 1 

𝑐11 𝑐12 10 −1 + 0 + 3
𝐶= 𝑐 𝑐22 𝐶=
21 2 ×2 𝑐21 𝑐22 2 ×2

10 2
𝐶=
𝑐21 𝑐22 2 ×2
Example: Multiplying Two Matrices
If A*B =C
Steps:
3. 𝑐𝑖𝑗 = dot product between ith row of A and jth column of B.

1 2 3 3 − 1
A=  B = 2 0 
 4 5 6 
1 1 

𝑐11 𝑐12 10 2
𝐶= 𝑐 𝑐22 𝐶=
21 2 ×2 12 + 10 + 6 𝑐22 2 ×2

10 2
𝐶=
28 𝑐22 2 ×2
Example: Multiplying Two Matrices
If A*B =C
Steps:
3. 𝑐𝑖𝑗 = dot product between ith row of A and jth column of B.

1 2 3 3 − 1
A=  B = 2 0 
 4 5 6 
1 1 

𝑐11 𝑐12 10 2
𝐶= 𝑐 𝑐22 𝐶=
21 2 ×2 28 −4 + 0 + 6 2 ×2

10 2
𝐶=
28 2 2 ×2
Example: Multiplying Two Matrices
If A*B =C
𝑎11 𝑎12 … 𝑎1𝑛
𝑎21 𝑎22 … 𝑎2𝑛 𝑏11 𝑏12 … 𝑏1𝑗 … 𝑏1𝑝
… 𝑏2𝑗 … 𝑏2𝑝
𝐵 = 𝑏21
: : : 𝑏22
𝐴 = 𝑎𝑖1 𝑎𝑖2 … 𝑎𝑖𝑛 : : : :
: : : 𝑏𝑛1 𝑏𝑛2 … 𝑏𝑛𝑗 … 𝑏𝑛𝑝
𝑎𝑚1 𝑎𝑚2 … 𝑎𝑚𝑛 𝑛×𝑝
𝑚×𝑛

𝑐11 𝑐12 … 𝑐1𝑝


𝑐 𝑐22 … 𝑐2𝑝
𝐶 = :21 : :
𝑐𝑚1 𝑐𝑚2 … 𝑐𝑚𝑝 𝑚×𝑝
𝑛

𝑐𝑖𝑗 = ෍ 𝑎𝑖𝑘 𝑏𝑘𝑗


𝑘=1
Example: Multiply the following matrices
 2 4 1 4 
1. A=  B= 
1 3  2 1 

1 4 
2. A = 1 2 B= 
2 1 

− 2 4  3
3. A=  B= 
 1 − 3  − 2

3 2 1   1 − 1
4. A=  B = − 2 2 
8 3 4   
 0 1 
Determinant of a 2 x 2 matrix
• If  a11 a12 
A=
a21 a22 

the determinant |A| is given by

| A |= a11a22 − a21a12
Find the Determinant of the following matrices

2 3
A= 
 1 5

− 1 − 3
B=
2 5 

− 1 − 3
C= 
 2 − 5 
Inverse of a 2 x 2 matrix
• A square matrix A is said to be invertible or nonsingular if the following
relationship holds:
−1 −1
AA = A A = I

𝑎 𝑏
• If 𝐴=
𝑐 𝑑
1 𝑑 −𝑏
𝐴−1 =
𝐴 −𝑐 𝑎

• where 𝐴 = ad − cb
and 𝐴 ≠0
Solving simultaneous equations
A system of linear equations in matrix form.

e.g. x + y = 10
x − 2y = 4

The two equations can be represented as follows:

1 1  x  10 
1 − 2 y  =  4 
    

Ax = b −1
x= A b
Solve the following simultaneous equations
1. x+ y =5 2. 2x + y = 4
x − y =1 x − 2 y = −3

3. − x + 2 y = −1 4. 3 x + 4 y = 25
x − 2y =1 4 x + 3 y = 24
Minor
• The minor of an element is defined as a determinant obtained by
deleting the row and column containing the element. For the matrix A,

 a11 a12 a13 


A = a21 a22 a23 
a22 a23
M 11 =
a32 a33
a31 a32 a33 
a21 a23
M 12 =
a31 a33

• Find the following minors: M13, M21, M22, M23, M31, M32, M33 of the
matrix A.
Cofactor Matrix
• For the given matrix A,  a11 a12 a13 
A = a21 a22 a23 
a31 a32 a33 

cofactors are obtained as follows:

i+ j
Cij = ( −1) M
ij
Cij is the elements of the cofactor matrix.
The cofactor matrix
 a11 a12 a13 
A = a21 a22 a23 
i+ j
a31 a32 a33  C = ( −1)
ij
M
ij

C11 = ( −1)1+1 M 11

1+1
a22 a23
C11 = ( −1) = a22 a33 − a23 a32
a32 a33
Find all the cofactors .
Find the cofactor matrices of the following.

1 2 3
A = 0 1 2
3 2 0

− 1 2 − 3
B =  1 − 2 2 
 3 2 − 1
1 2 3
A= 0 1 2
Cofactor Matrix of A 3 2 0

1 2 0 2 0 1

2 0 3 0 3 2 𝑐𝑖𝑗 = (−1)𝑖+𝑗 𝑀𝑖𝑗
2 3 1 3 1 2
𝐶. 𝑀 = − −
2 0 3 0 3 2
2 3 1 3 1 2

1 2 0 2 0 1

(0 − 4) −(0 − 6) (0 − 3)
𝐶. 𝑀 = −(0 − 6) (0 − 9) −(2 − 6)
(4 − 3) −(2 − 0) (1 − 0)

−4 6 −3
𝐶. 𝑀 = 6 −9 4
1 −2 1
−1 2 −3
B= 1 −2 2
Cofactor Matrix of B 3 2 −1

−2 2 1 2 1 −2

2 −1 3 −1 3 2 𝑐𝑖𝑗 = (−1)𝑖+𝑗 𝑀𝑖𝑗
2 −3 −1 −3 −1 2
𝐶. 𝑀 = − −
2 −1 3 −1 3 2
2 −3 −1 −3 −1 2

−2 2 1 2 1 −2

(2 − 4) −(−1 − 6) (2 + 6)
𝐶. 𝑀 = −(−2 + 6) (1 + 9) −(−2 − 6)
(4 − 6) −(−2 + 3) (2 − 2)

−2 7 8
𝐶. 𝑀 = −4 10 8
−2 −1 0
Transpose of a matrix
• A transpose of a matrix is obtained by replacing all elements aij with aji.
The matrix transpose, most commonly written AT.
Inverse-(Adjoint Method)
• If A is a n x n square matrix, its inverse is obtained by;

−1 Adj A
A =
Determinent of A

(Cofactor matrix )T
A−1 =
A
Determinant of a n x n matrix
 a11 a12 ... a1n 
If a a22 ... a2 n 
A =  21 
 ... ... ... ... 
a an 2 ... ann 
 n1 nn

the determinant |A| is given by

i+ j
| A |=  aij (−1)
n

j =1
M ij

Mij is the determinant of the matrix after deleting ith row and jth
column
Determinant of a 3 x 3 matrix
• If
 a11 a12 a13 
A = a21 a22 a23 
 a31 a32 a33 

the determinant |A| is given by 𝑎11 𝑀11 − 𝑎12 𝑀12 + 𝑎13 𝑀13

a22 a23 a21 a23 a21 a22


| A |= a11 − a12 + a13
a32 a33 a31 a33 a31 a32
Find the Determinant of the following matrices

1 2 3
A = 0 1 2
3 2 0

− 1 2 − 3
B =  1 − 2 2 
 3 2 − 1
Find the Determinant of the following matrices
1 2 3
A= 0 1 2
3 2 0

𝐴 = 𝑎11 𝑀11 − 𝑎12 𝑀12 + 𝑎13 𝑀13

1 2 0 2 0 1
𝐴 =1 −2 +3
2 0 3 0 3 2

𝐴 =1 0−4 −2 0−6 +3 0−3

𝐴 = −4 + 12 − 9

𝐴 = −1
Find the Determinant of the following matrices
−1 2 −3
B = 1 −2 2
3 2 −1

𝐵 = 𝑏11 𝑀11 − 𝑏12 𝑀12 + 𝑏13 𝑀13

−2 2 1 2 1 −2
𝐵 = −1 −2 −3
2 −1 3 −1 3 2

𝐵 = −1 2 − 4 − 2 −1 − 6 − 3 2 − −6

𝐵 = 2 + 14 − 24

𝐵 = −8
Find the inverse of the following matrices
• We found the cofactor matrices and the determinants of A and B before.
Now, use adjoint method to find the inverse of A and B.

1 2 3
A = 0 1 2
3 2 0

− 1 2 − 3
B =  1 − 2 2 
 3 2 − 1
(Cofactor matrix )T
A−1 =
−1 A
Inverse of A (𝐴 )
1 2 3 −4 6 −3
A= 0 1 2 , 𝐶. 𝑀 = 6 −9 4 , 𝐴 = −1
3 2 0 1 −2 1

𝐶 𝑀𝑇
𝐴−1 = 𝐴

−4 6 1 −4 6 1
1
𝐴−1 = 6 −9 −2 where 𝐶. 𝑀𝑇 = 6 −9 −2
−1
−3 4 1 −3 4 1

4 −6 −1
−1
𝐴 = −6 9 2
3 −4 −1
B −1
=
(Cofactor matrix )T
−1 B
Inverse of B (𝐵 )
−1 2 −3 −2 7 8
B= 1 −2 2 , 𝐶. 𝑀 = −4 10 8 , 𝐵 = −8
3 2 −1 −2 −1 0

𝐶 𝑀𝑇
𝐵 −1 = 𝐵

−2 −4 −2 −2 −4 −2
1
𝐵 −1 = 7 10 −1 where 𝐶. 𝑀𝑇 = 7 10 −1
−8
8 8 0 8 8 0
0.25 0.5 0.25
𝐵 −1 = −0.875 −1.25 0.125
−1 −1 0
System of Linear Equations
• When solving a system of linear equations adjoint method is used to
find the inverse of the square matrix.

Solve the following linear systems using matrix inversion.

1. x+ y+z =6 2. 2x + y + 2z = 5
x+ 2 y − z =2 x + 2 y − z = −3
2 x + y + 2 z = 10 2x − y − z = 1

3.
x + 2y + z = 3
2 x − y + 2 z =11
x − 2y − z =1
System of Linear Equations
Q1 𝑥+𝑦+𝑧=6
𝑥 + 2𝑦 − 𝑧 = 2
2𝑥 + 𝑦 + 2𝑧 = 10

Represent the above system in matrix form:

1 1 1 𝑥 6
1 2 −1 𝑦 = 2
2 1 2 𝑧 10

𝐴𝐱 = 𝑏
𝐱 = 𝐴−1 𝑏

−1
𝐶. 𝑀𝑇
𝐴 =
𝐴
1 1 1 𝑥 6
1 2 −1 𝑦 = 2
2 1 2 𝑧 10
System of Linear Equations
2 −1 1 −1 1 2

1 2 2 2 2 1
1 1 1 1 1 1 𝑐𝑖𝑗 = (−1)𝑖+𝑗 𝑀𝑖𝑗
𝐶. 𝑀 = − −
1 2 2 2 2 1
1 1 1 1 1 1

2 −1 1 −1 1 2

(4 − (−1)) −(2 − (−2)) (1 − 4)


𝐶. 𝑀 = −(2 − 1) (2 − 2) −(1 − 2)
(−1 − 2) −(−1 − 1) (2 − 1)

5 −4 −3
𝐶. 𝑀 = −1 0 1
−3 2 1
1 1 1 𝑥 6
1 2 −1 𝑦 = 2
2 1 2 𝑧 10
System of Linear Equations
5 −4 −3
𝐶. 𝑀 = −1 0 1
−3 2 1

5 −1 −3
𝐶. 𝑀𝑇 = −4 0 2
−3 1 1

1 1 1
A= 1 2 −1 𝐴 = 𝑎11 𝑀11 − 𝑎12 𝑀12 + 𝑎13 𝑀13
2 1 2
2 −1 1 −1 1 2
𝐴 =1 −1 +1
1 2 2 2 2 1
𝐴 = 4+1 −1 2+2 + 1−4
𝐴 = −2
1 1 1 𝑥 6
1 2 −1 𝑦 = 2
2 1 2 𝑧 10
System of Linear Equations
𝐶. 𝑀𝑇
𝐴−1 =
𝐴

1 5 −1 −3
𝐴−1 = −4 0 2
−2
−3 1 1

𝐱 = 𝐴−1 𝑏

1 5 −1 −3 6 1 30 − 2 − 30
𝐱= −4 0 2 2 = −24 + 0 + 20
−2 −2
−3 1 1 10 −18 + 2 + 10
𝑥=1
1 −2 1
= −4 = 2 𝑦=2
−2 𝑧=3
−6 3
System of Linear Equations
Q2 2𝑥 + 𝑦 + 2𝑧 = 5
𝑥 + 2𝑦 − 𝑧 = −3
2𝑥 − 𝑦 − 𝑧 = 1

Represent the above system in matrix form:

2 1 2 𝑥 5
1 2 −1 𝑦 = −3
2 −1 −1 𝑧 1

𝐴𝐱 = 𝑏
𝐱 = 𝐴−1 𝑏

𝐶. 𝑀𝑇
𝐴−1 =
𝐴
2 1 2 𝑥 5
1 2 −1 𝑦 = −3
2 −1 −1 𝑧 1
System of Linear Equations
2 −1 1 −1 1 2

−1 −1 2 −1 2 −1
1 2 2 2 2 1 𝑐𝑖𝑗 = (−1)𝑖+𝑗 𝑀𝑖𝑗
𝐶. 𝑀 = − −
−1 −1 2 −1 2 −1
1 2 2 2 2 1

2 −1 1 −1 1 2

(−2 − (1)) −(−1 − (−2)) (−1 − 4)


𝐶. 𝑀 = −(−1 − (−2)) (−2 − 4) −(−2 − 2)
(−1 − 4) −(−2 − 2) (4 − 1)

−3 −1 −5
𝐶. 𝑀 = −1 −6 4
−5 4 3
2 1 2 𝑥 5
1 2 −1 𝑦 = −3
2 −1 −1 𝑧 1
System of Linear Equations
−3 −1 −5
𝐶. 𝑀 = −1 −6 4
−5 4 3

−3 −1 −5
𝐶. 𝑀𝑇 = −1 −6 4
−5 4 3

2 1 2
A= 1 2 −1 𝐴 = 𝑎11 𝑀11 − 𝑎12 𝑀12 + 𝑎13 𝑀13
2 −1 −1
2 −1 1 −1 1 2
𝐴 =2 −1 +2
−1 −1 2 −1 2 −1
𝐴 = 2 −2 − 1 − 1 −1 + 2 + 2 −1 − 4
𝐴 = −17
2 1 2 𝑥 5
1 2 −1 𝑦 = −3
2 −1 −1 𝑧 1
System of Linear Equations
𝐶. 𝑀𝑇
𝐴−1 =
𝐴

1 −3 −1 −5
𝐴−1 = −1 −6 4
−17
−5 4 3

𝐱 = 𝐴−1 𝑏

1 −3 −1 −5 5 1 −15 + 3 − 5
𝐱= −1 −6 4 −3 = −5 + 18 + 4
−17 −17
−5 4 3 1 −25 − 12 + 3
𝑥=1
1 −17 1
= 17 = −1 𝑦 = −1
−17 𝑧=2
−34 2
1 2 1 𝑥 3
2 −1 2 𝑦 = 11
1 −2 −1 𝑧 1
System of Linear Equations
Q3 𝑥 + 2𝑦 + 𝑧 = 3
2𝑥 − 𝑦 + 2𝑧 = 11
𝑥 − 2𝑦 − 𝑧 = 1

Represent the above system in matrix form:

1 2 1 𝑥 3
2 −1 2 𝑦 = 11
1 −2 −1 𝑧 1

𝐴𝐱 = 𝑏
𝐱 = 𝐴−1 𝑏

𝐶. 𝑀𝑇
𝐴−1 =
𝐴
1 2 1 𝑥 3
2 −1 2 𝑦 = 11
1 −2 −1 𝑧 1
System of Linear Equations
−1 2 2 2 2 −1

−2 −1 1 −1 1 −2
2 1 1 1 1 2 𝑐𝑖𝑗 = (−1)𝑖+𝑗 𝑀𝑖𝑗
𝐶. 𝑀 = − −
−2 −1 1 −1 1 −2
2 1 1 1 1 2

−1 2 2 2 2 −1

(1 − 2(−2)) −(−2 − 2) (−4 − (−1))


𝐶. 𝑀 = −(−2 − (−2)) (−1 − 1) −(−2 − 2)
(4 − (−1)) −(2 − 2) (−1 − 4)

5 4 −3
𝐶. 𝑀 = 0 −2 4
5 0 −5
1 2 1 𝑥 3
2 −1 2 𝑦 = 11
1 −2 −1 𝑧 1
System of Linear Equations
5 4 −3
𝐶. 𝑀 = 0 −2 4
5 0 −5

5 0 5
𝐶. 𝑀𝑇 = 4 −2 0
−3 4 −5

1 2 1
A= 2 −1 2 𝐴 = 𝑎11 𝑀11 − 𝑎12 𝑀12 + 𝑎13 𝑀13
1 −2 −1
−1 2 2 2 2 −1
𝐴 =1 −2 +1
−2 −1 1 −1 1 −2
𝐴 = 1 1 + 4 − 2 −2 − 2 + 1 −4 + 1
𝐴 = 10
1 2 1 𝑥 3
2 −1 2 𝑦 = 11
1 −2 −1 𝑧 1
System of Linear Equations
𝐶. 𝑀𝑇
𝐴−1 =
𝐴

1 5 0 5
𝐴−1 = 4 −2 0
10
−3 4 −5

𝐱 = 𝐴−1 𝑏

1 5 0 5 3 1 15 + 0 + 5
𝐱= 4 −2 0 11 = 12 − 22 + 0
10 10
−3 4 −5 1 −9 + 44 − 5
𝑥=2
1 20 2
= −10 = −1 𝑦 = −1
10 𝑧=3
30 3

You might also like