IT2212
Matrix Defined (Fortney, 2020)
What is a Matrix?
• It is a mathematical object that contains a rectangular table or array of numbers or variables arranged
in horizontal rows (m) and vertical columns (n) enclosed in brackets or large parentheses
Order (m x n matrix) Coefficients (or entries) of a matrix
Example: Find the order of the given matrix. Also, find its A23 entry.
𝟏 𝟐 𝟑
𝑨 = [𝟒 𝟓 𝟔]
𝟕 𝟖 𝟗
Types of Matrices
• A column matrix is a matrix having all its elements in a single column.
𝟏𝟎
𝑪 = [ 𝟏𝟎𝟎 ] 3 x 1 Column Matrix
𝟏𝟎𝟎𝟎
• Row Matrix is a matrix having all its elements in a single row.
𝑹 = [𝟐 𝟒 𝟔 𝟖 𝟏𝟎] 1 x 5 Row Matrix
• Square Matrix is a matrix with the same number of rows and columns.
𝟏 𝟗
𝑺=[ ]
𝟒 𝟏𝟔
04 Handout 1 *Property of STI
Page 1 of 5
IT2212
• Zero Matrix is a matrix that has all its elements equal to zero.
𝟎 𝟎 𝟎
𝒁 = [𝟎 𝟎 𝟎]
𝟎 𝟎 𝟎
Operations on Matrices (Pierce, 2020)
Matrix Equality
• A = B means:
o They have the same size
o They have equal corresponding entries
Example:
Determine which of the matrices below are equal.
𝟓 𝟑 𝟐 𝟓 𝟑 𝟐 𝟓 𝟑 𝟐
𝑨 = [ 𝟑 −𝟓 𝟏𝟏] 𝑩 = [ 𝟑 𝟓 𝟏𝟏] 𝑪 = [ 𝟑 −𝟓 𝟏𝟏]
−𝟐 𝟏 𝟔 −𝟐 𝟏 𝟔 −𝟐 𝟏 𝟔
AB BC A=C
Matrix Addition and Subtraction
• Matrices of the same dimension can be added or subtracted.
• To add or subtract matrices, just add, or subtract the corresponding entries
Example:
𝟓 𝟔 𝟏 𝟐 𝟗 𝟑
𝑨 = [−𝟑 𝟓 𝟖] 𝑩= [ 𝟒 𝟎 𝟑]
𝟒 𝟔 𝟕 −𝟓 −𝟏 𝟑
Find A + B and A – B
5+2 6+9 1+3 𝟕 𝟏𝟓 𝟒
𝑨 + 𝑩 = [ −3 + 4 5+0 8 + 3] = [ 𝟏 𝟓 𝟏𝟏]
4 + (−5) 6 + (−1) 7 + 3 −𝟏 𝟓 𝟏𝟎
5−2 6−9 1−3 𝟑 −𝟑 −𝟐
𝑨 − 𝑩 = [ −3 − 4 5−0 8 − 3] = [−𝟕 𝟓 𝟓]
4 − (−5) 6 − (−1) 7 − 3 𝟗 𝟕 𝟒
Matrix Multiplication
Two (2) general categories:
1. Scalar in which a single number is multiplied with every entry of a matrix
Example: Find 2A
1 6 2∗1 2∗6 𝟐 𝟏𝟐
𝐴 = [9 3] 2𝐴 = [2 ∗ 9 2 ∗ 3] = [𝟏𝟖 𝟔 ]
6 0 2∗6 2∗0 𝟏𝟐 𝟎
2. Matrix Multiplication of an entire matrix by another entire matrix is possible if, and only if,
the number of columns in the first matrix equals the number of rows in the second matrix
Example: Find AB
04 Handout 1 *Property of STI
Page 2 of 5
IT2212
7 8
1 2 3
𝐴=[ ] 𝐵 = [ 9 10]
4 5 6
11 12
(1 ∗ 7) + (2 ∗ 9) + (3 ∗ 11) (1 ∗ 8) + (2 ∗ 10) + (3 ∗ 12) 𝟓𝟖 𝟔𝟒
𝑨𝑩 = [ ]=[ ]
(4 ∗ 7) + (5 ∗ 9) + (6 ∗ 11) (4 ∗ 8) + (5 ∗ 10) + (6 ∗ 12) 𝟏𝟑𝟗 𝟏𝟓𝟒
Transpose of a Matrix
• The transpose of a matrix is a matrix
transformation used in applications where
inverse and adjoint of matrices are required.
The transpose of a matrix is obtained by
changing the rows into columns and columns
into rows for a given matrix.
Example: Find the transpose of matrix A.
3 5
3 8 4
𝐴 = [8 1] → 𝐴𝑇 = [ ]
5 1 6
4 6
Identity matrix
A square matrix with ones on the main diagonal and zeros elsewhere.
1 0 0
𝐼 = [ 0 1 0]
0 0 1
Determinant of a Matrix
Only square matrices have determinants. The determinant is a scalar quantity solved by the following
algorithm:
𝑎 𝑏
For 2 x 2 matrix: [ ] → determinant = |𝑎𝑐 𝑏
| = a*d – b*c
𝑐 𝑑 𝑑
𝑎1 𝑏1 𝑐1
𝑏2 𝑐2 𝑎2 𝑐2 𝑎2 𝑏2
For a 3 x 3 matrix: [𝑎2 𝑏2 𝑐2] determinant = 𝑎1 ∗ | | − 𝑏1 | | + 𝑐1 ∗ | |
𝑏3 𝑐3 𝑎3 𝑐3 𝑎3 𝑏3
𝑎3 𝑏3 𝑐3
Inverse of a Matrix
The inverse of matrix (A-1) is another matrix, which on multiplication with the given matrix, gives the
multiplicative identity.
A * A-1 = I
To solve for the inverse of the matrix, there are several methods that yield the same answer.
Using the minor determinants, cofactors, and adjoint, we use the formula:
1
𝐴−1 = ∗ 𝐴𝑑𝑗 𝐴
|𝐴|
We solve for the inverse through the following steps:
Step 1: Build the Matrix of Minors, a matrix that consists of the determinant of the resultant matrix
formed when the rows and column of the entry is removed.
04 Handout 1 *Property of STI
Page 3 of 5
IT2212
Example: To solve for the a11 entry, eliminate the row and column containing this element.
? ? ◼ ◼
𝐴=[ ] → [◼ −1 2]
◼ 1 2
Solve for the determinant of the remaining elements
0
−1 2
[ ] → (-1) (2) – (2)(1) = 0 → [ ]
1 2
Step 2: Turn the matrix of minors into the Matrix of Cofactors, by multiplying the elements
+1 −1 +1
to 1 or -1 using this guide: (−1 +1 −1)
+1 −1 +1
Example:
2 1 −1 0−2 −1
𝐴 = [−3 −1 2 ] → 𝑚𝑖𝑛𝑜𝑟 𝑜𝑓 𝐴 = [3 2 4]
−2 1 2 1 7 1
0 2 −1
→ 𝑐𝑜𝑓𝑎𝑐𝑡𝑜𝑟 𝑜𝑓 𝐴 = [−3 2 −4]
1 −7 1
Step 3: Find the adjoint of A (Adj A) by getting the transpose of the cofactor of A.
0 2 −1 0 −3 1
𝑐𝑜𝑓𝑎𝑐𝑡𝑜𝑟 𝑜𝑓 𝐴 = [−3 2 −4] → 𝑎𝑑𝑗 𝐴 = [ 2 2 −7]
1 −7 1 −1 −4 1
Step 4: Divide each entry by the determinant of A.
2 1 −1
𝐴 = [−3 −1 2 ] → 𝑑𝑒𝑡𝑒𝑟𝑚𝑖𝑛𝑎𝑛𝑡 𝑜𝑓 𝐴 = (2 ∗ 0) − (1 ∗ −2) + (− 1 ∗ −1) = 3
−2 1 2
2/3 1/3 −1/3
𝐴−1 = [ −1 −1/3 2/3 ]
−2/3 1/3 2/3
Matrix Algebra (Rosen, 2019)
Systems of Linear Equations
A system of linear equations can be solved by matrix algebra by using the concepts of matrix multiplication
and matrix inverse.
Given: 2x + y - z = 8
-3x – y + 2z = -11
-2x + y + 2z = -3
First, form the matrix equation. Write the coefficients of the variables as follows:
04 Handout 1 *Property of STI
Page 4 of 5
IT2212
𝑥1 𝑦1 𝑧1 𝟐 𝟏 −𝟏
𝑥
[ 2 𝑦2 𝑧2 ] = [−𝟑 −𝟏 𝟐] = 𝑨
𝑥3 𝑦3 𝑧3 −𝟐 𝟏 𝟐
𝒙
𝒚
The next matrix is composed of the variables. [ ] = 𝑽
𝒛
𝟖
After the equal sign is the solution matrix = [−𝟏𝟏] = 𝑩
−𝟑
Written as a matrix equation we have:
A*V=B
𝟐 𝟏 −𝟏 𝒙 𝟖
[−𝟑 −𝟏 𝟐 ] ∗ [𝒚 ] = [−𝟏𝟏 ]
−𝟐 𝟏 𝟐 𝒛 −𝟑
Solution:
𝐵
𝑉 = 𝐴 𝑜𝑟 𝑉 = 𝐵 ∗ 𝐴−1 , where A-1 is the inverse of matrix A
Solving for the inverse:
2 1 −1 −4 −2 −5 −4 2 −5
𝐴 = [−3 −1 2 ] → 𝐴𝑚𝑖𝑛𝑜𝑟 = [ 3 2 4 ] 𝐴𝑐𝑜𝑓𝑎𝑐𝑡𝑜𝑟 = [−3 2 −4]
−2 1 2 1 1 1 1 −1 1
−4 −3 1
→ 𝐴𝑑𝑗 𝐴 = [ 2 2 −1]
−5 −4 1
2 1 −1
det 𝐴 = |−3 −1 2 | = (2 ∗ −4) − (1 ∗ −2) + (−1 ∗ −5) = −1
−2 1 2
1 −4 −3 1 1 4 3 −1
𝐴−1 = 𝐴𝑑𝑗 𝐴 ∗ =[ 2 2 −1] ∗ = [ −2 −2 1]
det 𝐴 −1
−5 −4 1 5 4 −1
𝑉 = 𝐵 ∗ 𝐴−1
𝑥 4 3 −1 8 𝟐
[𝑦] = [ −2 −2 1 ] ∗ [−11] = [ 𝟑 ]
𝑧 5 4 −1 −3 −𝟏
x = 2, y = 3, z = -1
References:
Fortney, J. P. (2020). Discrete Mathematics for Computer Science: An Example-Based Introduction. CRC Press.
Pierce, R. (2020). Inverse of a Matrix using Minors, Cofactors and Adjugate. (2020, February 9). Math Is Fun.
[Link]
Rosen, K. H. (2019). Discrete Mathematics and Its Applications. McGraw-Hill Education.
04 Handout 1 *Property of STI
Page 5 of 5