Chapter 7_Matrices
Chapter 7_Matrices
Chapter 7: Matrices
Dr. Mohamad El Dandachy
[email protected]
Eng.Tarek Halawani
[email protected]
1
Content
▪ General properties of matrices
▪ Arithmetic operation on matrices
▪ Transpose of a Matrix
▪ Row echelon form
▪ Rank of a matrix
▪ The inverse of a square matrix
▪ Solving of linear system of equations
▪ By using inverse matrix
▪ By Gaussian Elimination
▪ The eigenvalues and eigenvectors problem
▪ Matrix partitioning (block decomposition)
2
Definition
▪ A matrix is a rectangular arrangement of numbers (or functions) in rows
and columns
𝑎11 𝑎12 … 𝑎1𝑛
𝑎21 𝑎22 … 𝑎2𝑛
𝐀 = 𝐴 = 𝑎𝑖 𝑗 = ⋮ ⋮ ⋱ ⋮
𝑚 ×𝑛
𝑎𝑚1 𝑎𝑚2 ⋯ 𝑎 𝑚𝑛
▪ Rows run horizontally and columns run vertically.
▪ The above matrix has m rows and n columns.
▪ A zero matrix: is a matrix (of any size) whose all elements are zero
𝑐11 𝑐12 … 𝑐1𝑚
𝑐21 𝑐22 … 𝑐2𝑚
▪ A 𝒎 × 𝒎 matrix: (m=n) 𝐂 = ⋮ ⋮ ⋱ ⋮ is a square matrix
𝑐𝑚1 𝑐𝑚2 ⋯ 𝑐 𝑚𝑚
▪ In a square matrix the elements {𝑎𝑖𝑖} = {𝑎11, 𝑎22,…, 𝑎 𝑚𝑚 } are called the main or principal diagonal of the
matrix
▪ Square matrix are important when solving sets of linear equations.
4
Special Type of square matrices
▪ Symmetric matrix: is a square matrix with 𝒂𝒊𝒋 = 𝒂𝒋𝒊 for all i and j
5 1 2
ex: 𝐀 = 1 6 −7
2 −7 8
▪ Skew Symmetric matrix: is a square matrix with 𝒂𝒊𝒋 = −𝒂𝒋𝒊 for all i and j
0 1 −2
ex: 𝐁 = −1 0 7
2 −7 0
▪ diagonal matrix: is a square matrix with 𝒂𝒊𝒊 ≠ 𝟎 and 𝒂𝒊𝒋 = 𝟎 for all 𝑖 ≠ 𝑗
5 0 0
ex: 𝐂 = 0 6 0
0 0 8
▪ Identity matrix: is a square matrix with 𝒂𝒊𝒊 = 𝟏 and 𝒂𝒊𝒋 = 𝟎 for all 𝑖 ≠ 𝑗 denoted by 𝑰
1 0 0
1 0
▪ ex: 𝐈𝟑×𝟑 = 0 1 0 , 𝐈𝟐×𝟐 =
0 1
0 0 1
▪ The multiplication of any 𝐀 matrix by 𝐈 gives the matrix 𝐀 → 𝑨𝐈 = 𝐀 5
Content
▪ General properties of matrices
▪ Arithmetic operation on matrices
▪ Transpose of a Matrix
▪ Row echelon form
▪ Rank of a matrix
▪ The inverse of a square matrix
▪ Solving of linear system of equations
▪ By using inverse matrix
▪ By Gaussian Elimination
▪ The eigenvalues and eigenvectors problem
▪ Matrix partitioning (block decomposition)
6
Arithmetic operation on matrices
▪ Equality: Two matrices 𝐀 = 𝑎 𝑖𝑗 and 𝐁 = 𝑏𝑖𝑗 are equal if:
𝑚×𝑛 𝑟×𝑐
▪ They have the same size (𝑚 = 𝑟 and 𝑛 = 𝑐)
▪ 𝑎 𝑖𝑗 = 𝑏𝑖𝑗 for all i and j
· 2 −3 −5 × 2 −5 × −3 −10 15
ex 1: −5 = =
4 −1 −5 × 4 −5 × −1 −20 5
2 −3 ∙ 2 × −5 −3 × −5 −10 15
ex 2: −5 = =
4 −1 4 × −5 −1 × −5 −20 5
8
Arithmetic operation on matrices (continue)
▪ Matrix Multiplication:
▪ Let 𝐀 = 𝑎 𝑖𝑗 and 𝐁 = 𝑏𝑖𝑗
𝑚 ×𝑛 𝑝 ×𝑞
▪ 𝐂 = 𝐀 ∙ 𝐁 = 𝐀𝐁 is only defined if 𝒏 = 𝒑 and 𝐂 will be a 𝒎 × 𝒒 matrix
▪ You can only multiply if the number of columns in the 1st matrix is equal to the number of rows in the 2nd matrix.
▪ ex:
▪ 𝐀𝟐×𝟐 ∙ 𝑩𝟑×𝟐is not defined
▪ 𝐀𝟐×𝟑 ∙ 𝑩𝟑×𝟓 ∙ 𝑪𝟓×𝟒 gives a matrix of size 2 × 4
▪ The entries 𝑐 𝑖𝑗 = ∑ 𝒏𝑘 =1 𝑎 𝑖𝑘 𝑏 𝑘𝑗
▪ The matrix multiplication is not commutative: 𝐀 ∙ 𝐁 ≠ 𝐁 ∙ 𝐀
▪ Matrix multiplication is associative: (𝐀 ∙ 𝐁) ∙ 𝐂 = 𝐀 ∙ (𝐁 ∙ 𝐂)
ex: 𝟐 −𝟏 ∙ · 𝟑 −𝟗 𝟐
=?
𝟏 −𝟐𝟓 𝟏𝟎
𝟑𝟑 𝟒𝟒 𝟓𝟓 𝟕𝟕 −𝟔
−𝟔 𝟐𝟗 𝟏 −𝟏𝟖
6 6 −5 6 9 −4
▪ ex 1: A = 9 7 11 → AT = 6 7 9
−4 9 −3 −5 11 −3
2 −3
2 4 7
▪ ex 2: 𝐵 = 4 −1 → 𝐵𝑇 =
−3 −1 6
7 6
▪ Step 1: the first non zero entry in row 1 should be 1→ divide row 1 by 4
𝑅1
5 3 1
4 5 −6 1 4 1 −
7 −3 0 8 4 2 4
7 −3 0 8
▪ Step 2: the first entries in below rows should be zeros → subtract 7 Row1 from Row 2
5 3 1
5 3 1
1 𝑅2−7𝑅1 1 4
−
2 4
−
4 2 4 47 21 25
7 −3 0 8 0 −
4 2 4
▪ Step 3: the second entry in row 2 should be 1
5 3 1 47 𝟓 𝟑 𝟏
1 − 𝑅 /− 𝟏 −
4 2 4 2 4 𝟒 𝟐 𝟒
𝑺𝑻𝑶𝑷
47 21 25 𝟒𝟐 𝟐𝟓
0 𝟎 𝟏 −
4 2 4 𝟒𝟕 𝟒𝟕
Content
▪ General properties of matrices
▪ Arithmetic operation on matrices
▪ Transpose of a Matrix
▪ Row echelon form
▪ Rank of a matrix
▪ The inverse of a square matrix
▪ Solving of linear system of equations
▪ By using inverse matrix
▪ By Gaussian Elimination
▪ The eigenvalues and eigenvectors problem
▪ Matrix partitioning (block decomposition)
Rank of a matrix
▪ The rank of 𝑚 × 𝑛 matrix 𝐀 is denoted by 𝑟𝑎𝑛𝑘 𝐀
▪ 𝑟𝑎𝑛𝑘 𝐀 ≤ min(𝑚, 𝑛)
▪ 𝑟𝑎𝑛𝑘 𝐀 = 𝑟𝑎𝑛𝑘(𝐀𝐓)
▪ Method 2: the number leading coefficients in the echelon form (see slides 16 and 17)
▪ Method 3: Equal to the dimension of the largest square sub-matrix of A that has a non-zero
determinant. 18
Rank of a matrix: Example
▪ 𝑟𝑎𝑛𝑘 C ≤ min(𝑚, 𝑛) ≤ 4
▪ 𝑟𝑎𝑛𝑘 C can be found by:
▪ Method 2: the number leading coefficients in the echelon form
19
Content
▪ General properties of matrices
▪ Arithmetic operation on matrices
▪ Transpose of a Matrix
▪ Row echelon form
▪ Rank of a matrix
▪ The inverse of a square matrix
▪ Solving of linear system of equations
▪ By using inverse matrix
▪ By Gaussian Elimination
▪ The eigenvalues and eigenvectors problem
▪ Matrix partitioning (block decomposition)
20
The inverse of a square matrix
▪ An 𝑛 × 𝑛 matrix 𝐀 is said to be nonsingular or invertible if there
exists a matrix 𝐵 such that 𝐀𝐁 = 𝐁𝐀 = 𝐈
▪ 𝒂𝒅𝒋(𝐀) is the adjoint matrix of 𝐀 and it is defined as the transpose of the matrix
of the signed minor determinant corresponding to the elements of 𝐀
1+𝑛 𝑀 𝑻
+𝑀11 −𝑀12 ⋯ −1 1𝑛
−𝑀21 +𝑀22 ⋯ −1 2+𝑛𝑀
2𝑛
𝒂𝒅𝒋 𝐀 = ⋮ ⋮ ⋱ ⋮
−1 𝑛+1𝑀𝑛1 −1 𝑛+2𝑀𝑛2 ⋯ −1 𝑛+𝑛 𝑀
𝑛𝑛
▪ 𝐶𝑖𝑗 = −1 𝑖+𝑗 𝑀𝑖𝑗 is the signed minor determinant (see chapter 6) and is called cofactor
22
The inverse of a square matrix
4 -3
Example 1: Find the inverse of : 𝐀 = and check your answer
-𝟐 5
𝟏
𝐀−𝟏 = 𝒂𝒅𝒋(𝐀)
𝒅𝒆𝒕(𝐀)
23
The inverse of a square matrix
Example 2: Find the inverse of : and check your answer
24
Content
▪ General properties of matrices
▪ Arithmetic operation on matrices
▪ Transpose of a Matrix
▪ Row echelon form
▪ Rank of a matrix
▪ The inverse of a square matrix
▪ Solving of linear system of equations
▪ By using inverse matrix
▪ By Gaussian Elimination
▪ The eigenvalues and eigenvectors problem
▪ Matrix partitioning (block decomposition)
25
Solving of linear system of equations
using inverse matrix
𝑎11 𝑥 + 𝑎12 𝑦 + 𝑎13 𝑧 = 𝑏1 ▪ Example 1:
▪ A linear system: 𝑎21 𝑥 + 𝑎22 𝑦 + 𝑎23𝑧 = 𝑏2
𝑎31 𝑥 + 𝑎32 𝑦 + 𝑎33𝑧 = 𝑏3 ▪ Use the inverse of
matrix to solve:
𝑿 = 𝑨−𝟏 ∙ 𝑩
26
Solving of linear system of equations
using inverse matrix
𝑥 + 2 𝑦 + 3 𝑧 = −4
b. 4 𝑥 + 5𝑧 = −11
6 𝑥 − 7 𝑦 + 𝑧 = −11
27
Solving of linear system of equations
using Gaussian Elimination
𝑎11 𝑥 + 𝑎12 𝑦 + 𝑎13 𝑧 = 𝑏1
▪ A linear system: 𝑎21 𝑥 + 𝑎22 𝑦 + 𝑎23𝑧 = 𝑏2
𝑎31 𝑥 + 𝑎32 𝑦 + 𝑎33𝑧 = 𝑏3
𝒂𝟏𝟏 𝒂𝟏𝟐 𝒂𝟏𝟑 𝒃𝟏
can be represented by the augmented matrix: 𝒂𝟐𝟏 𝒂𝟐𝟐 𝒂𝟐𝟑 𝒃𝟐
𝒂𝟑𝟏 𝒂𝟑𝟐 𝒂𝟑𝟑 𝒃𝟑
▪ Transform this augmented matrix to row echelon form matrix using the Elementary row operations (see slides
14, 15 and 16)
1 𝑑12 𝑑13 𝑐1
0 1 𝑑23 𝑐2
0 0 1 𝑐3
▪ This form gives the following linear system:
𝑥 + 𝑑12 𝑦 + 𝑑13 𝑧 = 𝑐1
𝑦 + 𝑑23𝑧 = 𝑐2
𝑧 = 𝑐3
▪ By back substitution we obtain the solution:
𝑧 = 𝑐3
𝑦 + 𝑑23 𝑐3 = 𝑐2 → 𝑦 = 𝑐2 − 𝑑23𝑐3
𝑥 + 𝑑12 𝑐2 − 𝑑23𝑐3 + 𝑑13 𝑐3 = 𝑐1 → 𝑥 = 𝑐1 − 𝑑12 𝑐2 − 𝑑23𝑐3 − 𝑑13 𝑐3
28
Solving of linear system of equations
using Gauss-Jordan Elimination
𝑎11 𝑥 + 𝑎12 𝑦 + 𝑎13 𝑧 = 𝑏1
▪ A linear system: 𝑎21 𝑥 + 𝑎22 𝑦 + 𝑎23𝑧 = 𝑏2
𝑎31 𝑥 + 𝑎32 𝑦 + 𝑎33𝑧 = 𝑏3
𝑎11 𝑎12 𝑎13 𝑏1
can be represented by the augmented matrix: 𝑎21 𝑎22 𝑎23 𝑏2
𝑎31 𝑎32 𝑎33 𝑏3
▪ Transform this augmented matrix to reduced-row echelon form matrix using the
Elementary row operations (see slides 14, 15 and 16)
𝟏 𝟎 𝟎 𝒄𝟏
Example on
𝟎 𝟏 𝟎 𝐜𝟐
reduced-row echelon form
𝟎 𝟎 𝟏 𝒄𝟑
▪ This form gives the solution of the linear system:
𝑥 = 𝑐1
𝑦 = 𝑐2
𝑧 = 𝑐3
▪ No need to back substitution
29
Example 2:
2𝑥 + 6 𝑦 + 𝑧 = 7
• Find the solution of: 𝑥 + 2𝑦 − 𝑧 = −1 using:
5 𝑥 + 7 𝑦 − 4𝑧 = 9
a. Gaussian Elimination (row echlon form)
b. Gauss-Jordan elimination (reduced row echlon form)
30
31
32
9
33
34
Modify the matrix from row echlon form to row-reduced echlon form
35
Content
▪ General properties of matrices
▪ Arithmetic operation on matrices
▪ Transpose of a Matrix
▪ Row echelon form
▪ Rank of a matrix
▪ The inverse of a square matrix
▪ Solving of linear system of equations
▪ By using inverse matrix
▪ By Gaussian Elimination
▪ The eigenvalues and eigenvectors problem
▪ Matrix partitioning (block decomposition)
36
The eigenvalues and eigenvectors problem
▪ Let 𝐀 be 𝑛 × 𝑛 matrix, a number 𝜆 is the eigenvalue of 𝐀 if there exists a non-zero solution vector 𝐗 = 𝑲 of
the linear system
𝐀∙ 𝑿=𝝀 𝑿
Or 𝐀 − 𝝀 𝑰 𝑿 = 𝟎
▪ As we are searching for non-Trivial solutions 𝐗 ≠ 𝟎, the system has this solution if:
𝐝𝐞𝐭 𝐀 − 𝝀 𝑰 = 𝟎 (characteristic equation of A)
▪ Application of eigenvalue:
▪ Differential equations
▪ Communication systems: the theoretical limit of communication channel capacity or steady state of
Markov chains
▪ Wherever there are vibrations, there are eigenvalues, the natural frequencies of the vibrations.
▪ When engineers design structures, they are concerned with the frequencies of vibration of the
structure. (Designing bridges for
example) 37
Find the eigenvalues and eigenvectors of a
matrix
▪ If the eigenvector 𝑿 = 𝑲 is given:
▪ We find 𝐀 ∙ 𝑲
▪ It should be in the form 𝝀𝑲 → 𝝀 is an eigenvalue
▪ General case:
▪ Find First the eigenvalues: Find the roots of det A − 𝜆 𝐼 = 0
▪ For each eigenvalue 𝝀 : Find the solution of A − 𝜆 𝐼 𝑋 = 0 (using Gauss-Jordan for
example), The solution of the X = 𝑲 is the eigenvector corresponding to 𝜆
38
Example 1:
39
Example 2:
40
Example 2:
41
0
42
0
43
44
45
Content
▪ General properties of matrices
▪ Arithmetic operation on matrices
▪ Transpose of a Matrix
▪ Row echelon form
▪ Rank of a matrix
▪ The inverse of a square matrix
▪ Solving of linear system of equations
▪ By using inverse matrix
▪ By Gaussian Elimination
▪ The eigenvalues and eigenvectors problem
▪ Matrix partitioning (block decomposition)
46
Matrix partitioning
▪ A matrix 𝐀 can be partitioned into smaller matrices called block or submatrix
▪ The partition is indicated by horizontal lines between the rows and vertical lines between the
columns.
row vector
a11 a12 a13 a14 column vector
a11 a14 r1
A = a 21 a 22 a 23 a 24 = c1 c 2 c3 c 4
a12 a13
A = a 21 a22 a23 a24 = r2
a31 a32 a33 a 34
a31 a32 a33 a34 r3
submatrix
a11 a12 a13 a14
A11 A12
A = a21 a22 a23 a24 =
A21 A22
a31 a32 a33 a34
47
Block multiplication
Let 𝐀 be an 𝑚 × 𝒏 matrix and 𝐁 an 𝒏 × 𝑝 matrix
48
Block multiplication
Let 𝐀 be an 𝑚 × 𝒏 matrix and 𝐁 an 𝒏 × 𝑝 matrix
▪ In general we may decompose 𝐀 and 𝐁
With
▪𝐀𝟏𝟏 is a 𝑟 × 𝑠 matrix ▪𝐁𝟏𝟏 is a s × 𝑞 matrix
▪𝐀𝟏𝟐 is a 𝑟 × (𝑛 − 𝑠) matrix ▪𝐁𝟏𝟐 is a s × (𝑝 − 𝑞) matrix
▪𝐀𝟐𝟏 is a (𝑚 − 𝑟) × 𝑠 matrix ▪ 𝐁𝟐𝟏 is a (𝑛 − 𝑠) × 𝑞 matrix
▪𝐀𝟐𝟐 is a(𝑚 − 𝑟) × (𝑛 − 𝑠) matrix ▪𝐁𝟐𝟐 is a(𝑛 − 𝑠) × (𝑝 − 𝑞) matrix