LEC 3 Matries Direct Method
LEC 3 Matries Direct Method
Chapter -3-
Direct Methods for Solving Linear Systems
3.1 Introduction
Linear systems of equations are associated with many problems in engineering and science,
as well as with applications of mathematics to the social sciences and the quantitative study
of business and economic problems.
A linear system of n equations in n unknowns 𝑥1 , 𝑥2 , … , 𝑥𝑛 is a set of equations
𝐸1 , 𝐸2 , … , 𝐸𝑛 of the form
𝐸1 : 𝑎11 𝑥1 + ⋯ + 𝑎1𝑛 𝑥𝑛 = 𝑏1
𝐸2 : 𝑎21 𝑥1 + ⋯ + 𝑎2𝑛 𝑥𝑛 = 𝑏2
(1)
… … … … … … … … … … … … … … ..
𝐸𝑛 : 𝑎𝑛1 𝑥1 + ⋯ + 𝑎𝑛𝑛 𝑥𝑛 = 𝑏𝑛
where the coefficients 𝑎𝑗𝑘 , & 𝑏𝑗 re given numbers. The system is called homogeneous
if all the 𝑏𝑗 are zero; otherwise, it is called nonhomogeneous. Using matrix multiplication
the equation (1) will be written as a single vector equation
𝐴𝑥 = 𝑏 (2)
Where
𝑎11 𝑎12 … 𝑎1𝑛 𝑥1 𝑏1
𝑎21 𝑎22 … 𝑎2𝑛 𝑥2 𝑏
𝐴=[… … … … ], 𝑎𝑛𝑑 𝑥 = [ … ] , 𝑎𝑛𝑑 𝑏 = [ 2 ]
…
𝑎𝑛1 𝑎𝑛2 … 𝑎𝑛𝑛 𝑥𝑛 𝑏𝑛
he following matrix 𝐴̃ is called the augmented matrix of the system (1):
𝑎11 𝑎12 … 𝑎1𝑛 𝑏1
𝑎 𝑎22 … 𝑎2𝑛 𝑏2
𝐴̃ = [𝐴 𝑏] = [ 21 ]
… … … … …
𝑎𝑛1 𝑎𝑛2 … 𝑎𝑛𝑛 𝑏𝑛
19
Engineering College Chemical Engineering Dept.
backward substitution can be performed. Solving the nth equation for xn gives
𝑏𝑛
𝑥𝑛 =
𝑎𝑛𝑛
Solving the n-1th equation for xn-1 gives
𝑏𝑛 − 𝑎𝑛−1,𝑛 𝑥𝑛
𝑥𝑛−1 =
𝑎𝑛−1,𝑛−1
20
Engineering College Chemical Engineering Dept.
6 2 8 26
(2)
𝐴 = [0 4 −2|−5] (𝐸3 − 2 ∗ 𝐸2 ) → 𝐸3
0 8 2 −7
6 2 8 26
𝐴(3) = [0 4 −2|−5]
0 0 6 3
Back substitution. Determination of 𝑥1 , 𝑥2 , 𝑥3
3 1
𝑥3 = =
6 2
21
Engineering College Chemical Engineering Dept.
1 1
4𝑥2 − 2𝑥3 = −5 → 𝑥2 = ∗ (−5 + 2 ∗ ) = −1
4 2
1 1
6𝑥1 + 2𝑥2 + 8𝑥3 = 26 → 𝑥1 = (26 − (2 ∗ −1) − 8 ∗ ) = 4
6 2
Example 2: Solve the system
𝐸1 : 𝑥1 + 𝑥2 + 3 𝑥4 = 4 ,
𝐸2 : 2𝑥1 + 𝑥2 − 𝑥3 + 𝑥4 = 1,
𝐸3 : 3𝑥1 − 𝑥2 − 𝑥3 + 2𝑥4 = −3,
𝐸4 : − 𝑥1 + 2 𝑥2 + 3𝑥3 − 𝑥4 = 4
Sol.
1 1 0 3 4
2 1 −1 1 1
𝐴(1) =[ | ]
3 −1 −1 2 −3
−1 2 3 −1 4
Elimination of 𝑥1
(𝐸2 − 2 ∗ 𝐸1 ) → 𝐸2
(𝐸3 − 3 ∗ 𝐸1 ) → 𝐸3
(𝐸4 + 𝐸1 ) → 𝐸4
1 1 0 3 4
0 −1 −1 −5 −7
𝐴(2) =[ | ]
0 −4 −1 −7 −15
0 3 3 2 8
Elimination of 𝑥2
(𝐸3 − 4 ∗ 𝐸2 ) → 𝐸3
(𝐸4 + 3 ∗ 𝐸2 ) → 𝐸4
1 1 0 3 4
0 −1 −1 −5 −7
𝐴(3) =[ | ]
0 0 3 13 13
0 0 0 −13 −13
Back substitution. Determination of 𝑥1 , 𝑥2 , 𝑥3 & 𝑥4
22
Engineering College Chemical Engineering Dept.
−13 𝑥4 = −13 → 𝑥4 = 1
3𝑥3 + 13 𝑥4 = 13 → 𝑥3 = 0
−𝑥2 − 𝑥3 − 5 𝑥4 = −7 → 𝑥2 = 2
𝑥1 + 𝑥2 + 3 𝑥4 = 4 → 𝑥1 = −1
23
Engineering College Chemical Engineering Dept.
24
Engineering College Chemical Engineering Dept.
This is clearly a contrived example and the graph demonstrate why the error can so easily
occur, but for only slightly larger systems it is much more difficult to predict in advance
when devastating round-off error can occur.
The simplest strategy is to select, at the ith step, the element in the same column that is
below the diagonal and has the largest absolute value; that is, to determine the smallest
p≥ i such that
|𝑎𝑝𝑖 | = max |𝑎𝑘𝑖 |
𝑖≤𝑘≤𝑛
25
Engineering College Chemical Engineering Dept.
Note:
1- The technique just described is called partial pivoting, or maximal column Pivoting.
2- Although partial pivoting is sufficient for many linear systems, situations do arise when
it is inadequate.
3.3.1 scaled partial pivoting
The first step in this procedure is to define a scale factor sP for each row:
𝑆𝑘 = max |𝑎𝑘𝑗 |
𝑖≤𝑘≤𝑛
The appropriate row interchange to place zeros in the first column is determined by
choosing the first integer p with
𝑎𝑝1 |𝑎𝑘1 |
= max
𝑆𝑝 𝑖≤𝑘≤𝑛 𝑆𝑘
and performing (E1)↔(Ep). The effect of scaling is to ensure that the largest element in
each row has a relative magnitude of 1 before the comparison for row interchange is
performed.
In a similar manner, before eliminating variable xi using the operations
Ek −mkiEi → Ek for k = i +1,...,n
we select the smallest integer p ≥ i with
𝑎𝑝𝑖 |𝑎𝑘𝑖 |
= max
𝑆𝑝 𝑖≤𝑘≤𝑛 𝑆𝑘
27
Engineering College Chemical Engineering Dept.
28
Engineering College Chemical Engineering Dept.
𝐸2 − 𝐸1 → 𝐸2 & 𝐸3 − 6 ∗ 𝐸1 → 𝐸3
4 10
1 1
3 3
𝐴(3) = 11 | 11
0 −2
3 3
[0 −5 1 −5]
3
∗ 𝐸 → 𝐸2
11 2
4
1 1 10
3 3
𝐴(4) = 6| 1
0 1 −
11
[0 −5 1 −5]
4
𝐸1 − 𝐸2 → 𝐸1 & 𝐸3 + 5 ∗ 𝐸2 → 𝐸3
3
19
1 0
11 2
|
𝐴(5) = 0 1 − 6 1
11|
19 0
[ 0 0 −
11 ]
6
𝐸1 + 𝐸3 → 𝐸1 & 𝐸2 − 𝐸3 → 𝐸2
19
1 0 0 2
𝐴(6) = [0 1 0 |1]
19
0 0 −
11 0
−11
∗ 𝐸3 → 𝐸3
19
1 0 02
(7)
𝐴 = [0 1 0|1]
0 0 10
𝑥1 = 2, 𝑥2 = 1&𝑥3 = 0
30
Engineering College Chemical Engineering Dept.
Example7. Solve the following linear system & find the inverse matrix using Gauss-Jordan
elimination method
2𝑥1 − 7𝑥2 + 4 𝑥3 = 9
𝑥1 + 9𝑥2 − 6𝑥3 = 1
−3𝑥1 + 8𝑥2 + 5𝑥3 = 6
Sol.
2 −7 4 9 1 0 0
(1)
𝐴 =[ 1 9 −6| 1 |0 1 0]
−3 8 5 6 0 0 1
1
∗ 𝐸 → 𝐸1
2 1
1 −7/2 2 9/2 1/2 0 0
[1 9 −6| 1 | 0 1 0]
−3 8 5 6 0 0 1
𝐸2 − 𝐸1 & 𝐸3 + 3 ∗ 𝐸1
1 −7/2 2 9/2 1/2 0 0
[0 25/2 −8| −7/2 |−1/2 1 0]
0 −5/2 11 39/2 3/2 0 1
2
∗ 𝐸 → 𝐸2
25 2
1 −7/2 2 9/2 1/2 0 0
[0 1 −16/25| −7/25 |−1/25 2/25 0]
0 −5/2 11 39/2 3/2 0 1
7 5
𝐸1 + 𝐸2 & 𝐸3 + ∗ 𝐸2
2 2
1 0 −6/25 88/25 9/25 7/25 0
[0 1 −16/25| −7/25 |−1/25 2/25 0]
0 0 47/5 94/2 7/5 1/5 1
5
∗ 𝐸 → 𝐸3
47 3
31
Engineering College Chemical Engineering Dept.
32