Linear Algebra
Linear Algebra
Reda S Tantawi
Contents
Introduction 1
Determinants 3
Properties of Determinants 3
Value of a determinant 5
The upper triangular form of a determinant 8
Cramer’s Rule 11
Matrices 14
Special Matrices 15
Mathematical operations on Matrices 16
Invertible matrices 19
Systems of linear equations and matrix equation 21
The augmented matrix for a system of linear equations 21
Matrix Solution of Linear System of equations 23
Gauss-Elimination method 23
Gauss – Jordan Elimination method 28
Inverse of matrices 31
The inverse of a matrix using the elementary row operations 31
The inverse of a matrix and determinants 32
Invertible matrices method 35
LU - decomposition method 38
Iterative methods 47
Jaccobi method 47
Gauss - Seidel method 51
Eigenvalues and eigenvectors of a square matrix 56
0
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
Introduction
Linear algebra is the branch of mathematics concerning linear equations and functions. Linear
algebra is one of the corner stones of computational mathematics. such as Almost all numerical
schemes such as the finite element and finite difference methods are in fact techniques that
transform, assemble, reduce, rearrange, and/or approximate the differential, integral, or other types
of equations to systems of linear algebraic equations.
Solving a system of linear algebraic equations is equivalent to finding the intersection point(s) of
all surfaces (lines), represented by these equations, in a space of dimension equals the number of
the given equations. If all surfaces happen to pass through a single point, then the solution is
unique. If the intersected part is a line or a surface, there are an infinite number of solutions.
Otherwise, the solution does not exist.
Systems of Linear Equations
A system of 𝑛 linear equations in 𝑛 unknowns 𝑥1 , 𝑥2 , ⋯ , 𝑥𝑛 is a set of equations of the form:
𝑎11 𝑥1 + 𝑎12 𝑥2 + ⋯ + 𝑎1𝑛 𝑥𝑛 = 𝑏1
𝑎21 𝑥1 + 𝑎22 𝑥2 + ⋯ + 𝑎2𝑛 𝑥𝑛 = 𝑏2
(1)
⋮
𝑎𝑛1 𝑥1 + 𝑎𝑛2 𝑥2 + ⋯ + 𝑎𝑛𝑛 𝑥𝑛 = 𝑏𝑛 }
where 𝑎𝑖𝑗 , 𝑏𝑗 are real numbers.
This system of equations is called homogeneous if 𝑏𝑗 = 0 for all 𝑗 = 1,2, ⋯ , 𝑛 and non-
homogeneous otherwise.
Possibility of solving a system of linear equations:
For a system of non-homogeneous linear equations:
(1) the system has a single (unique) solution.
(2) the system has an infinite number of solutions.
(3) the system has no solution at all.
For a system of homogeneous linear equations:
(1) the system has only the trivial solution (zeros);
(2) the system has an infinite number of solutions.
A system of linear equations is called consistent if it has at least one solution and inconsistent
if it has no solution.
1
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
There are two techniques for solving a system of linear algebraic equations: One of them
depends on the matrices and determinants algebra, and the other depends on iterations with starting
estimates for the solution.
2
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
Determinants
A determinant consists of elements listed in rows and columns of the same number between
two vertical lines, the number of rows (or columns) is the order of the determinant. The
determinant is denoted by |𝐴|, |𝐵|, |𝐶|, ⋯. The determinants have many beneficial properties for
studying vector spaces, matrices, and systems of equations.
The determinant consists of n rows is of order 𝑛 × 𝑛 or simply we can say of order 𝑛.
For examples:
𝑎11 𝑎12 𝑎13
𝑎11 𝑎12
|𝐴| = |𝑎11 | of order 1, |𝐴| = | | of order 2, |𝐴| = |𝑎21 𝑎22 𝑎23 | of order
𝑎21 𝑎22
𝑎31 𝑎32 𝑎33
𝑎11 𝑎12 ⋯ 𝑎1𝑛
Determinants have many applications. In our present study we are going to use the determinants
to solve system of linear algebraic equations (Cramer’s Rule), to evaluate the eigenvalues and
eigenvectors of square matrix, and finally, to find the inverse of a square matrix.
Properties of Determinants
The properties of determinants can be very useful, they are complicated to prove.
(1) If we interchange all the rows and the columns, the value of the determinant does not change.
4 7 −1 4 2 −5
|2 −3 4 |=| 7 −3 1|
−5 1 −1 −1 4 −1
(2) If we interchange any two rows (or columns), then sign of the determinant changes.
4 7 −1 4 7 −1 7 4 −1
|2 −3 4 | = − |−5 1 −1| = − |−3 2 4|
−5 1 −1 2 −3 4 1 −5 −1
(3) If any two rows or any two columns in a determinant are identical (or proportional), then
the value of the determinant is zero.
3
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
2 −8 6 8 2 −8 6 8 2 4 6 4
|3 −9 5 10| |3 −9 5 10| |3 6 5 10|
= 0, = 0, =0
|2 −8 6 8| |0 4 1 2| |2 4 7 8|
1 −4 0 6 6 −24 18 24 1 2 0 6
(4) Multiplying a determinant by k means multiplying the elements of only one row (or one
column) by 𝑘.
4 7 −1 20 35 −5 4 7 −1 20 7 −1
5×| 2 −3 4 |=| 2 −3 4 | = | 10 −15 20 | = | 10 −3 4|
−5 1 −1 −5 1 −1 −5 1 −1 −25 1 −1
4 35 −1
=| 2 −13 4|
−5 5 −1
Similarly, we can take a common factor from elements of a row (or column):
4 12 20 1 3 5 2 12 4
|𝐴| = |2 −3 5 | = 4 × |2 −3 5 | = 2 × 5 × |1 −3 1|
0 1 10 0 1 10 0 1 2
1 6 2
= 2 × 5 × 2 |1 −3 1|
0 1 2
(5) If to each element of a row (or a column) of a determinant the equimultiples of corresponding
elements of other rows (columns) are added, then value of determinant remains same.
2 −8 6 8 2 −8 6 8
|3 −9 5 10| −𝑅1 + 𝑅2 |1 −1 −1 2|
|𝐴| = → |𝐴| =
|1 −2 2 0 | −𝑅1 + 𝑅4 |1 −2 2 0|
1 −4 0 6 −1 4 −6 −2
2 −8 6 8 2 −8 6 8
|3 −9 5 10| 𝑅1 + 𝑅2 |5 −17 11 18|
|𝐵| = → |𝐵| =
|1 −2 2 0 | 2𝑅1 + 𝑅3 |5 −18 14 16|
1 −4 0 6 1 −4 0 6
4
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
Value of a determinant
- The value of a determinant of order 1 is given as: |𝐴| = |𝑎11 | = 𝑎11
∴ |𝐴| = |5| = 5, |𝐴| = |−5| = −5
- The value of a determinant of order 2 is given as:
𝑎11 𝑎12
|𝐴| = | | = 𝑎11 × 𝑎22 − 𝑎12 × 𝑎21
𝑎21 𝑎22
5 2 2 −4
∴ | | = 5 × 3 − 2 × 8 = −1, | | = 2 × 3 − (−4) × 6 = 30
8 3 6 3
- Evaluation of the value of a determinant of order ≥ 3 needs to know minors and cofactors of
the elements of a determinant.
Minor of the element 𝑎𝑖𝑗 of a determinant |𝐴| is the determinant obtained by deleting ith row
and jth column, and it is denoted by 𝑀𝑖𝑗 .
Cofactor of the element 𝑎𝑖𝑗 of a determinant |𝐴| is given by 𝐴𝑖𝑗 = (−1)𝑖+𝑗 𝑀𝑖𝑗 , the sign of
(−1)𝑖+𝑗 is called sign of the element 𝑎𝑖𝑗 (which is positive if the sum of the numbers of the row
and the column of the element is even, and negative if this sum is odd).
2 1 −2
For example, the minors of the determinant: |𝐴| = | 3 5 0 | are:
−4 8 3
5 0 3 0
𝑀11 = | | = 15 − 0 = 15, 𝑀12 = | | = 9 − 0 = 9,
8 3 −4 3
3 5 1 −2
𝑀13 = | | = 24 + 20 = 44, 𝑀21 = | | = 3 + 16 = 19,
−4 8 8 3
2 −2 2 1
𝑀22 = | | = 6 − 8 = −2, 𝑀23 = | | = 16 + 4 = 20,
−4 3 −4 8
1 −2 2 −2
𝑀31 = | | = 0 + 10 = 10, 𝑀32 = | | = 0 + 6 = 6,
5 0 3 0
2 1
𝑀33 = | | = 10 − 3 = 7.
3 5
The cofactors of |𝐴| are:
𝐴11 = (−1)2 𝑀11 = 15, 𝐴12 = (−1)3 𝑀12 = −9, 𝐴13 = (−1)4 𝑀13 = 44,
𝐴21 = (−1)3 𝑀21 = −19, 𝐴22 = (−1)4 𝑀22 = −2, 𝐴23 = (−1)5 𝑀23 = −20,
5
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
𝐴31 = (−1)4 𝑀31 = 10, 𝐴32 = (−1)5 𝑀32 = −6, 𝐴33 = (−1)6 𝑀33 = 7.
The value of a determinant of order ≥ 3 can be obtained by the sum of products of all elements of
a row (or a column) with the corresponding co-factors (we can use any row or any column). That
is,
|𝐴| = ∑𝑖 𝐴𝑖𝑗 for any row j, or
|𝐴| = ∑𝑗 𝐴𝑖𝑗 for any column j.
This method is called ‘expansion of the determinant’.
𝑎11 𝑎12 𝑎13
Therefore, the value of |𝐴| = |𝑎21 𝑎22 𝑎23 | is:
𝑎31 𝑎32 𝑎33
(a) Using the first row, we have
+ − +
𝑎11 𝑎12 𝑎13
𝑎22 𝑎23 𝑎21 𝑎23 𝑎21 𝑎22
|𝐴| = |𝑎21 𝑎22 |
𝑎23 = 𝑎11 | | − 𝑎12 | | + 𝑎13 | |
𝑎32 𝑎33 𝑎31 𝑎31 𝑎31 𝑎32
𝑎31 𝑎32 𝑎31
(b) Using the third column, we have
+
𝑎11 𝑎12 𝑎13
−
𝑎21 𝑎22 𝑎11 𝑎12 𝑎11 𝑎12
|𝐴| = |𝑎21 𝑎22 𝑎23 | = 𝑎13 | | − 𝑎23 | | + 𝑎33 | |
+
𝑎31 𝑎32 𝑎31 𝑎32 𝑎21 𝑎22
𝑎31 𝑎32 𝑎33
Note that the results we obtained by using the first row and the third column are the same.
Remarks:
1- If all the elements of a row (or column) are zeros, then we can use the co-factors of this row (or
column) foe which the value of the determinant must be zero.
2- When expanding by cofactors, you do not need to evaluate the cofactors of zero entries, because
a zero entry times its cofactor is zero. So that, the row (or column) containing the most zeros is
usually the best choice for expansion by cofactors.
2 1 −2
Example 1: Find the value of the determinant: |𝐴| = | 3 5 0|
−4 8 3
6
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
Solution:
(a) Using the first row, we have:
+ − +
2 1 −2
5 0 3 0 3 5
|𝐴| = | 3 5 0 | = 2 | | − 1| | + (−2) | |
8 3 −4 3 −4 8
−4 8 3
= 2(5 × 3 − 0) − (9 − 0) + (−2)(24 + 20) = −67
(b) Using the third column, we have:
+
2 1 −2
− 3 5 2 1
|𝐴| = | 3 5 0 | = −2 | | − 0 + 3| |
+ −4 8 3 5
−4 8 3
= −2(24 + 20) + 3(10 − 3) = −67
Note that the results we obtained by using the first row and the third column are the same.
7
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
| 0 𝑎22 ⋯ ⋯ 𝑎2𝑛 |
|𝐴| = 0 0 ⋱ ⋯ ⋮ = 𝑎11 × 𝑎22 × 𝑎33 × ⋯ × 𝑎𝑛𝑛
| ⋮ ⋮ ⋮ ⋱ ⋮ |
0 0 ⋯ ⋯ 𝑎𝑛𝑛
We can obtain the triangular form of a determinant by applying the properties of the determinants,
as we will see in the following.
We will use a symbolic shorthand to describe these row operations:
1. 𝑅𝑖 ↔ 𝑅𝑗 : Interchanging the rows 𝑖 and 𝑗, then sign of the determinant changes.
2. 𝛼 cf 𝑅𝑖 : Taking 𝛼 as common factor from row 𝑖.
3. 𝛼𝑅𝑖 + 𝑅𝑗 : Multiply row 𝑖 by the scalar 𝛼 and add to row 𝑗.
The above statements are called elementary row operations.
Example 1:
Find the upper triangular form of the determinant, and then find its value:
4 2 3
|𝐴| = | 2 0 2|
−1 4 5
8
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
Solution:
4 2 3 −1 4 5 −1 4 5
𝑅1 ↔ 𝑅3 2𝑅1 + 𝑅2 → 𝑅2
|𝐴| = | 2 0 2| → −| 2 0 2| → −| 0 8 12|
4𝑅1 + 𝑅3 → 𝑅3
−1 4 5 4 2 3 0 18 23
18 −1 4 5
− 𝑅2 + 𝑅3 → 𝑅3
8
→ −| 0 8 12 | = −(−1)(8)(−4) = −32
0 0 −4
Example 2:
Find the upper triangular form of the determinant, then find its value.
2 3 1 0 −5 6 0 0
|1 4 4 6| |0 1 −1 2|
(𝑖)|𝐴| = (ii)|𝐵| =
|3 1 0 3| |−3 4 −5 1|
5 8 2 6 1 6 0 3
Solution:
We apply the operations on the determinant as follows:
2 3 1 0 1 4 4 6
−2𝑅1 +𝑅2
|1 4 4 6| 𝑅1 ↔ 𝑅2 |2 3 1 0| −3𝑅1+𝑅3
(𝑖)|𝐴| = → − →
|3 1 0 3| |3 1 0 3| −5𝑅1+𝑅4
5 8 2 6 5 8 2 6
1 4 4 6
1 4 4 6
11
−12| 5 𝑅2 + 𝑅3 → 𝑅3
− |0 −5 −7 −12|
|0 −5 −7 17 57
− → − 0 0
|0 −11 −12 −15| − 12 𝑅2 + 𝑅4 → 𝑅4 5 5 |
5 |
6 24
0 −12 −18 −24 0 0 −
5 5
1 4 4 6
6
𝑅 + 𝑅4 → 𝑅4 |0 −5 −7 −12|
17 3 17 57
→ − 0 0 = 150
| 5 5 |
150
0 0 0
17
9
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
−5 6 0 0
−5 6 0 0
3 1
− 𝑅1 + 𝑅3 → 𝑅3 |0 1 −1 2| 𝑐𝑓 𝑅3
|0 1 −1 2| 5 2 5
(ii) |𝐵| = → 0 −5 1 →
|−3 4 −5 1| 1
𝑅1 + 𝑅4 → 𝑅4 5 1
𝑐𝑓𝑅4
5 | | 5
36
1 6 0 3 0 0 3
5
−5 6 0 0 −5 6 0 0
1 |0 1 −1 2 | −2𝑅2 + 𝑅3 → 𝑅3 1 | 0 1 −1 2 |
→
25 | 0 2 −25 5 | −36𝑅2 + 𝑅4 → 𝑅4 25 | 0 0 −23 1 |
0 36 0 15 0 0 36 −57
−5 6 0 0
36
𝑅 + 𝑅4 → 𝑅4 1 |0 1 −1 2 |
23 3
→
25 | 0 0 −23 1 |
−1275
0 0 0
23
1 −1275
= [−5 × 1 × (−23) × ( )] = −255
25 23
Example 3:
Find the upper triangular form of the determinant, and then find its value:
1 2 1 4
|4 2 5 0|
|𝐴| =
|3 0 3 3|
1 4 1 5
Solution:
1 2 1 4 1 2 1 4
−4𝑅1 +𝑅2
|4 2 5 0| −3𝑅1 +𝑅3 |0 −6 1 −16|
|𝐴| = →
|3 0 3 3| −𝑅1+𝑅4 |0 −6 0 −9 |
1 4 1 5 0 2 0 1
1 2 1 4 1 2 1 4
1
−𝑅2 + 𝑅3 |0 −6 1 −16| 𝑅3 + 𝑅4 0 −6 1 −16|
3 |
→ → = −12
1
𝑅2 + 𝑅4 |0 0 −1 7 | |0 0 −1 7 |
3 1 −13
0 0 0 0 0 −2
3 3
10
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
Cramer’s Rule:
Cramer’s rule, named after Gabriel Cramer (1704–1752), is a formula that uses determinants to
solve a system of algebraic linear equations. According to Cramer’s rule, if the system of n linear
equations (1) has a nonzero coefficient determinant, that is the determinant Δ of coefficient of the
unknowns 𝑥1 , 𝑥2 , … , 𝑥𝑛 , i.e.,
𝑎11 𝑎12 ⋯ 𝑎1𝑛
where:
𝑏1 𝑎12 ⋯ 𝑎1𝑛 𝑎11 𝑏1 ⋯ 𝑎1𝑛
| 𝑏2 𝑎22 ⋯ 𝑎2𝑛 | |𝑎21 𝑏2 ⋯ 𝑎2𝑛 |
Δ𝑥1 = , Δ𝑥2 = , and so on.
|⋮ ⋮ ⋱ ⋮ | | ⋮ ⋮ ⋱ ⋮ |
𝑏𝑛 𝑎𝑛2 ⋯ 𝑎𝑛𝑛 𝑎𝑛1 𝑏𝑛 ⋯ 𝑎𝑛𝑛
Example 1: Using Cramer’s rule, discuss the possibility of solving the equations.
𝑥 + 𝑦 = 3, 4𝑥 − 𝑦 = 2
11
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
12
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
3 5 −3
Δ𝑥 = | 2 −2 1 | = 3(6 − 4) − 5(−6 + 4) − 3(8 − 8) = 16 ≠ 0
−4 4 −3
Thus, the given system has no solution.
Example 4:
Using Cramer’s rule, discuss the possibility of solving the equations.
2𝑥 + 𝑦 + 5𝑧 = 0, − 2𝑥 + 𝑦 − 3𝑧 = 0, 2𝑥 − 𝑦 = 0
Solution: We have a homogeneous system of three equations.
2 1 5
Δ = |−2 1 −3| = 2(0 − 3) − (0 + 6) + 5(2 − 2) = −12 ≠ 0
2 −1 0
Thus, the given system has only trivial solution, 𝑥 = 0, 𝑦 = 0, 𝑧 = 0
Exercise:
1. Expand each of the following determinants (Find the value of the determinant):
3 0 −4 0
2 3 −2 −4 7 1
|0 8 1 2|
(𝑖)|𝐴| = |0 1 2| (𝑖𝑖)|𝐵| = | 5 0 3| (𝑖𝑖𝑖)|𝐶| =
|6 1 8 0|
1 0 −1 2 0 −1
0 0 0 1
2. Find the upper triangular formula of each of the following determinants, then find its value.
1 0 1 4 2 2 1 4
|4 2 6 2| |4 2 0 2|
(𝑖)|𝐴| = (ii)|𝐵| =
|3 0 3 9| |0 0 3 4|
1 4 1 5 1 4 1 5
3. Using Cramer’s rule, find the solution of the following equations:
i) − 2 𝑥 + 3𝑦 − 5𝑧 = −11, 4𝑥 − 𝑦 + 𝑧 = −3, − 𝑥 − 4𝑦 + 6𝑧 = 15
ii) 5 𝑥 − 2𝑦 + 𝑧 = 15, 3 𝑥 − 3𝑦 − 𝑧 = −7, 2 𝑥 − 𝑦 − 7𝑧 = 3
iii) 3 𝑥 + 2𝑦 + 8𝑧 = 38, 𝑥 + 3𝑦 + 9𝑧 = 37, 2 𝑥 + 𝑦 + 𝑧 = 15
iv) 𝑥 + 2𝑧 = 1, 3𝑥 − 𝑦 + 𝑧 = 2, 4𝑦 + 5𝑧 = −1
v) 4𝑥 + 2𝑦 − 𝑧 = 5, 3𝑥 − 𝑦 + 𝑧 = −2, 𝑥 + 𝑦 − 𝑧 = 0
13
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
Matrices
The importance of matrices has increased because of the human need to display and classify data
and store information, as well as to deal with that data in the form of tables, and that organizing
the information in a specific way facilitates quick memory and comparison between them. The
importance of arrays increased with the use of the computer and its ability to perform long
mathematical operations in a short time. The important role of matrices is not limited to
mathematics only, but also plays a large role in other sciences such as engineering, physics,
chemistry, and others.
A matrix is an array of elements arranged in rows and columns. The numbers that make up a
matrix are called the elements of a matrix, and these elements are written in parentheses on the
figure or on the figure ( ) . A matrix having m rows and n columns is said to have the
order 𝑚 × 𝑛. Usually, we denote the matrix by one of the capital letters, such as A, B, C, ⋯ and
we denote the elements of a matrix A by the symbol 𝑎𝑖𝑗 where i denotes the row number the
element is in and j refers to the column number.
Hence a matrix 𝐴 of order 𝑚 × 𝑛 can be represented in the following forms:
A matrix having only one column is called a column vector; and a matrix with only one row is
called a row vector and are often written in Boldface lowercase letters.
A (general) row vector is of the form 𝒂 = [𝑎1 𝑎1 ⋯ 𝑎𝑛 ] and a column vector is of the
form
𝑏1
𝑏2
𝒃=
⋮
[ 𝑏𝑛 ]
Equality of two Matrices: Two matrices A and B having the same order 𝑚 × 𝑛 are equal if 𝑎𝑖𝑗 =
𝑏𝑖𝑗 for each 𝑖 = 1, 2, ⋯ , 𝑚 and 𝑗 = 1, 2, ⋯ , 𝑛. In other words, two matrices are said to be equal if
14
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
they have the same order and their corresponding elements are equal.
Special Matrices:
1. A matrix in which all elements are zeros is called a zero-matrix, denoted by [0]. For example,
0 0
0 0 0 0 0
[0]2×2 = [ ], [0]2×3 = [ ], [0]3×2 = [0 0]
0 0 0 0 0
0 0
2. A matrix having the number of rows equal to the number of columns is called a square matrix.
Thus, its order is 𝑛 × 𝑛 or 𝑛 only. That is,
𝑎11 𝑎12 ⋯ 𝑎1𝑛
𝑎21 𝑎22 ⋯ 𝑎2𝑛
𝐴=
⋮ ⋮ ⋱ ⋮
[𝑎𝑛1 𝑎𝑛2 ⋯ 𝑎𝑛𝑛 ]
where the elements 𝑎11 , 𝑎22 , 𝑎33 , ⋯ , 𝑎𝑛𝑛 are called the diagonal elements and form the principal
(main) diagonal of 𝐴. The sum of the diagonal elements is called trace of the matrix;
𝑇𝑟(𝐴) = 𝑎11 + 𝑎22 + 𝑎33 + ⋯ + 𝑎𝑛𝑛
3. A square matrix 𝐴 is said to be a diagonal matrix if aij = 0 for all 𝑖 ≠ 𝑗 but non-zero
15
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
2. Addition and subtraction of matrices: To add (or subtract) two matrices A and B, they must
be of the same order. If A and B are two matrices of the same order 𝑚 × 𝑛, then 𝐶 = 𝐴 ± 𝐵 gives
a matrix of the same order 𝑚 × 𝑛 such that each element of 𝐶 is the sum of the corresponding
elements of A and B. For examples:
1 0 3 0
i) If 𝐴 = [−3 2] , 𝐵 = [ 5 7]
5 1 −5 6
1 0 3 0 4 0
∴ 𝐴 + 𝐵 = [−3 2] + [ 5 7] = [ 2 9],
5 1 −5 6 0 7
1 0 3 0 −2 0
𝐴 − 𝐵 = [−3 2] − [ 5 7] = [−8 −5]
5 1 −5 6 10 −5
16
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
2 3 0 3 0 0
ii) If 𝐴 = [−1 4 0] , 𝐵 = [2 0 −1], then
3 2 1 4 2 1
2 3 0 3 0 0 1 0 0 4 3 0
𝐴 + 𝐵 − 𝐼 = [−1 4 0] + [2 0 −1] − [0 1 0] = [1 3 −1]
3 2 1 4 2 1 0 0 1 7 4 1
2 3 0 6 0 0 3 0 0 −1 3 0
𝐴 − 2𝐵 + 3𝐼 = [−1 4 0] − [4 0 −2] − [0 3 0] = [−5 7 2]
3 2 1 8 4 2 0 0 3 −5 −2 2
3. Multiplication of matrices: The product AB of two matrices A and B is defined if and only if
the number of columns of A = the number of rows of B. Consider a matrix A of order 𝑚 × 𝑟 and
a matrix B of order 𝑟 × 𝑛, then If 𝐶 = 𝐴𝐵
𝑟
Remarks:
(a) Suppose that the matrix product AB is defined (available). Then the product BA need not be
defined.
(b) Suppose that the matrix products 𝐴𝐵 and 𝐵𝐴 are defined, it is not necessary that 𝐴𝐵 = 𝐵𝐴.
For examples:
1
i). If 𝒂 = [3] , 𝒃 = [2 3 4]
2
1 1×2 1×3 1×4 2 3 4
∴ 𝒂𝒃 = [3] [2 3 4] = [ 3 × 2 3×3 3 × 4] = [6 9 12] ,
2 2×2 2×3 2×4 4 6 8
1
𝒃𝒂 = [2 3 4] [3] = [ 2 × 1 + 3 × 3 + 4 × 2] = [19]
2
Note that even the products ab and ba are available, the results of the product are different.
17
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
1 6 3
1 3 4
ii). If 𝐴 = [ ] , 𝐵 = [0 3 5]
2 0 8
2 1 1
1 6 3
1 3 4
∴ 𝐴𝐵 = [ ] [0 3 5]
2 0 8
2 1 1
1×1+3×0+4×2 1×6+3×3+4×1 1×3+3×5+4×1
=[ ]
2×1+0×0+8×2 2×6+0×3+8×1 2×3+0×5+8×1
9 19 22
=[ ]
18 20 14
Note that the product 𝐵𝐴 is not available (defined).
1 −1
−1 0
iii) If 𝐴 = [0 3 ] and 𝐵 = [ ], then
2 1
2 4
1 −1 1 × (−1) − 1 × 2 −1 × 0 − 1 × 1 −3 −1
−1 0
𝐴𝐵 = [0 3 ][ ] = [0 × (−1) + 3 × 2 0×0+3×1 ]= [ 6 3]
2 1
2 4 2 × (−1) + 4 × 2 2×0+4×1 6 4
Note that the product 𝐵𝐴 is not available (defined).
18
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
5. Determinant of a square matrix: The determinant is a function that takes a square matrix as
an input and produces a scalar as an output. The determinant of a square matrix A is denoted by
det(A) or |𝐴| (note that |𝐴| is read as determinant of A and not, as modulus of A). The elements
of |𝐴| are the same elements of the matrix A with the same order, that is:
𝑎11 𝑎12 ⋯ 𝑎1𝑚 𝑎11 𝑎12 ⋯ 𝑎1𝑚
𝑎21 𝑎22 ⋯ 𝑎2𝑚 | 𝑎21 𝑎22 ⋯ 𝑎2𝑚 |
If 𝐴= then |𝐴| =
⋮ ⋮ ⋱ ⋮ | ⋮ ⋮ ⋱ ⋮ |
[𝑎𝑚1 𝑎𝑚2 ⋯ 𝑎𝑚𝑚 ] 𝑎𝑚1 𝑎𝑚2 ⋯ 𝑎𝑚𝑚
Invertible matrices
A square matrix 𝐴 of order 𝑛 is called invertible (or nonsingular) if there exists a square matrix 𝐵
of the same order such that 𝐴𝐵 = 𝐵𝐴 = 𝐼. The matrix 𝐵 is called a multiplicative inverse of 𝐴
and is denoted by 𝐴−1 . A matrix that does not have an inverse is called noninvertible (or singular).
If 𝐴 is invertible its inverse is also invertible and gives the matrix 𝐴 itself. Moreover, if 𝐴 and 𝐵
are two invertible matrices, their product 𝐴𝐵 is also invertible, with (𝐴𝐵)−1 = 𝐵−1 𝐴−1 . It is
worth to mention that not all matrices have inverses. Non-square matrices, for example, do not
have inverses by definition. The square matrix 𝐴 has inverse if |𝐴| ≠ 0.
For examples:
4 3 −2 3
1. The matrices 𝐴 = [ ] and 𝐵 =[ ] are invertible, because,
3 2 3 −4
4 3 −2 3 1 0 −2 3
4 3 1 0
𝐴𝐵 = [ ][ ]=[ ], 𝐵𝐴 = [ ][ ]=[ ].
3 2 3 −4 0 1 3 −4 3 2 0 1
12 6 1
− −
1 2 3 11 11 11
5 3 5
2. The matrices 𝐴 = [0 4 5] and 𝐵= −
22 22 22
1 0 6 2 1 2
−
[ 11 11 11 ]
are invertible, because:
12 6 1
− −
1 2 3 11 11 11 1 0 0
5 3 5
𝐴𝐵 = [0 4 5] − = [0 1 0],
22 22 22
1 0 6 2 1 2 0 0 1
−
[ 11 11 11 ]
19
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
12 6 1
− −
11 11 11 1 2 3 1 0 0
5 3 5
𝐵𝐴 = − [0 4 5] = [0 1 0]
22 22 22
2 1 2 1 0 6 0 0 1
−
[ 11 11 11 ]
In the following subjects we will show how to find the inverse of a square matrix.
Exercises
2 −13 −3 0
1. Find 2𝐴 + 3𝐵, 𝐴 − 2𝐵 for the matrices: 𝐴=[ ], 𝐵 = [ ]
0 −12 8 5
2. Find 2𝐴 + 3𝐵 − 5𝐼, −𝐵 + 𝐼 for the matrices:
2 5 0 0 1 0
𝐴 = [1 3 1] , 𝐵 = [1 2 4]
7 −2 4 5 4 2
3. Find the product of the matrices:
3 2 1 3 1 2 1
1 3 −1 0
(𝑖) [ ][ ], (𝑖𝑖) [−2] [2 1 3], (𝑖𝑖𝑖) [−1 3 0 ] [−3 0 1]
2 4 2 1
1 4 2 −1 1 3 3
1 2 2 −1 0 3
(iv) [ ][ ]
0 1 0 3 2 −1
1 2 −1 2
3. Show that matrices 𝐴 = [ ] and 𝐵 = [ ] are invertible.
1 1 1 −1
2 −1 3 −7 −9 10
4. Show that matrices 𝐴 = [−5 3 1] and 𝐵 = [−12 −15 17 ] are invertible.
−3 2 3 1 1 −1
20
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
21
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
Remember that: Possibility of solving a system of linear equations can be recognized as:
For a homogeneous system of linear equations either
(1) the system has only the trivial solution (zeros);
(2) the system has an infinite number of solutions.
For a non-homogeneous system either
(1) the system has a single (unique) solution.
(2) the system has an infinite number of solutions.
(3) the system has no solution at all.
22
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
Example 1:
Using Gauss Elimination method, discuss the solution of the system of equations:
𝑥 + 𝑦 − 𝑧 = −2, 2𝑥 − 𝑦 + 𝑧 = 5, − 𝑥 + 2𝑦 + 2𝑧 = 1
Solution: The augmented matrix corresponding to the system is:
1 1 −1 −2
[𝐴|𝒃] = [ 2 −1 1|5]
−1 2 2 1
Now we want zeros for the elements in the first column below the pivot 1. The first zero can be
obtained by multiplying the first row by (−2) and adding the results to the second row. The second
zero can be obtained by adding the first row to the third row, note that the first row is unchanged.
We use elementary row operations to obtain the reduced form as follows:
1 1 −1 −2 1 1 −1 −2
2𝑅1 + 𝑅2 → 𝑅2
[𝐴|𝒃] = [ 2 −1 1 | 5 ]→ [0 −3 3|9]
𝑅1 + 𝑅3 → 𝑅3
−1 2 2 1 0 3 1 −1
1 1 −1 −2
𝑅2 + 𝑅3 → 𝑅3
→ [0 −3 3|9]
0 0 4 8
Thus, the system has a unique solution:
4𝑧 = 8 ⇒ 𝑧 = 2, − 3𝑦 + 3𝑧 = 9 ⇒ 𝑦 = − 1, 𝑥 + 𝑦 − 𝑧 = −2 ⇒ 𝑥 = 1
Example 2:
Using Gauss Elimination method, discuss the solution of the system of equations:
3𝑥 + 4𝑦 + 4𝑧 = 7, 𝑥 − 𝑦 − 2𝑧 = 2, 2𝑥 − 3𝑦 + 6𝑧 = 5
24
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
25
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
1 0 −3 −1 1 0 −3 −1
𝑅1 + 𝑅3 −3𝑅2 + 𝑅3
→ [0 1 −1| 0 ] → [0 1 −1| 0 ]
0 3 −3 0 0 0 0 0
We see that the elements of the third row are zeros, then the system has an infinite number of
solutions. Since the pivot of the third column is zero, then we choose 𝑧 to be the free variable
(arbitrary) and represent it by the parameter 𝑧 = 𝑐. The first and second rows give:
𝑧 = 𝑐, 𝑦 − 𝑧 = 0 ⇒ 𝑦 = 𝑐, 𝑥 − 3𝑧 = − 1, 𝑥 = 3𝑐 − 1,
where 𝑐 is any real number.
Example 5:
Using Gauss Elimination method, discuss the solution of the system of equations:
4𝑥 + 2𝑦 − 𝑧 = 5 , 3𝑥 − 𝑦 + 𝑧 = − 2, 𝑥 + 𝑦 − 𝑧 = 0
Solution: It is better to rearrange the given equations and the augmented matrix becomes:
1 1 −1 0 1 1 −1 0
−4𝑅1 + 𝑅2
[𝐴|𝒃] = [4 2 −1| 5 ] → [0 −2 3|5]
−3𝑅1 + 𝑅3
3 −1 1 −2 0 −4 4 −2
1 1 −1 0
−2𝑅2 + 𝑅3
→ [0 −2 3| 5 ]
0 0
−2 −12
13 1
∴ −2𝑧 = −12 ⇒ 𝑧 = 6, − 2𝑦 + 3𝑧 = 5 ⇒ 𝑦 = , 𝑥 + 𝑦 − 𝑧 = 0 ⇒ 𝑥 = −
2 2
Example 6:
Using Gauss Elimination method, discuss the solution of the system of equations:
5𝑥 − 2𝑦 + 𝑧 = 5 , 𝑥 − 𝑦 − 𝑧 = 0, 2𝑥 − 𝑦 + 3𝑧 = − 1
Solution: It is better to rearrange the given equations and the augmented matrix becomes:
1 −1 −1 0 1 −1 −1 0
−5𝑅1 + 𝑅2
[𝐴|𝒃] = [5 −2 1 | 5 ]→ [0 3 6|5]
−2𝑅1 + 𝑅3
2 −1 3 −1 0 1 5 −1
1 0
− 𝑅2 + 𝑅3 1 −1 −1
3
→ [0 3 6| 5 ]
3 −8/3 0 0
8 8 31 23
∴ 3𝑧 = − ⇒ 𝑧 = − , 3𝑦 + 6𝑧 = 5 ⇒ 𝑦 = , 𝑥−𝑦−𝑧 =0 ⇒ 𝑥 =
3 9 9 9
26
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
Example 7:
Using Gauss Elimination method, discuss the solution of the system of equations:
−𝑥 + 𝑦 + 𝑧 = 0 , 3𝑥 − 𝑦 = 0, 2𝑥 − 4𝑦 − 5𝑧 = 0
Solution: The augmented matrix corresponding to the homogenous system is:
−1 1 1 0 −1 1 1 0
3𝑅1 + 𝑅2
[𝐴|𝒃] = [ 3 −1 0 |0] → [0 2 3 |0]
2𝑅1 + 𝑅3
2 −4 −5 0 0 −2 −3 0
−1 1 10
𝑅2 + 𝑅3
→ [0 2 3|0]
0 0 00
We see that the elements of the third row are zeros, then the system has an infinite number of
solutions. Since the pivot of the third column is zero and there is no rows below to interchange,
then we choose 𝑧 to be the free variable (arbitrary) and represent it by the parameter 𝑧 = 𝑐. The
first and second rows give:
3 1
𝑧 = 𝑐, 2𝑦 + 3𝑧 = 0 ⇒ 𝑦 = − 𝑐, − 𝑥 + 𝑦 + 𝑧 = 0, 𝑥 = − 𝑐
2 2
Example 8:
Using Gauss Elimination method, discuss the solution of the system of equations:
𝑥 + 𝑦 + 𝑧 = 0 , 𝑥 − 𝑦 + 2𝑧 = 0, 2𝑥 − 𝑦 − 𝑧 = 0
Solution:
The augmented matrix corresponding to the homogenous system is:
1 1 1 0 1 1 1 0
−𝑅1 + 𝑅2
[𝐴|𝒃] = [1 −1 2 |0] → [0 −2 1 |0]
−2𝑅1 + 𝑅3
2 −1 −1 0 0 −3 −3 0
3 1 1 1 0
− 𝑅2 + 𝑅3
2
→ [0 −2 1 |0]
0 0 −9/2 0
Then, the system has the zero solution as a unique solution: 𝑥 = 𝑦 = 𝑧 = 0
27
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
Remark:
If 𝑐𝑘𝑘 ≠ 0, 𝑘 = 1,2, ⋯ , 𝑛 the system of equations has unique solution. Otherwise, the system
may have an infinite number of solutions or has no solution according to the zero rows in the
matrices 𝐶 and [𝐶\𝒅], by the same manner in Gauss-Elimination method.
Example 1:
Using Gauss – Jordan Elimination method, discuss the solution of the system of equations:
𝑥 + 𝑦 + 𝑧 = 0, 𝑥 − 2𝑦 + 2𝑧 = 4, 𝑥 + 2𝑦 − 𝑧 = 2
Solution:
We begin by writing the system as an augmented matrix:
1 1 1 0 1 1 1 0
−𝑅1 + 𝑅2
[𝐴|𝒃] = [1 −2 2 |4] → [0 −3 1 |4]
−𝑅1 + 𝑅3
1 2 −1 2 0 1 −2 2
1 1 1 0 1 0 3 −2
𝑅2 ↔ 𝑅3 −𝑅2 + 𝑅1
→ [0 1 −2|2] → [0 1 −2| 2 ]
3𝑅2 + 𝑅3
0 −3 1 4 0 0 −5 10
1
− 𝑅3 1 0 3 −2
−3𝑅3 + 𝑅1
1 0 0 4
5
→ [0 1 −2| 2 ] → [0 1 0|−2]
2𝑅3 + 𝑅2
0 0 1 −2 0 0 1 −2
Thus, the solution is: 𝑥 = 4, 𝑦 = − 2, 𝑧 = − 2
28
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
Example 2:
Using Gauss – Jordan Elimination method, discuss the solution of the system of equations:
4𝑥 + 3𝑦 + 5𝑧 = 3, 2𝑥 + 𝑦 + 3𝑧 = 1, 𝑥 + 5𝑦 + 6𝑧 = 4
Solution:
It is better to rearrange the given equations and the augmented matrix becomes:
1 5 64 1 5 6 4
−2𝑅1 + 𝑅2
[𝐴|𝒃] = [2 1 3|1] → [0 −9 −9 | −7 ]
−4𝑅1 + 𝑅3
4 3 53 0 −17 −19 −13
1
−1 1 5 6 4 1 0 1 9
𝑅2 −5𝑅2 + 𝑅1 7
9 7
→ [0 1 1 | ]→ 0 1 1 || 9
9 17𝑅2 + 𝑅3
2
0 −17 −19 −13 [0 0 −2 ]
9
2
1 1 0 0
𝑅 + 𝑅1 9
2 3 8
→
1
0 1 0 || 9
𝑅3 + 𝑅2 2
[0 0 −2
2
9 ]
Thus, the solution is: 𝑥 = 2/9, 𝑦 = 8/9, 𝑧 = − 1/9
Example 3:
Using Gauss – Jordan Elimination method, discuss the solution of the system of equations:
𝑥 − 11𝑦 + 4𝑧 = 3, 2𝑥 + 4𝑦 − 𝑧 = 7, 5𝑥 − 3𝑦 + 2 𝑧 = 3
Solution: We begin by writing the system as an augmented matrix:
1 −11 4 3 1 −11 4 3
−2𝑅1 + 𝑅2
[𝐴|𝒃] = [2 4 −1|7] → [0 26 −9 | 1 ]
−5𝑅1 + 𝑅3
5 −3 2 3 0 52 −18 −12
5 89
11
𝑅2 + 𝑅1 1 0 26
26
26
→ [0 26 −9| 1 ]
−2𝑅2 + 𝑅3
0 0 0 −14
Because the third “equation” is a false statement, the system has no solution.
Example 4:
Using Gauss – Jordan Elimination method, discuss the solution of the system of equations:
2𝑥 + 3𝑧 = 0, 4𝑥 − 3𝑦 + 7𝑧 = 0, 8𝑥 − 9𝑦 + 15𝑧 = 0
29
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
Solution:
We begin by writing the system as an augmented matrix:
2 0 3 0 2 0 30
−2𝑅1 + 𝑅2
[𝐴|𝒃] = [4 −3 7 |0] → [0 −3 1|0]
−4𝑅1 + 𝑅3
8 −9 15 0 0 −9 30
2 0 30
−3𝑅2 + 𝑅3
→ [0 −3 1|0]
0 0 00
We see that the elements of the third row are zeros, then the system has an infinite number of
solutions. Since the pivot of the third column is zero and there is no rows below to interchange,
then we choose 𝑧 to be the free variable (arbitrary) and represent it by the parameter 𝑧 = 𝑐. The
first and second rows give:
𝑐 3𝑐
𝑧 = 𝑐, − 3𝑦 + 𝑧 = 0 ⇒ 𝑦 = , 2𝑥 + 3𝑧 = 0, 𝑥 = −
3 2
where 𝑐 is any real number.
30
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
Inverse of Matrices
There are two ways to obtain the inverse of a square matrix. The first depends on using the
elementary row operations to determine the inverse of a matrix, and the second depends on using
the determinants and the adjoint on the matrix. Note that the inverse of a matrix is unique. which
means that there is only one inverse matrix (if exists). That’s why we say “the” inverse matrix of
𝐴 and denote it by 𝐴−1 .
2 0 3 1 0 0
−3𝑅2 + 𝑅3
→ [0 −3 1|−2 1 0]
0 0 0 2 −3 1
Thus, the given matrix has no inverse.
Example 3:
Using the determinants, find the inverse of the matrices:
4 0 0 4 2 3
2 1
(𝑖) 𝐴 = [ ] (𝑖𝑖) 𝐵 = [0 6 2] (𝑖𝑖𝑖)𝐶 = [7 5 4]
0 4
2 0 1 9 2 6
Solution:
2 1
(𝑖) |𝐴| = | |=8≠0
0 4
4 0 𝑇 4 −1
[𝐴𝑖𝑗 ] = [ ] ⇒ 𝐴𝑑𝑗𝐴 = [𝐴𝑖𝑗 ] = [ ]
−1 2 0 2
32
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
1 1
𝐴𝑑𝑗𝐴 1 4 −1 −
∴ 𝐴−1 = = [ ] = [2 8]
|𝐴| 8 0 2 1
0
4
4 0 0
(𝑖𝑖)|𝐵| = |0 6 2| = 24 ≠ 0
2 0 1
6 2 0 2 0 6
+| | −| | +| |
0 1 2 1 2 0 6 4 −12
0 0 4 0 4 0
[𝐵𝑖𝑗 ] = − | | +| | −| | = [0 4 0 ]
0 1 2 1 2 0
0 0 4 0 4 0 0 −8 24
+| | −| | +| |
[ 6 2 0 2 0 6]
6 0 0
⇒ 𝐴𝑑𝑗𝐵 = [ 4 4 −8]
−12 0 24
1
0 0
6 0 0 4
𝐴𝑑𝑗𝐵 1 1 1 −1
∴ 𝐵−1 = = [ 4 4 −8] =
|𝐵| 24 6 6 3
−12 0 24 −1
[2 0 1]
4 2 3
5 4 7 4 7 5
(𝑖𝑖𝑖) |𝐶| = |7 5 4| = 4 | | − 2| | + 3| | = −17 ≠ 0
2 6 9 6 9 2
9 2 6
5 4 7 4 7 5
+| | −| | +| |
2 6 9 6 9 2 22 −6 −31
2 3 4 3 4 2
[𝐶𝑖𝑗 ] = − | | +| | −| | = [−6 −3 10 ]
2 6 9 6 9 2
2 3 4 3 4 2 −7 5 6
+| | −| | +| |
[ 5 4 7 4 7 5]
22 −6 −7
⇒ 𝐴𝑑𝑗𝐶 = [ −6 −3 5]
−31 10 6
33
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
22 6 7
−
22 −6 −7 17 17 17
𝐴𝑑𝑗𝐶 −1 6 3 5
∴ 𝐶 −1 = = [ −6 −3 5 ]= −
|𝐶| 17 17 17 17
−31 10 6 31 10 6
[ 17 − − ]
17 17
Exercise:
Using determinants, find the inverse of the matrices:
1 −2 0 1 3 2
3 2
(i) 𝐴 = [ ] (ii) 𝐵 = [ 3 1 5] (iii) 𝐶 = [ 0 5 1]
−1 4
−1 2 3 −1 3 0
Example 4:
Use inverse of matrices method to solve the following equations (if it is possible):
2𝑥 + 𝑦 + 5𝑧 = 4, − 2𝑥 + 𝑦 − 3𝑧 = − 2, 2𝑥 − 𝑦 = − 1
Solution: The augmented matrix is
2 1 5 1 0 0 2 1 5 1 0 0
𝑅1 + 𝑅2
[𝐴|𝐼] = [−2 1 −3|0 1 0] → [0 2 2|1 1 0]
−𝑅1 + 𝑅3
2 −1 0 0 0 1 0 −2 −5 −1 0 1
1 2 0 4 1
−
1
0 4
− 𝑅2 + 𝑅1 2 2 𝑅 + 𝑅1
2 3 3
→ [0 2 2 |1 1 0] →
𝑅2 + 𝑅3 2
𝑅3 + 𝑅2
0 0 −3 0 1 1 3
34
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
1 5 2
2 0 0 1 5 4 1 1
2 6 3 𝑅1 , 𝑅2 1 0 0 4 12 3
2 2 1 5 1
0 2 0 |1 5 2 →
1
0 1 0|| 2 6 3
3 3 − 𝑅3 0 0 1 1 1
[0 0 −3 0 1 1] 3
[ 0 −
3
− ]
3
1 5 2
4 12 3
1 5 1
∴ 𝐴−1 =
2 6 3
1 1
[0 −
3
− ]
3
1 𝑥 5 2 4 1
4 12 3 −
2
1 5 1
⇒ 𝑦 = −2 = 0
2 6 3
1 1
[𝑧] [ 0 − − ] [−1] [ 1 ]
3 3
−1
∴ 𝑥 = , 𝑦 = 0, 𝑧 = 1
2
Example 5:
Use inverse of matrices method to solve the following equations (if it is possible):
𝑥 + 𝑦 + 𝑧 = 1, 𝑥 − 2𝑦 + 2𝑧 = 4, 𝑥 + 2𝑦 − 𝑧 = 2
Solution: The augmented matrix is
1 1 1 1 0 0 1 1 1 1 0 0
−𝑅1 + 𝑅2
[𝐴|𝐼] = [1 −2 2 |0 1 0] → [0 −3 1 |−1 1 0]
−𝑅1 + 𝑅3
1 2 −1 0 0 1 0 1 −2 −1 0 1
4 2 1
1 1 0 0 4
𝑅 + 𝑅1 3 3 3 𝑅 + 𝑅1
3 2 5 3
→ 0 −3 1 ||−1 1 0 →
1 3
𝑅2 + 𝑅3 5 4 1 𝑅3 + 𝑅3
3
[0 0 − −
3 3 3
1] 5
2 3 4 2 3 4
1 0 0 − 1 1 0 0 −5
5 5 5 − 𝑅2 5 5
0 ||− 9 6 3 3 3 2 1
0 −3
5 5 5
→
3
0 1 0|| 5 −
5
−
5
0 0
5
− −4 1 − 𝑅3 4 1 3
[0 0 1
1] 5 − − ]
[ 3 3 3 5 5 5
35
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
2 3 4
−
5 5 5
3 2 1
∴ 𝐴−1 = − −
5 5 5
4 1 3
[ 5 − −
5 5]
𝑥 2 3 4 1 18
−
5 5 5 5
3 2 1 7
⇒ 𝑦 = − − 4 = −
5 5 5 5
4 1 3 6
[𝑧 ] [ − − ] [2] [ − ]
5 5 5 5
18 7 6
∴ 𝑥 = , 𝑦 = − , 𝑧 = −
5 5 5
Example 6:
Use inverse of matrices method to solve the following equations (if it is possible):
4𝑥 + 2𝑦 + 3 𝑧 = 2 , 7𝑥 + 5𝑦 + 4 𝑧 = 1, 9 𝑥 + 2 𝑦 + 6 𝑧 = 0
Solution: First, we have to obtain the inverse of the coefficient matrix:
4 2 3
𝐴 = [7 5 4]
9 2 6
Using the determinants technique, we have:
4 2 3
5 4 7 4 7 5
|𝐴| = |7 5 4| = 4 | | − 2| |+3| | = −17 ≠ 0
2 6 9 6 9 2
9 2 6
5 4 7 4 7 5
+| | −| | +| |
2 6 9 6 9 2 22 −6 −31
2 3 4 3 4 2
[𝐴𝑖𝑗 ] = − | | +| | −| | = [−6 −3 10 ]
2 6 9 6 9 2
2 3 4 3 4 2 −7 5 6
+| | −| | +| |
[ 5 4 7 4 7 5]
22 −6 −7
⇒ 𝐴𝑑𝑗𝐴 = [ −6 −3 5]
−31 10 6
36
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
22 −6 −7
𝐴𝑑𝑗𝐶 −1
∴ 𝐴−1 = = [ −6 −3 5]
|𝐶| 17
−31 10 6
𝑥 22 6 7 2 38
− −
17 17 17 17
6 3 5 15
⇒ 𝑦 = − 1 =
17 17 17 17
31 10 6 52
[𝑧 ] [ − − ][ 0 ] [
17 17 17 17 ]
38 15 52
∴ 𝑥 = − , 𝑦 = , 𝑧 =
17 17 17
Exercises
Using Gauss elimination, Gauss - Jordan elimination methods, and inverse of matrices find all
solutions of each of the following systems or indicate that no solution exists.
1) 𝑥 + 𝑦 + 𝑧 = 1, 𝑥 − 2𝑦 + 2𝑧 = 4, 𝑥 + 2𝑦 − 𝑧 = 2
2) 2𝑥 + 𝑦 + 5𝑧 = 10, 𝑥 − 3𝑦 − 𝑧 = −2, 2𝑥 − 𝑦 + 3𝑧 = 6
3) 12𝑥 + 7𝑦 + 3𝑧 = 2, 𝑥 + 5𝑦 + 2𝑧 = −5, 2𝑥 + 7𝑦 − 11𝑧 = 6
4) 𝑥 + 𝑦 − 𝑧 = −1, 𝑥 + 𝑧 = 3, 3𝑥 + 2𝑦 − 𝑧 = 1
5) 3𝑥 − 𝑦 + 2𝑧 = 1, 2𝑥 − 2𝑦 + 3𝑧 = 2, 𝑥 + 2𝑦 − 𝑧 = 3
6) 2𝑥 − 𝑦 + 5𝑧 = 4, − 6𝑥 + 3𝑦 − 9𝑧 = −6, 4𝑥 − 2𝑦 = −2
7) 2𝑥 − 𝑦 + 5𝑧 = 4, − 2𝑥 + 𝑦 − 3𝑧 = −2, 2𝑥 − 𝑦 = −1
8) 4𝑥 − 𝑦 + 2𝑧 = 0, 2𝑥 + 3𝑦 − 𝑧 = 0, 3𝑥 + 𝑦 + 𝑧 = 0
9) 2𝑥 − 𝑦 + 5𝑧 = 0, − 2𝑥 + 𝑦 − 3𝑧 = 0, 2𝑥 − 𝑦 = 0
10) 2𝑥 + 3𝑧 = 3, 4𝑥 − 3𝑦 + 7𝑧 = 5, 8𝑥 − 9𝑦 + 15 = 10
37
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
LU - decomposition method
The system of equations (1) can be written in the matrix equation 𝐴𝒙 = 𝒃, where:
𝑎11 𝑎12 ⋯ 𝑎1𝑛 𝑥1 𝑏1
𝑎21 𝑎22 ... 𝑎2𝑛 𝑥2 𝑏2
𝐴= , 𝒙= , 𝒃=
⋮ ⋮ ⋱ ⋮ ⋮ ⋮
[𝑎𝑛1 𝑎𝑛2 ⋯ 𝑎𝑛𝑛 ] [𝑥𝑛 ] [𝑏𝑛 ]
In the LU decomposition method the coefficient matrix 𝐴 (a non-singular matrix) is decomposed
into a product of a lower triangular matrix 𝐿 and an upper triangular matrix 𝑈, i.e., 𝐴 = 𝐿𝑈.
A version of expressing the LU matrices explicitly, they look like:
1 0 ⋯ 0 𝑢11 𝑢12 ⋯ 𝑢1𝑛
𝑙21 1 ... 0 0 𝑢22 ... 𝑢2𝑛
𝐿= , 𝑈=
⋮ ⋮ ⋱ ⋮ ⋮ ⋮ ⋱ ⋮
[𝑙𝑛1 𝑙𝑛2 ⋯ 1] [ 0 0 ⋯ 𝑢𝑛𝑛 ]
The LU decomposition is not always guaranteed. It is guaranteed only when the leading principal
minors of the coefficient matrix are not zeros.
Leading Principal Minors of A square Matrix
Each square 𝑛 × 𝑛 matrix has 𝑛 leading principal minors. A leading principal minor is the
determinant of the leading principal submatrix obtained by deleting the last 𝑛 − 𝑘 rows and
columns of the matrix, 𝑘 = 1, 2, 3, ⋯ , 𝑛. The leading principal minors of a matrix 𝐴 starts by |𝑎11 |
and ends by |𝐴|.
7 6 3
For example: the matrix 𝐴 = [−5 4 5 ] has three leading principal minors:
1 0 6
1. |7| formed by deleting the last two rows and columns of 𝐴.
7 6
2. | | formed by deleting the last row and column of 𝐴.
−5 4
7 6 3
3. |−5 4 5 | formed by the determinant of the matrix, which is |𝐴|.
1 0 6
Hint: Sometimes it is needed to rearrange the given equations to guarantee the nonzero leading
principal minors of the coefficient matrix, which makes the LU decomposition method applicable.
38
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
However, to perform the calculations of the 𝐿 and 𝑈 matrices. First, we obtain the product matrix
𝐿𝑈 and equating the elements of its first row by those of the first row in the 𝑈 matrix to get the
first row in the upper matrix 𝑈. Equating the second rows in both sides yields the second row in
each of the matrices 𝐿 and 𝑈. By the same way we can find all the elements of the matrices 𝐿 and
𝑈.
However, we can write the results of the process of equating the two matrices in both sides of (8)
as the following equations:
𝑎11 = 𝑢11 , 𝑎12 = 𝑢12 ⇒ 𝑢1𝑘 = 𝑎1𝑘 , 𝑘 = 1,2, ⋯ , 𝑛 (9. 𝑎)
𝑗
Equations (9. 𝑎 − 9. 𝑑) can be used to perform computer code to determine the 𝐿 and 𝑈 matrices.
First, we use the equations (9. 𝑎), (9. 𝑐) to find the first row 𝑢1𝑘 and the first column 𝑙𝑗1 , then
apply for (9. 𝑏), (9. 𝑑) in parallel.
Thus, the system of linear algebraic equations can be decomposed to two systems of linear
algebraic equations which can be solved directly.
𝐴𝒙 = 𝒃 ⇒ 𝐿𝑈𝒙 = 𝒃
Consider 𝒚 = 𝑈𝒙 then 𝐿𝒚 = 𝒃.
Therefore, we must obtain y by solving the equation 𝐿𝒚 = 𝒃, that is:
39
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
1 0 ⋯ 0 𝑦1 𝑏1
𝑙21 1 ... 0 𝑦2 𝑏2
= (10)
⋮ ⋮ ⋱ ⋮ ⋮ ⋮
[𝑙𝑛1 𝑙𝑛2 ⋯ 1] [𝑦𝑛 ] [𝑏𝑛 ]
Then we can obtain the solution 𝒙 by solving the equation 𝑈𝒙 = 𝒚, that is:
𝑢11 𝑢12 ⋯ 𝑢1𝑛 𝑥1 𝑦1
0 𝑢22 ... 𝑢2𝑛 𝑥2 𝑦2
= (11)
⋮ ⋮ ⋱ ⋮ ⋮ ⋮
[ 0 0 ⋯ 𝑢𝑛𝑛 ] [𝑥𝑛 ] [𝑦𝑛 ]
Example 1:
Using the LU decomposition method solve the equations (if it is possible):
𝑥 + 2𝑦 + 4𝑧 = 2, 2𝑥 + 3𝑦 − 5𝑧 = 1, 4𝑥 − 5𝑦 + 8𝑧 = 5
Solution: We have
1 2 4 𝑥 2
𝐴 = [2 3 −5] , 𝒙 = [𝑦] , 𝒃 = [ 1]
4 −5 8 𝑧 5
40
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
41
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
42
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
Example 3:
Using the LU decomposition method solve the equations (if it is possible):
𝑦 + 𝑧 = 3, 2𝑥 − 3𝑦 − 𝑧 = 1, 𝑥 − 𝑦 + 2𝑧 = 2
Solution: We have
0 1 1 𝑥 3
𝐴 = [2 −3 −1] , 𝒙 = [𝑦] , 𝒃 = [1]
1 −1 2 𝑧 2
The first leading principal minor of the matrix 𝐴 is: |0| = 0 .
0 1 1
Since |𝐴| = |2 −3 −1| = −4 ≠ 0, then it is needed to rearrange the given equations. We
1 −1 2
may rearrange these equations as:
2𝑥 − 3𝑦 − 𝑧 = 1, 𝑦 + 𝑧 = 3, 𝑥 − 𝑦 + 2𝑧 = 2
2 −3 −1 𝑥 1
∴ 𝐴 = [0 1 1 ], 𝒙 = [𝑦 ] , 𝒃 = [3]
1 −1 2 𝑧 2
The leading principal minors of the matrix 𝐴 becomes:
2 −3 −1
2 −3
1. |2| = 2 ≠ 0, 2. | | = 2 ≠ 0, 3. |0 1 1 |=4≠0
0 1
1 −1 2
Decomposing the coefficient matrix as:
2 −3 −1 1 0 0 𝑢11 𝑢12 𝑢13
[0 1 1 ] = [𝑙21 1 0] [ 0 𝑢22 𝑢23 ]
1 −1 2 𝑙31 𝑙32 1 0 0 𝑢33
𝑢11 𝑢12 𝑢13
= [𝑙21 𝑢11 𝑙21 𝑢12 + 𝑢22 𝑙21 𝑢13 + 𝑢23 ]
𝑙31 𝑢11 𝑙31 𝑢12 + 𝑙32 𝑢22 𝑙31 𝑢13 + 𝑙32 𝑢23 + 𝑢33
Then we have:
𝑢11 = 2, 𝑢12 = −3, 𝑢13 = −1
𝑙21 𝑢11 = 0 → 𝑙21 = 0,
𝑙21 𝑢12 + 𝑢22 = 1 → 𝑢22 = 1,
43
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
44
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
45
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
Example 5: Using the LU decomposition method, solve the equations (if it is possible):
2𝑥 + 5𝑦 − 3𝑧 = 3, 𝑥 − 2𝑦 + 𝑧 = 2, 7𝑥 + 4𝑦 − 3𝑧 = −4
Solution: We have
2 5 −3 𝑥 3
𝐴 = [1 −2 1 ], 𝒙 = [𝑦 ] , 𝒃=[ 2 ]
7 4 −3 𝑧 −4
The leading principal minors of the matrix 𝐴 are:
2 5 −3
2 5
1. |2| = 2 ≠ 0, 2. | | = −9 ≠ 0, 3. |1 −2 1 |=0
1 −2
7 4 −3
Therefore, the coefficient matrix cannot be decomposed into LU form, and the LU decomposition
method is not applicable and the given system of equation does not have unique solution.
Exercises
Using the LU decomposition method solve the equations:
1)𝑥 + 2𝑧 = 1, 3𝑥 − 𝑦 + 𝑧 = 2, 4𝑦 + 5𝑧 = −1
2)3𝑥 + 𝑦 − 2𝑧 = 4, 2𝑥 + 3𝑦 + 𝑧 = 2, 𝑥 − 3𝑦 + 2𝑧 = 8
3)4𝑥 + 2𝑦 − 𝑧 = 0, 6𝑥 + 3𝑦 + 2𝑧 = −16, 𝑥 + 2𝑦 + 9𝑧 = −4
4)4𝑥 + 10𝑦 + 8𝑧 = 44, 10𝑥 + 26𝑦 + 26𝑧 = 128, 8𝑥 + 26𝑦 + 61𝑧 = 214
46
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
Iterative methods
If we have a system of large number of linear equations, the above direct methods need many
operations which may affect the result due to the round off error. To avoid this problem, we use
the iterative methods, in which we start from an approximation to the solution. We apply the
iterative methods if the convergence is rapid or there are many zeros coefficients in the system.
Consider the system of equations (2.1) and rewrite them is the fixed-point form as
1
𝑥𝑘 = (𝑏𝑘 − ∑𝑛𝑗=1 𝑎𝑘𝑗 𝑥𝑗 ) (8)
𝑎𝑘𝑘
𝑗≠𝑘
Explicitly, we obtain:
1
𝑥1 = {𝑏1 − (𝑎12 𝑥2 + 𝑎13 𝑥2 + ⋯ + 𝑎1𝑛 𝑥𝑛 )}
𝑎11
1
𝑥2 = {𝑏2 − (𝑎21 𝑥1 + 𝑎23 𝑥3 + ⋯ + 𝑎2𝑛 𝑥𝑛 )}
𝑎22 (9)
⋮
1
𝑥𝑛 = {𝑏𝑛 − (𝑎𝑛1 𝑥1 + 𝑎𝑛2 𝑥2 + ⋯ + 𝑎𝑛,𝑛−1 𝑥𝑛−1 )} }
𝑎𝑛𝑛
If (10) is satisfied, then the system of linear equations has a unique solution to which the iterative
methods will converge for any initial approximation.
Remark:
Sometimes, it is needed to interchange equations (rearrange the equations) of the given system to
obtain convergence of the solution.
Below are two of the most important iterative methods.
Jaccobi method
This method uses the starting approximate solution 𝑥𝑘0 , 𝑘 = 1,2, ⋯ , 𝑛 to obtain 𝑥𝑘1 , then uses 𝑥𝑘1
to find 𝑥𝑘2 and so on until the solution converges, i.e., |𝑥𝑘𝑚+1 − 𝑥𝑘𝑚 | ≤ 𝜀 .
The iteration of Jaccobi method is written as
(𝑚+1) 1 𝑛 (𝑚)
𝑥𝑘 = (𝑏𝑘 − ∑𝑗=1 𝑎𝑘𝑗 𝑥𝑗 ) , 𝑘 = 1,2,3, ⋯ , 𝑛, 𝑚 = 0,1,2, ⋯ (11)
𝑎𝑘𝑘
𝑗≠𝑘
47
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
Example 1:
Using Jaccobi method, solve the equations:
4𝑥 + . 24𝑦 − . 08𝑧 = 8, . 04𝑥 − . 08𝑦 + 4𝑧 = 20, . 09𝑥 + 3𝑦 − . 15𝑧 = 9
using 𝑥0 = 0, 𝑦0 = 0, 𝑧0 = 0
Solution:
We should rearrange the equations to be:
4𝑥 + 0.24𝑦 − 0.08𝑧 = 8, 0 . 09𝑥 + 3𝑦 − 0.15𝑧 = 9, 0 . 04𝑥 − 0.08𝑦 + 4𝑧 = 20
Then we have the iterative formula:
1
𝑥𝑖+1 = {8 − (0.24𝑦𝑖 − 0.08𝑧𝑖 )},
4
1
𝑦𝑖+1 = {9 − (0.09𝑥𝑖 − 0.15𝑧𝑖 )},
3
1
𝑧𝑖+1 = {20 − (0.04𝑥𝑖 − 0.08𝑦𝑖 )}.
4
The iterations give
𝑖 = 0:
1
𝑥1 = {8 − (0.24𝑦0 − 0.08𝑧0 )} = 2.0,
4
1
𝑦1 = {9 − (0.09𝑥0 − 0.15𝑧0 )} = 3.0,
3
1
𝑧1 = {20 − (0.04𝑥0 − 0.08𝑦0 )} = 5.0
4
𝑖 = 1:
1 1
𝑥2 = {8 − (0.24𝑦1 − 0.08𝑧1 )} = {8 − (.24 × 3 − .08 × 5)} = 1.92000000178,
4 4
1 1
𝑦2 = {9 − (0.09𝑥1 − 0.15𝑧1 )} = {9 − (.09 × 2 − .15 × 5 )} = 3.19000000754,
3 3
1 1
𝑧2 = {20 − (0.04𝑥1 − 0.08𝑦1 )} = {20 − (.04 × 2 − .08 × 3)} = 5.03999999910
4 4
𝑖 = 2:
1 1
𝑥3 = {8 − (0.24𝑦2 − 0.08𝑧2 )} = {8 − (.24 × 3.19 − .08 × 5.04)} = 1.90940000155
4 4
1 1
𝑦3 = {9 − (0.09𝑥2 − 0.15𝑧2 )} = {9 − (.09 × 1.92 − .15 × 5.04 )} = 3.19440000762
3 3
1 1
𝑧3 = {20 − (0.04𝑥2 − 0.08𝑦2 )} = {20 − (.04 × 1.92 − .08 × 3.19)} = 5.04459999913
4 4
48
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
Example 2:
Using six iterations of Jaccobi method, solve the equations:
12𝑥 + 7𝑦 + 3𝑧 = 1, 𝑥 + 8𝑦 + 2𝑧 = 2, − 2𝑥 − 7𝑦 + 25𝑧 = 1
with 𝑥0 = 0, 𝑦0 = 0, 𝑧0 = 0:
Solution: The Jaccobi iterative formula is:
𝑥𝑖+1 = (1 − 7𝑦𝑖 − 3𝑧𝑖 )/12,
𝑦𝑖+1 = (2 − 𝑥𝑖 − 2𝑧𝑖 )/8,
𝑧𝑖+1 = (1 + 2𝑥𝑖 + 7𝑦𝑖 )/25
The iterations give:
𝑖 = 0:
𝑥1 = (1 − 7𝑦0 − 3𝑧0 )/12 = 0.08.333334,
𝑦1 = (2 − 𝑥0 − 2𝑧0 )/8 = 0.25,
𝑧1 = (1 + 2𝑥0 + 7𝑦0 )/25 = 0.04
𝑖 = 1:
𝑥2 = (1 − 7𝑦1 − 3𝑧1 )/12 = −0.0725,
𝑦2 = (2 − 𝑥1 − 2𝑧1 )/8 = 0.2295833,
49
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
Example 3:
Using five iterations of Jaccobi method, solve the system equations:
𝑥 + 2𝑦 − 𝑧 = 5, 3𝑥 − 𝑦 + 𝑧 = −2, 𝑥 + 𝑦 + 2𝑧 = 1
with 𝑥0 = 1, 𝑦0 = 0, 𝑧0 = 1.
Solution:
We must rearrange the equations as:
3𝑥 − 𝑦 + 𝑧 = −2, 𝑥 + 2𝑦 − 𝑧 = 5, 𝑥 + 𝑦 + 2𝑧 = 1
and the iterative formula becomes:
𝑥𝑖+1 = (−2 + 𝑦𝑖 − 𝑧𝑖 )/3,
𝑦𝑖+1 = (5 − 𝑥𝑖 + 𝑧𝑖 )/2,
𝑧𝑖+1 = (1 − 𝑥𝑖 − 𝑦𝑖 )/2
The iterations give:
𝑖 = 0:
𝑥1 = (−2 + 𝑦0 − 𝑧0 )/3 = −1
𝑦1 = (5 − 𝑥1 + 𝑧0 )/2 = 2.5
𝑧1 = (1 − 𝑥1 − 𝑦1 )/2 = 0.0
𝑖 = 1:
𝑥2 = (−2 + 𝑦1 − 𝑧1 )/3 = 1.66667
𝑦2 = (5 − 𝑥1 + 𝑧1 )/2 = 3
𝑧2 = (1 − 𝑥1 − 𝑦1 )/2 = -0.25
50
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
𝑖 = 2:
𝑥3 = (−2 + 𝑦2 − 𝑧2 )/3 = 0.4166667
𝑦3 = (5 − 𝑥2 + 𝑧2 )/2 = 2.291667
𝑧3 = −(1 − 𝑥2 − 𝑦2 )/2 = −1.08333
The following table contains more results:
i xi +1 yi +1 zi +1
3 4.583334 E − 01 1.750000 −8.541667 E − 01
4 2.013889 E − 01 1.843750 −6.041667 E − 01
5 1.493056 E − 01 2.097222 −5.225694 E − 01
Example 1:
Using ten iterations of Gauss - Seidel method, solve the system equations:
𝑥 + 2𝑦 + 𝑧 = 1, 3𝑥 − 2𝑦 + 2𝑧 = 4, 𝑥 + 𝑦 − 5𝑧 = 2
with 𝑥0 = 1, 𝑦0 = 1, 𝑧0 = 1.
Solution:
We must rearrange the equations and the iterative formula becomes:
𝑥𝑖+1 = (4 + 2𝑦𝑖 − 2𝑧𝑖 )/3
𝑦𝑖+1 = (1 − 𝑥𝑖+1 − 𝑧𝑖 )/2
𝑧𝑖+1 = −(2 − 𝑥𝑖+1 − 𝑦𝑖+1 )/5
The iterations give:
𝑖 = 0:
𝑥1 = (4 + 2𝑦0 − 2𝑧0 )/3 = 1.33333
𝑦1 = (1 − 𝑥1 − 𝑧0 )/2 = −0.666666
𝑧1 = −(2 − 𝑥1 − 𝑦1 )/5 = −0.266666
51
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
𝑖 = 1:
𝑥2 = (4 + 2𝑦1 − 2𝑧1 )/3 = 1.066667
𝑦2 = (1 − 𝑥2 − 𝑧1 )/2 = 0.1
𝑧2 = −(2 − 𝑥2 − 𝑦2 )/5 = −0.1666667
𝑖 = 2:
𝑥3 = (4 + 2𝑦2 − 2𝑧2 )/3 = 1.51111
𝑦3 = (1 − 𝑥3 − 𝑧2 )/2 = −0.172222
𝑧3 = −(2 − 𝑥3 − 𝑦3 )/5 = −0.132222
The following table contains more results:
i xi +1 yi +1 zi +1
3 1.306667 − 0.8722220 −0.1561111
4 1.379259 − 0.1115741 −0.1464630
5 1.356593 − 0.1050648 −0.1496944
6 1.363086 − 0.1066960 −0.1487219
7 1.361351 − 0.1063144 −0.1489927
8 1.361786 −0.1063964 −0.1489222
9 1.361684 − 0.1063808 −0.1489394
Example 2:
Using six iterations of Gauss - Seidel method, solve the system equations:
𝑥 + 𝑦 + 5𝑧 = 4, 2𝑥 − 3𝑦 + 𝑧 = 2, 5𝑥 − 4𝑦 + 𝑧 = 0
with 𝑥0 = 1, 𝑦0 = 0, 𝑧0 = 0.
Solution:
We must rearrange the equations and the iterative formula becomes:
𝑥𝑖+1 = (4𝑦𝑖 − 𝑧𝑖 )/5,
𝑦𝑖+1 = −(2 − 2𝑥𝑖+1 − 𝑧𝑖 )/3,
𝑧𝑖+1 = (4 − 𝑥𝑖+1 − 𝑦𝑖+1 )/5
The iterations give:
𝑖 = 0:
𝑥1 = (4𝑦0 − 𝑧0 )/5 = 0
52
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
53
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
54
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
Exercises
Using Jaccobi and Gauss - Seidel methods to solve following the equations:
1) 9𝑥 − 5𝑧 = 10, 20𝑦 − 12𝑧 = −2, − 5𝑥 − 12𝑦 + 20𝑧 = 0
where 𝑥0 = 0, 𝑦0 = 0, 𝑧0 = 0
2) 2𝑥 + 10𝑦 − 𝑧 = −32, − 𝑥 + 2𝑦 + 15𝑧 = 17, 10𝑥 − 𝑦 + 2𝑧 = 58
where 𝑥0 = 1, 𝑦0 = 1, 𝑧0 = 1
3) 4𝑥 + 2𝑦 + 𝑧 = 14, 𝑥 + 5𝑦 − 𝑧 = 10, 𝑥 + 𝑦 + 8𝑧 = 20
where 𝑥0 = 1, 𝑦0 = 1, 𝑧0 = 1
4) 6𝑥 + 𝑦 + 𝑧 = 107, 𝑥 + 9𝑦 − 2𝑧 = 36, 2𝑥 − 𝑦 + 8𝑧 = 121
where 𝑥0 = 1, 𝑦0 = 1, 𝑧0 = 1
55
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
This section presents one of the most important problems in linear algebra, the eigenvalue
problem. Its central question can be stated as follows. If 𝐴 is a square matrix of order 𝑛, do nonzero
𝒙 vectors exist such that 𝐴𝒙 is a scalar multiple of 𝒙?. The scalar, denoted by the Greek letter
lambda (λ), is called an eigenvalue of the matrix A and the nonzero vector 𝒙 is called an
eigenvector of 𝐴 corresponding to λ. The terms eigenvalue and eigenvector are derived from the
German word Eigenwert, meaning “proper value.” So, we have 𝐴𝒙 = 𝜆𝒙.
To find the eigenvalues and eigenvectors of a square matrix 𝐴 of order 𝑛, let I be the identity
matrix of order 𝑛. Writing the equation 𝐴𝒙 = 𝜆𝒙 in the form 𝐴𝒙 = 𝜆𝐼𝒙 then produces the system
of equations:
(𝐴 − 𝜆𝐼)𝒙 = 0 (1)
This homogeneous system of equations has nonzero solutions if and only if the coefficient matrix
(𝐴 − 𝜆𝐼) is not invertible, that is;
𝑑𝑒𝑡( 𝐴 − 𝜆𝐼) = 0 (2)
The equation (2) is called the characteristic equation of A and it gives a polynomial of degree 𝑛 in
λ, its n roots are the eigenvalues of the matrix A. For each eigenvalue there exist a corresponding
eigenvector (nonzero vector) which can be obtained by solving the homogeneous system (1).
Since the eigenvectors are nonzero vectors, then the homogeneous system (1) has an infinite
number of solutions for each value of λ. So that we consider the value 1 for the free variable. This
requires row reducing of a matrix where the resulting row reduced form must have at least one
row of zeros.
Example 1:
Verify that which of the vectors 𝒙1𝑇 = [4 1], 𝒙𝑇2 = [3 1] , and 𝒙𝑇3 = [1 1] is an eigenvector
2 −12
of the matrix 𝐴 = [ ] and find the corresponding eigenvalue.
1 −5
Solution:
2 −12 4 −4 4
𝐴𝒙1 = [ ] [ ] = [ ] = − [ ] = −𝒙1 ,
1 −5 1 −1 1
then 𝒙1 is an eigenvector of the matrix 𝐴 and the corresponding eigenvalue is 𝜆 = −1 .
56
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
2 −12 3 −6 3
𝐴𝒙2 = [ ] [ ] = [ ] = −2 [ ] = −2𝒙2 ,
1 −5 1 −2 1
then 𝒙2 is an eigenvector of the matrix 𝐴 , and the corresponding eigenvalue is 𝜆 = −2 .
2 −12 1 −10
𝐴𝒙3 = [ ][ ] = [ ] ≠ 𝜆𝒙3 ,
1 −5 1 −4
then 𝒙3 is not an eigenvector of the matrix 𝐴.
Example 2:
Verify that which of the vectors 𝒙1𝑇 = [−2 1 0], 𝒙𝑇2 = [−10 3 1], and
3 6 −8
𝒙𝑇3 = [0 2 3] is an eigenvector of the matrix 𝐴 = [0 0 6 ] and find the corresponding
0 0 2
eigenvalue.
Solution:
3 6 −8 −2 0
𝐴𝒙1 = [0 0 6 ] [ 1 ] = [0] ≠ 𝜆𝒙1 ,
0 0 2 0 0
then 𝒙1 is not an eigenvector of the matrix 𝐴.
3 6 −8 −10 −20 −10
𝐴𝒙2 = [0 0 6 ] [ 3 ] = [ 6 ] = 2 [ 3 ] = 2𝒙2 ,
0 0 2 1 2 1
then 𝒙2 is an eigenvector of the matrix 𝐴 and the corresponding eigenvalue is 𝜆 = 2 .
3 6 −8 0 −12
𝐴𝒙3 = [0 0 6 ] [2] = [ 18 ] ≠ 𝜆𝒙3 ,
0 0 2 3 6
then 𝒙3 is not an eigenvector of the matrix 𝐴.
Example 3:
Verify that which of the vectors 𝒙1𝑇 = [1 0 1], xT2 = −1 1 0 , and xT3 =1 1 2 is an
1 −3 3
eigenvector of the matrix 𝐴 = [3 −5 3] and find the corresponding eigenvalue.
6 −6 4
Solution:
57
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
1 −3 3 1 4 1
𝐴𝒙1 = [3 −5 3] [0] = [ 6 ] ≠ 𝜆 [0] ≠ 𝜆𝒙1
6 −6 4 1 10 1
Then 𝒙1 is not an eigenvector of the matrix 𝐴.
1 −3 3 −1 −4 −1
𝐴𝒙2 = [3 −5 3] [ 1 ] = [ −8 ] ≠ 𝜆 [ 1 ] ≠ 𝜆𝒙2
6 −6 4 0 −12 0
Then 𝒙2 is not an eigenvector of the matrix 𝐴.
1 −3 3 1 4 1
𝐴𝒙3 = [3 −5 3] [1] = [4] = 4 [1] = 4𝒙3
6 −6 4 2 8 2
Then 𝒙3 is an eigenvector of the matrix 𝐴 and the corresponding eigenvalue is 𝜆 = 4.
Example 4:
2 −12
Find the eigenvalues and eigenvectors of the matrix 𝐴 = [ ]
1 −5
Solution:
The eigenvalues 𝜆 of the matrix 𝐴 are given by solving the characteristic equation:
2−𝜆 −12
𝑑𝑒𝑡( 𝐴 − 𝜆𝐼) = 0 ⇒ | |=0
1 −5 − 𝜆
∴ 𝜆2 + 3𝜆 + 2 = 0 ⇒ (𝜆 + 1)(𝜆 + 2) = 0 ⇒ 𝜆 = −1, −2
Consider 𝒙1𝑇 = [𝑥1 𝑥2 ] to be the eigenvector corresponding to the eigenvalue 𝜆1 = −1
3 −12 𝑥1 0
∴ (𝐴 − 𝜆1 𝐼)𝒙1 = 0 ⇒ [ ][ ] = [ ]
1 −4 𝑥2 0
Using Gauss-Elimination method gives the augmented matrix:
1
3 −12 0 3 𝑅1 + 𝑅2 3
− −12 0
[ | ]→ [ | ]
1 −4 0 0 0 0
∴ 3𝑥1 − 12𝑥2 = 0.
Letting the free variable 𝑥2 = 𝑘 = 1 gives 𝑥1 = 4 ⇒ 𝒙1𝑇 = [4 1]
Consider 𝒙𝑇2 = [𝑥1 𝑥2 ] to be the eigenvector corresponding to the eigenvalue 𝜆2 = −2
4 −12 𝑥1 0
∴ (𝐴 − 𝜆2 𝐼)𝒙2 = 0 ⇒ [ ][ ] = [ ]
1 −3 𝑥2 0
58
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
0 −1 0 0 −1 1 −1 0 −1 1 −1 0
𝑅1 ↔ 𝑅2 𝑅2 + 𝑅3
[−1 1 −1|0] → [0 −1 0 |0] → [0 −1 0 |0]
0 −1 0 0 0 −1 0 0 0 0 0 0
∴ 𝑥2 = 0, 𝑥3 = 𝑘, 𝑥1 = −𝑥3 .
Letting the free variable 𝑥3 = 𝑘 = 1 gives 𝑥1 = −1, 𝑥2 = 0 ⇒ 𝒙𝑇3 = [−1 0 1].
Consider 𝒙𝑇3 = [𝑥1 𝑥2 𝑥3 ] to be the eigenvector corresponding to the eigenvalue 𝜆3 = 3
−2 −1 0 𝑥1 0
∴ (𝐴 − 𝜆3 𝐼)𝒙3 = 0 ⇒ [−1 −1 −1] [𝑥2 ] = [0]
0 −1 −2 𝑥3 0
Using Gauss-Elimination method gives the augmented matrix:
−2 −1 0 0 − 1 𝑅 + 𝑅 −2 −1 0 0 −2 −1 0 0
2 1 2 −2𝑅2 + 𝑅3
[−1 −1 −1|0] → [0 −1/2 −1|0] → [0 −1/2 −1|0]
0 −1 −2 0 0 −1 −2 0 0 0 0 0
∴ 2𝑥1 = −𝑥2 , 𝑥2 = −2𝑥3 .
Letting the free variable 𝑥3 = 𝑘 = 1 gives 𝑥1 = 1, 𝑥2 = −2 ⇒ 𝒙𝑇3 = [1 −2 1].
Example 6:
3 0 0
Find the eigenvalues and eigenvectors of the matrix 𝐴 = [0 2 0]
0 0 4
Solution:
The eigenvalues of the matrix A are given by solving the equation:
3−𝜆 0 0
𝑑𝑒𝑡( 𝐴 − 𝜆𝐼) = 0 ⇒ | 0 2−𝜆 0 |=0
0 0 4−𝜆
∴ (3 − 𝜆)(2 − 𝜆)(4 − 𝜆) = 0 ⇒ 𝜆 = 3, 2, 4
If the eigenvector corresponding to the eigenvalue 𝜆1 = 3 is 𝒙1𝑇 = [𝑥1 𝑥2 𝑥3 ], then,
0 0 0 𝑥1 0
(𝐴 − 𝜆1 𝐼)𝒙1 = 0 ⇒ [0 −1 0] [𝑥2 ] = [0]
0 0 1 𝑥3 0
It is easy to see that 𝑥2 = 0, 𝑥3 = 0, consider the free variable 𝑥1 = 𝑘 = 1 ⇒ 𝒙1𝑇 = [1 0 0]
Consider 𝒙𝑇2 = [𝑥1 𝑥2 𝑥3 ] to be the eigenvector corresponding to the eigenvalue 𝜆2 = 2
60
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
1 0 0 𝑥1 0
∴ (𝐴 − 𝜆2 𝐼)𝒙2 = 0 ⇒ [0 0 0] [𝑥2 ] = [0]
0 0 2 𝑥3 0
It is easy to see that 𝑥1 = 0, 𝑥3 = 0, consider the free variable 𝑥2 = 𝑘 = 1
⇒ 𝒙𝑇2 = [0 1 0]
Consider 𝒙𝑇3 = [𝑥1 𝑥2 𝑥3 ] to be the eigenvector corresponding to the eigenvalue 𝜆3 = 4
−1 0 0 𝑥1 0
∴ (𝐴 − 𝜆3 𝐼)𝒙3 = 0 ⇒ [0 −2 0] [𝑥2 ] = [0]
0 0 0 𝑥3 0
It is easy to see that 𝑥1 = 0, 𝑥2 = 0, consider the free variable 𝑥3 = 𝑘 = 1
⇒ 𝒙𝑇3 = [0 0 1]
Example 7:
1 0 0 0
0 1 5 −10
Find the eigenvalues and eigenvectors of the matrix 𝐴 =
1 0 2 0
[1 0 0 3 ]
Solution:
The eigenvalues 𝜆 of the matrix 𝐴 are given by solving the equation:
1−𝜆 0 0 0
| 0 1−𝜆 5 −10 |
𝑑𝑒𝑡( 𝐴 − 𝜆𝐼) = 0 ⇒ =0
| 1 0 2−𝜆 0 |
1 0 0 3−𝜆
∴ (1 − 𝜆)2 (2 − 𝜆)(3 − 𝜆) = 0 ⇒ 𝜆 = 1,2,3
Note that 𝜆 = 1 is repeated root.
The eigenvector corresponding to the eigenvalue 𝜆1 = 1 is 𝒙1𝑇 = [𝑥1 𝑥2 𝑥3 𝑥4 ] such that:
0 0 0 0 𝑥1 0
0 0 5 −10 𝑥2 0
(𝐴 − 𝜆1 𝐼)𝒙1 = 0 ⇒ =
1 0 1 0 𝑥3 0
[1 0 0 2 ] [𝑥4 ] [0]
Using Gauss-Elimination method gives the augmented matrix:
61
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
0 0 0 0 0 1 0 0 2 0
0 0 5 −10|0 𝑅1 ↔ 𝑅4 0 0 5 −10|0 −𝑅1 + 𝑅3
→ →
1 0 1 0 |0 1 0 1 0 |0
[1 0 0 2 0] [0 0 0 0 0]
1 0 0 2 0 1 0 0 2 0
1
0 0 5 −10|0 − 𝑅 + 𝑅3 0 0 5 −10|0
5 2
→
0 0 1 −2 |0 0 0 0 0 |0
[0 0 0 0 0] [0 0 0 0 0]
∴ 𝑥1 = −2𝑥4 , 𝑥3 = 2𝑥4
Since we have two rows of zeros, then we have two eigenvectors corresponding to the eigenvalue
𝜆1 = 1. There are two free variables, one of those two variables must be x2 and the
other may be 𝑥3 or 𝑥4 .
Letting 𝑥2 = 𝑘 = 1, 𝑥4 = 0 gives 𝑥1 = 0, 𝑥2 = 1, 𝑥3 = 0, 𝑥4 = 0 ⇒ 𝒙1𝑇 = [0 1 0 0].
Letting 𝑥2 = 0, 𝑥4 = 1 gives 𝑥1 = −2, 𝑥2 = 0, 𝑥3 = 2, 𝑥4 = 1 ⇒ 𝒙𝑇2 = [−2 0 2 1].
The eigenvector corresponding to the eigenvalue 𝜆2 = 2 is 𝒙𝑇3 = [𝑥1 𝑥2 𝑥3 𝑥4 ] such that:
−1 0 0 0 𝑥1 0
0 −1 5 −10 𝑥2 0
(𝐴 − 𝜆2 𝐼)𝒙3 = 0 ⇒ =
1 0 0 0 𝑥3 0
[1 0 0 1 ] [𝑥4 ] [0 ]
Using Gauss-Elimination method gives the augmented matrix:
−1 0 0 0 0 −1 0 0 0 0
0 −1 5 −10|0 𝑅1 + 𝑅3 0 −1 5 −10|0
→
1 0 0 0 |0 𝑅1 + 𝑅4 0 0 0 0 |0
[1 0 0 1 0] [0 0 0 1 0]
∴ 𝑥1 = 0, 𝑥4 = 0, 𝑥2 = 5𝑥3 .
Letting the free variable 𝑥3 = 𝑘 = 1 gives 𝑥2 = 5 ⇒ 𝒙𝑇3 = [0 5 1 0]
The eigenvector corresponding to the eigenvalue 𝜆3 = 4 is 𝒙𝑇4 = [𝑥1 𝑥2 𝑥3 𝑥4 ] such that:
−2 0 0 0 𝑥1 0
0 −2 5 −10 𝑥2 0
(𝐴 − 𝜆3 𝐼)𝒙4 = 0 ⇒ =
1 0 −1 0 𝑥3 0
[1 0 0 0 ] [𝑥4 ] [0 ]
62
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
63
Sinai University, Faculty of IT &CS === Linear Algebra (MA 110) === Prof. Reda S Tantawi
Exercise
1. Verify that which of the vectors 𝒙1𝑇 = [1 0 0], 𝒙𝑇2 = [0 −1 0], and 𝒙𝑇3 = [5 1 2] is
2 3 1
an eigenvector of the matrix 𝐴 = [0 −1 2] and find the corresponding eigenvalue.
0 0 3
2. Verify that which of the vectors 𝒙1 = [1 2 −1], 𝒙𝑇2 = [−2 1 0], and 𝒙𝑇3 = [3 0 0]
−2 2 −3
is an eigenvector of the matrix 𝐴 = [ 2 1 −6] and find the corresponding eigenvalue.
−1 −2 0
3. Verify that which of the vectors 𝒙1𝑇 = [1 0 −1], 𝒙𝑇2 = [1 2 0], and 𝒙𝑇3 = [−2 1 1]
4 −1 3
is an eigenvector of the matrix 𝐴 = [0 2 1] and find the corresponding eigenvalue.
0 0 3
4. Find the eigenvalues and corresponding eigenvectors of the matrices
2 1 0 2 0 0
4 −5
(𝑖)𝐴 = [ ] (ii)𝐴 = [0 2 0] (iii)𝐴 = [−1 1 0]
2 3
0 0 2 5 3 −3
1 3 0 2 1 0
(iv)𝐴 = [3 1 0] (𝑣) 𝐴 = [0 2 0]
0 0 −2 0 0 2
64