0% found this document useful (0 votes)
15 views30 pages

Lecture 4

This document discusses solving systems of linear algebraic equations using matrix notation. It defines key matrix concepts and operations used to represent systems of linear equations in matrix form. Specifically, it shows how a system of three equations with three unknowns can be written as a matrix equation Ax=b, with A as the coefficient matrix, x as the vector of unknowns, and b as the vector of constants. Solving linear systems in this matrix form allows applying techniques that perform the same operations to both the coefficient rows and corresponding elements of b.

Uploaded by

irayyn7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views30 pages

Lecture 4

This document discusses solving systems of linear algebraic equations using matrix notation. It defines key matrix concepts and operations used to represent systems of linear equations in matrix form. Specifically, it shows how a system of three equations with three unknowns can be written as a matrix equation Ax=b, with A as the coefficient matrix, x as the vector of unknowns, and b as the vector of constants. Solving linear systems in this matrix form allows applying techniques that perform the same operations to both the coefficient rows and corresponding elements of b.

Uploaded by

irayyn7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

10/04/2021

KING FAISAL UNIVERSITY


COLLEGE OF ENGINEERING

Engr310 – Numerical Methods for Engineers

Lecture 04: Linear Algebric Equations - Gauss Elimination



big 6- at it , WIJK .
Majdi Adel

Many of the fundamental


equations of engineering are
based on conservation laws (mass,
energy, momentum…)

In mathematical terms, this leads


to balance or continuity equations
that relate system behavior as
represented by the response of
the quantity being
Mass conservation can be used to model a series of
modeled to the properties or chemical reactors
characteristics of the system and Quantity being modeled: Mass of the chemical in each
the external stimuli or forcing reactor
functions acting on the system System properties: Reaction rates reactors’ sizes and flow
rates
forcing functions: feed rates into the system
Engr310 – Numerical Methods for Engineers Majdi Adel 2

1
10/04/2021
linear egu→a×+by+c=O " ↳ if

[email protected]
ax+by= - C

In this part we deal with the case of determining the values x1, x2, …, xn that
simultaneously satisfy a set of equations
𝑓 𝑥 ,𝑥 ,…,𝑥 =0
𝑓 𝑥 ,𝑥 ,…,𝑥 =0
.
.
.
𝑓 𝑥 ,𝑥 ,…,𝑥 =0
Where every equation is linear algebraic equation of the general form
𝑎 𝑥 + 𝑎 𝑥 + ⋯+ 𝑎 𝑥 = 𝑏
𝑎 𝑥 + 𝑎 𝑥 + ⋯+ 𝑎 𝑥 = 𝑏
.
.
.
𝑎 𝑥 + 𝑎 𝑥 + ⋯+ 𝑎 𝑥 = 𝑏
Engr310 – Numerical Methods for Engineers Majdi Adel 3

Mathematical Background ok 068196 @ ✗ e) 51

Row vectors Symmetric matrix (aij = aji for all i’s and j’s)
𝐵 = 𝑏 𝑏 ⋯ 𝑏 5 1 2
[ 137 ]
512
𝐴 = 1 3 7 →
Column vectors 2 7 8 278
𝑐
𝑐 Diagonal matrix any no
𝐶 = →
.

⋮ 𝑎 0 0
𝑐 𝐴 = 0 𝑎 0
Square matrix (n = m) 0 0 𝑎
𝑎 𝑎 𝑎 Identity matrix
𝐴 = 𝑎 𝑎 𝑎 1 0 0
𝑎 𝑎 𝑎 𝐼 = 0 1 0
0 0 1
cis 81=6*1,6
Engr310 – Numerical Methods for Engineers Majdi Adel 4

2
10/04/2021

Upper triangular matrix Matrix operations 6£ JIC;8


for size
𝐴 + 𝐵 = 𝐵+𝐴

Ef
𝑎 𝑎 𝑎 addition ← j

𝐴 = 𝑎 𝑎 𝐴 + 𝐵 + 𝐶 = 𝐴 + 𝐵 + 𝐶
𝑎 𝑔𝑎 𝑔𝑎 𝑔𝑎
𝑔𝐴 = 𝑔𝑎 𝑔𝑎 𝑔𝑎
Lower triangular matrix
𝑔𝑎 𝑔𝑎 𝑔𝑎
𝑎
JM # ↳ 81W
𝐴 = 𝑎 𝑎 Matrix product j @ is
𝑎 𝑎 𝑎 £94
a
𝐶 = 𝐴 𝐵 𝑐 = 𝑎 𝑏
Banded matrix
𝑎 𝑎 Multiplication of two matrices can be performed only if the
first matrix has as many columns as the number of rows in
𝑎 𝑎 𝑎
𝐴 = 𝑎 𝑎
the second matrix
𝑎
𝐴 × 𝐵 × = 𝐶 ×
𝑎 𝑎
Engr310 – Numerical Methods for Engineers Majdi Adel 5

Matrix product The transpose of a matrix involves


𝐴 𝐵 𝐶 = 𝐴 𝐵 𝐶 transforming its rows into columns and
its columns into rows
𝐴 𝐵 + 𝐶 = 𝐴 𝐶 + 𝐵 𝐶
𝑎 𝑎 𝑎
E-
𝐴 + 𝐵 𝐶 = 𝐴 𝐶 + 𝐵 𝐶 𝐴 = 𝑎 𝑎 𝑎 ↳ g) I
𝐴 𝐵 ≠ 𝐵 𝐴 𝑎 𝑎 𝑎
a- ☆ in
𝑎 𝑎 𝑎 .

Matrix division is not a defined operation. 𝐴 = 𝑎 𝑎 𝑎


However, if a matrix [A] is square and 𝑎 𝑎 𝑎
−1
nonsingular, there is another matrix [A] ,
called the inverse of [A], for which: Trace of a matrix is the sum of the
elements on its principal diagonal
𝐴 𝐴 = 𝐴 𝐴 = 𝐼
tr 𝐴 = 𝑎

Engr310 – Numerical Methods for Engineers Majdi Adel 6

3
10/04/2021

Linear Algebraic Equations in Matrix Form


Consider the following This system can be written as
% '

system of linear algebraic 𝐴 𝑋→ = 𝐵


omg
Vector of unknowns
equations j 1 1 1 𝑥 4 EH
𝑥 +𝑥 +𝑥 =4 2 1 3 𝑥 = 7 ①-

2𝑥 + 𝑥 + 3𝑥 = 7 3 1 6 𝑥 2
3𝑥 + 𝑥 + 6𝑥 = 2 Vector of constants
Matrix of coefficients si
Mol # f-
*I ID 'd
a. 6- µ ②j ①
It is useful to augment [A] with [B] since I 8>61
some techniques used for solving of linear c. 1 1 1 4
systems perform identical operations on a 2 1 3 7 →
② 215-8 6%

row of coefficients and the corresponding 3 1 6 2 4 ↳ wéb


constant txt &
Engr310 – Numerical Methods for Engineers Majdi Adel 7

Determinants
and Cramer’s
Rule
Engr310 – Numerical Methods for Engineers Majdi Adel 8

4
Crammer 's Rules from
Math for EE
10/04/2021

Ix pls b
Determinants
'

Determinants can be used to determine if the system has a unique solution or not.
They also can be used to solve the system
For the coefficient matrix [A], if:
0 𝑡ℎ𝑒 𝑠𝑦𝑠𝑡𝑒𝑚 ℎ𝑎𝑠 𝑛𝑜 𝑢𝑛𝑖𝑞𝑢𝑒 𝑠𝑜𝑙𝑢𝑡𝑖𝑜𝑛
÷ -
si am
ii.
𝑑𝑒𝑡 A = 6728
≠ 0 𝑡ℎ𝑒 𝑠𝑦𝑠𝑡𝑒𝑚 ℎ𝑎𝑠 𝑎 𝑢𝑛𝑖𝑞𝑢𝑒 𝑠𝑜𝑙𝑢𝑡𝑖𝑜𝑛
\
We define the determinant of the N x N matrix [A] as:
night
𝑑𝑒𝑡 A = … 𝐸 … 𝑎 , 𝑎 , …𝑎 ,

0 𝑖𝑓 𝑎𝑛𝑦 𝑡𝑤𝑜 𝑜𝑓 𝑖 , 𝑖 , … 𝑖 𝑎𝑟𝑒 𝑒𝑞𝑢𝑎𝑙


𝐸 … = +1 𝑖𝑓 𝑖 , 𝑖 , … 𝑖 𝑖𝑠 𝑎𝑛 𝑒𝑣𝑒𝑛 𝑝𝑎𝑟𝑖𝑡𝑦 𝑝𝑒𝑟𝑚𝑢𝑡𝑎𝑡𝑖𝑜𝑛
−1 𝑖𝑓 𝑖 , 𝑖 , … 𝑖 𝑖𝑠 𝑎𝑛 𝑜𝑑𝑑 𝑝𝑎𝑟𝑖𝑡𝑦 𝑝𝑒𝑟𝑚𝑢𝑡𝑎𝑡𝑖𝑜𝑛
Engr310 – Numerical Methods for Engineers Majdi Adel 9

For a 2 x 2 matrix For a 3 x 3 matrix


+ -
+
𝑎 𝑎 𝑎 𝑎 𝑎
𝐴 = 𝑎 𝑎 𝑎 𝑎 𝑎
𝐴 =
𝑎 𝑎 𝑎 𝑎 𝑎
𝐷= 𝑎 𝑎 𝑎 𝑎 𝑎
=𝑎 𝑎 −𝑎 𝑎 𝑎 𝑎 𝑎
𝐷=
𝑎 𝑎 𝑎
=𝑎 𝐷 −𝑎 𝐷 +𝑎 𝐷
9611b€
% 6) I > ☆I #
𝐷 =
𝑎 𝑎
↳ EM
1459 𝑎 𝑎
9611 ! 𝑎 𝑎
𝐷 = 𝑎 𝑎
𝑎 𝑎
𝐷 = 𝑎 𝑎

Engr310 – Numerical Methods for Engineers Majdi Adel 10

5
10/04/2021

Cramer’s Rule a×=b


921

÷ :] / ¥;] [ § ]
922 923
:

Each unknown in a system of linear algebraic equations may be expressed as a


fraction of two determinants with denominator D and with the numerator obtained
from D by replacing the column of coefficients of the unknown in question by the
constants b1, b2, …, bn

For a system of 3 equations (3 x 3 matrix)

𝑏 𝑎 𝑎 𝑎 𝑏 𝑎 𝑎 𝑎 𝑏
𝑏 𝑎 𝑎 𝑎 𝑏 𝑎 𝑎 𝑎 𝑏
𝑏 𝑎 𝑎 𝑎 𝑏 𝑎 𝑎 𝑎 𝑏
𝑥 = 𝑥 = 𝑥 =
𝐷 𝐷 𝐷
Cramer’s rule gives the exact solution to the system. However, for more than three equations, Cramer’s rule
becomes impractical because calculating the determinants is time consuming even by computers

Engr310 – Numerical Methods for Engineers Majdi Adel 11

Example
Use Cramer’s rule to solve the following linear system
𝑥 + 2𝑥 + 3𝑥 = 0
4𝑥 + 5𝑥 + 6𝑥 = 0
7𝑥 + 8𝑥 + 13𝑥 = 1

Engr310 – Numerical Methods for Engineers Majdi Adel 12

6
10/04/2021

Step 1: Rewrite in matrix form


1 2 3 0
4 5 6 0
7 8 13 1

Step 2: Calculate the determinant of the matrix of coefficients


1 2 3 5 6
𝐷 = = 5 13 − 6 8 = 17
𝐷= 4 5 6 8 13
7 8 13 4 6
= 1 𝐷 − 2 𝐷 + 3 𝐷 𝐷 = = 4 13 − 6 7 = 10
7 13
4 5
𝐷 = = 4 8 − 5 7 = −3
7 8
𝐷 = 1 17 − 2 10 + 3 −3 = −12

Since D ≠ 0, the matrix of coefficients is nonsingular and we have a unique solution to the system

Engr310 – Numerical Methods for Engineers Majdi Adel 13

Step 3: To calculate x1, replace the first column with the vector of constants and calculate the
determinant

0 2 3 0 6
𝐷 = = 0 13 − 6 1 = −6
𝐷= 0 5 6 1 13
1 8 13 0 5
= 0 𝐷 − 2 𝐷 + 3 𝐷 𝐷 = = 0 8 − 5 1 = −5
1 8

𝐷 = 0 − 2 −6 + 3 −5 = −3

0 2 3
0 5 6
−3
𝑥 = 1 8 13 = = 0.25
𝐷 −12

Engr310 – Numerical Methods for Engineers Majdi Adel 14

7
10/04/2021

Step 4: To calculate x2, replace the second column with the vector of constants and calculate the
determinant

1 0 3 0 6
𝐷 = = 0 13 − 6 1 = −6
𝐷= 4 0 6 1 13
7 1 13 4 0
= 1 𝐷 − 0 𝐷 + 3 𝐷 𝐷 = = 4 1 − 0 7 =4
7 1

𝐷 = 1 −6 − 0 + 3 4 = 6

1 0 3
4 0 6
𝑥 = 7 1 13 = 6 = −0.5
𝐷 −12

Engr310 – Numerical Methods for Engineers Majdi Adel 15

Step 5: To calculate x3, replace the third column with the vector of constants and calculate the
determinant

1 2 0 5 0
𝐷 = = 5 1 − 0 8 =5
𝐷= 4 5 0 8 1
7 8 1 4 0
= 1 𝐷 − 2 𝐷 + 0 𝐷 𝐷 = = 4 1 − 0 7 =4
7 1

𝐷 = 1 5 − 2 4 + 0 = −3

1 2 0
4 5 0
−3
𝑥 = 7 8 1 = = 0.25
𝐷 −12

Engr310 – Numerical Methods for Engineers Majdi Adel 16

8
10/04/2021

Gauss
Elimination

Engr310 – Numerical Methods for Engineers Majdi Adel 17

ñ Mdl :b 2

Deism 2
# AH it
matrixg ← &
upper triangular
Is ok
Gauss Elimination ( Row Echelon Form)
This approach can be Forward elimination
 Starting with the first row, add or
extended to a large system subtract multiples of that row to
of equations by developing eliminate the first coefficient from the
IMA # second row and beyond
a systematic algorithm to ¥  Continue this process with the second
upper triangular matrix
.

eliminate unknowns and to row to remove the second coefficient


from the third row and beyond
back substitute  Stop when an upper triangular matrix
0
remains
0 0

v. wisdom
8 @ b. Ml& Back substitution
 Starting with the last row, solve for
if 6
,
@ I Ñ_ the unknown, then substitute that
value into the next highest row
 Each row will contain only one more
unknown because it is an upper-
triangular
Engr310 – Numerical Methods for Engineers Majdi Adel 18

9
ibis # iii. µ
,
g. a viper triangular j ! A.
- : J WI I -0 'S
✗ + ✗ - ✗ =
1
, z }
3 ×, + ✗ -1 ✗ = 9
z 3
✗ -
✗ + 4 ✗ =
8
, z 3

.
:
As I & im I aids @I

1 : : :L :|
3 1 I

i.
Math for EE & id "

↳ É if 181 Hibi

[ §O ! ! / § ]
,
Rz =3 Ri
R} =
Rz
-

-
Ra
R, \
31 }
3 3
I
-

I -1 " ?o
1?
::÷
new
Rz
.

%
"
}
[ ! I
0
⑦ 5 µ]
7
R, = Rub
I 5
4
/
0 2 -

::
[ O
! I
o
-
I
I /¥ *
&
← a-
£
µ,
I
_Ñ I

: ✗ = I
}
.

i. 2 ✗z - Y X = 6
}
-


z
=

-61¥ = I

: .
✗ -1 ✗ -
✗ = I
, , }

✗ I 1- ✗ ✗
z
-
=
, }
= I + I -
C 1)- = 3
- 8,41 & it:-& @ a- A bit ↳ SW
" Ñ_ 1014 # b. is Wi:@ µ,
pivoting
element Pivoting egg

.

-
,

[f-11
I %' 'd MI%iz↳ , ↳

ds8.is/ Newts IWI


I I 4 8 pivoting equ
-

pivoting elements @ ← big


i. ji -61 10 pile
& I I

Ri=R ,
-

Caz / an )×R,
. -

µ #
"
d d I am
.

B) %
calm µ,
o.w.ly Pivoting JI &
I. WIKIA them Pivoting
@
.

egu
.

① 3- (3-1.1)×1=0 ② I - (3-1.1)×1=-2

③ I - (3%1)×-1=4 ⑨ 9- (3-11)×1=1

[ 1-148-0
'

I ]
'
11
"

0 -
2 4

ji-WI.be#[email protected]=Rz-(a31/an)XRi-
i.

' "
arm
g ↓ g.
~ #
.

g.
I
Pivoting

%
'm & , # dem
WWII ◦
.

pivoting i
µ #
eqa .
① I -
(1%1)×1=0 ② - I -
(1-1.1)×1=-2
③ 4- (1%1)×-1=5 ④ 8- (1%1)×1=7
' ' '

\
'

-
-

pivoting Pivoting equ


.

elem .

⑦ 0 5 7

i.
gjiog-ww-k.gl 2 -61
.

t.us#-2.gWlk1z.s-tpivotingequ. J.&R;--Rz-(azz
pivoting elem .

)✗R% / 922
'
Ms#
'
'd d ↓
µ ,
I -6
'

% '
µ Pivoting B)
* * 11
.

g. dem ' II &

µ # Pivoting eqa .

① -2 -
C -
2. ÷ -

2) ✗ -2=0 ② 5- C- 2 ÷ -27×4=1
③ 7- ( - 2. ÷ -
2) ✗ 6=1

[
' ' '

f]
-
'

0 -2 4 6 µ? # Ñ_↳
I
O O I
txt £

3=1 ✗
-
2×2+4×3=6 ✗ 2=-1

✗ ✗
2-

(+3=1 → ×
, =3
10/04/2021

Forward Elimination
𝑎 𝑎 … 𝑎 𝑏
𝑎 𝑎 … 𝑎 𝑏 Pivoting equation
⋮ ⋮ ⋱ ⋮ ⋮ Pivoting element
𝑎 𝑎 … 𝑎 𝑏
First elimination step is to eliminate the first
unknown x1, from the second through the nth
equations
𝑎
𝑅𝑎𝑤 = 𝑅𝑎𝑤 − 𝑅𝑎𝑤 𝑎 𝑎 … 𝑎 𝑏
𝑎
𝑎 0 𝑎 … 𝑎 𝑏
𝑅𝑎𝑤 = 𝑅𝑎𝑤 − 𝑅𝑎𝑤 ⋮ ⋮ ⋱ ⋮ ⋮
𝑎
0 𝑎 … 𝑎 𝑏
𝑎
𝑅𝑎𝑤 = 𝑅𝑎𝑤 − 𝑅𝑎𝑤
𝑎
Engr310 – Numerical Methods for Engineers Majdi Adel 19

Forward Elimination cont.


𝑎 𝑎 … 𝑎 𝑏
0 𝑎 … 𝑎 𝑏
⋮ ⋮ ⋱ ⋮ ⋮
0 𝑎 … 𝑎 𝑏
Second elimination step is to eliminate the Continue the elimination process until getting
second unknown x2, from the third through the an upper triangular matrix
nth equations 𝑎 𝑎 … 𝑎 𝑏
𝑎 0 𝑎 … 𝑎 𝑏
𝑅𝑎𝑤 = 𝑅𝑎𝑤 − 𝑅𝑎𝑤
𝑎 ⋮ ⋮ ⋱ ⋮ ⋮
𝑎 0 0 … 𝑎 𝑏
𝑅𝑎𝑤 = 𝑅𝑎𝑤 − 𝑅𝑎𝑤
𝑎

Engr310 – Numerical Methods for Engineers Majdi Adel 20

10
10/04/2021

Back Substitution
𝑎 𝑎 … 𝑎 𝑏
0 𝑎 … 𝑎 𝑏
⋮ ⋮ ⋱ ⋮ ⋮
0 0 … 𝑎 𝑏
Starting from the last raw to solve for xn

𝑏
𝑥 =
𝑎
This result is back-substituted into the (n − l)th equation to solve for xn−1. Repeat
this procedure to evaluate the remaining x’s

𝑏 −∑ 𝑎 𝑥
𝑥 = 𝑓𝑜𝑟 𝑖 = 𝑛 − 1, 𝑛 − 2, ⋯ , 1
𝑎

Engr310 – Numerical Methods for Engineers Majdi Adel 21

Example
Solve the following linear system using Gaussian elimination
𝑥 +𝑥 −𝑥 =1
3𝑥 + 𝑥 + 𝑥 = 9
𝑥 − 𝑥 + 4𝑥 = 8

Rewrite in matrix form


1 1 −1 1
3 1 1 9
1 −1 4 8

Engr310 – Numerical Methods for Engineers Majdi Adel 22

11
10/04/2021

Step 1: Eliminating x1 from second and third rows

1 −1 1
1
3 1
1 9
1 −1
4 8
3
𝑅𝑎𝑤 = 𝑅𝑎𝑤 − 𝑅𝑎𝑤 1 1 −1 1
1
0 −2 4 6
1
𝑅𝑎𝑤 = 𝑅𝑎𝑤 − 𝑅𝑎𝑤 0 −2 5 7
1

Step 2: Eliminating x2 from the third row


−2 1 1 −1 1
𝑅𝑎𝑤 = 𝑅𝑎𝑤 − 𝑅𝑎𝑤 0 −2 4 6
−2 0 0 1 1

Engr310 – Numerical Methods for Engineers Majdi Adel 23

Step 3: Back substitution

1 1 −1 1
0 −2 4 6
0 0 1 1
1
𝑥 = =1
1
6− 4 1
𝑥 = = −1
−2
1 − 1 −1 − −1 1
𝑥 = =3
1

Always substitute the solution set in the original system to check if it is correct or not

Engr310 – Numerical Methods for Engineers Majdi Adel 24

12
first method : -

10/04/2021

[% I -211-4 ]R [⑥ ¥1 ] ⑤ Y Is
-→[
's

1- }
◦ -
_

' ° ' " -


◦ ' " °

,
/4 Resp R, -6.5
0.25
-

, 0 -3.25
6 I 1 6 1 I 6
R3=6R ,
-

Rz→ o
④ -2.5 -9
find
[ 25-0-251-0 ]
To
R3=2Rz

'
's ✗ / Xz × :
R} →
'
, ,
}
.

-6.5
-

0 0 25-3-25 ✗ 3=-41
-4=1 0.25×2-3.25×3=-6.5
-

→ ✗ 2=-13
,
O O
-

y -
y
×,
-10.25×2-0.25×3=-0-5 →

1=3
Example
Solve the following linear system using Gaussian elimination
4𝑥 + 𝑥 − 𝑥 = −2
[
" ' "
5𝑥 + 𝑥 + 2𝑥 = 4
6𝑥 + 𝑥 + 𝑥 = 6
5
6
I

I
2
1
Y] 4
6
Second method :
Pivoting dens
-

"°ᵗiⁿdem
pivoting ego
I
.
.

[ ⑤fRi=R
If Ri :P }
,
-

-
Caz ,

Caz /a.) ✗ R
/ an )xR ,
-→[%|¥Piʳtiⁿe9tR}"=Rj
0-o-52.CM
-

( as ,
/
az )xRi ,

, ,

find

[ -11
at % ✗ ✗ 2) ×
I / :
}
.

→ ✗ 3=-41
-0.253.2s -4=1 6.5 ✗ 2=-13
g. 0.25×2+3.25×3 = →
O o -4 4 ✗ it
1×2-1×3=2 →

1=3
Engr310 – Numerical Methods for Engineers Majdi Adel 25

Example
Solve the following linear system using Gaussian elimination
3𝑥 − 0.1𝑥 − 0.2𝑥 = 7.85
0.1𝑥 + 7𝑥 − 0.3𝑥 = −19.3
0.3𝑥 − 0.2𝑥 + 10𝑥 = 71.4

Engr310 – Numerical Methods for Engineers Majdi Adel 26

13
10/04/2021

Ñ
.
.
b) I o a elim 1 NG
Pitfalls of Elimination Methods
HI → I 4
Division by Zero →
µ is pivoting y g Round-off Errors
dem .

Consider the following system of equations 1.00003 is not 1.0


2𝑥 + 3𝑥 = 8 Using more significant figures, will reduce the
error in the results. Round-off error can
4𝑥 + 6𝑥 + 7𝑥 = −3
become particularly important when solving
2𝑥 + 𝑥 + 6𝑥 = 5 large numbers of equations
Note that the first element a11 is zero.
Therefore, when doing the first elimination
step it will result in division by zero

Engr310 – Numerical Methods for Engineers Majdi Adel 27

Ill-Conditioned Systems Singular Systems


 Well-conditioned systems: Those where a It happens when two or more of the equations
small change in one or more of the are identical. This will result in n – 1 equations
coefficients results in a similar small change with n unknowns
in the solution
The determinant of a singular system is zero
 Ill-conditioned systems: Those where small
changes in coefficients result in large
changes in the solution Refer to the text book (Box 9.1) to see how to
It happens when two or more equations are use Gauss elimination to evaluate the
nearly identical, resulting in a wide ranges of determinant of a matrix
answers that approximately satisfy the e. g for ill conditioned : -

equations :&
i

, @
'M ÷ ] .
↳ .

It can be determined graphically when the


slopes of two or more equation are almost
equal or by calculating the determinant, if it is
close to zero; most probably the system is ill-
conditioned
Engr310 – Numerical Methods for Engineers Majdi Adel 28

ii. odi b w r si il-mllil.is 1 61 ☆


,
i.

C-
-
+

g- 14
10/04/2021

No solution Infinite solutions Ill-conditioned system

Engr310 – Numerical Methods for Engineers Majdi Adel 29

Pivoting
Gauss elimination may result in one or more of the coefficients on the main diagonal
(pivot element) are equal to zero (division by zero) or close to zero (round off errors)
To avoid this problem pivoting is used

Partial pivoting & t.at %! # A % # d) I e 6 All & Hi.

Switching the rows so that the largest element is the pivot element

Complete pivoting is 81 9 I'M" J H


Searching for the largest element in all rows and columns then switching
Rarely used because switching columns changes the order of the x’s and adds an
unjustified complexity to computer algorithms

Engr310 – Numerical Methods for Engineers Majdi Adel 30

15
10/04/2021

Example
Solve the following linear system using Gaussian elimination
0.0003𝑥 − 3.0000𝑥 = 2.0001
1.0000𝑥 − 1.0000𝑥 = 1.0000

First without pivoting, then by applying partial pivoting. Compare the results with the exact solution
of x1 = 1/3, x2 = 2/3. (use 4 decimal places)

0.0003 3.0000 2.0001


1.0000 1.0000 1.0000

Engr310 – Numerical Methods for Engineers Majdi Adel 31

Without pivoting
Step 1: Eliminating x1 from the second row
0%1 DX is ! b) I
0.0003 3.0000 2.0001
1.0000 1.0000 1.0000
1.0000 0.0003 3.0000 2.0001
𝑅𝑎𝑤 = 𝑅𝑎𝑤 − 𝑅𝑎𝑤
0.0003 0.0000 −9999 −6666

Step 2: Back substitution


−6666
𝑥 = = 0.6667
−9999
2.0001 − 3 0.6667
𝑥 = =0
0.0003

The answer is very sensitive to the number of significant digits used

Engr310 – Numerical Methods for Engineers Majdi Adel 32

16
10/04/2021

With pivoting: Switch the rows to make the pivot element a11 the largest
Step 1: Eliminating x1 from the second row
1.0000 1.0000 1.0000 I :@ go.MX Jw ↳ .

0.0003 3.0000 2.0001 b) I Ñ:b


0.0003 1.0000 1.0000 1.000
𝑅𝑎𝑤 = 𝑅𝑎𝑤 − 𝑅𝑎𝑤
1.0000 0.0000 9999 6666

Step 2: Back substitution


6666
𝑥 = = 0.6667
9999
1.0000 − 1 0.6667
𝑥 = = 0.3333
1.0000

The answer is not sensitive to the number of significant digits used

Engr310 – Numerical Methods for Engineers Majdi Adel 33

Without pivoting

With pivoting

Engr310 – Numerical Methods for Engineers Majdi Adel 34

17
10/04/2021

Scaling
In some cases, the coefficients of some equations in the system have much larger
magnitude than others. Therefore, scaling is used to minimize round-off errors in such
cases

Engr310 – Numerical Methods for Engineers Majdi Adel 35

Example
Solve the following linear system using Gaussian elimination
2.000𝑥 + 100000𝑥 = 100000
𝑥 + 𝑥 = 2.000

First without scaling, then by scaling the equations so that the maximum coefficient in each row is 1.
Compare the results with the exact solution of x1 = 1, x2 = 1. (use 3 decimal places)
É 1 ; }
g

2.000 100000 100000 IT


'

1.000 1.000 2.000


Scathing

you @ #
I

His WII

Engr310 – Numerical Methods for Engineers Majdi Adel 36

18
10/04/2021

Without scaling
Step 1: Eliminating x1 from the second row
@ @ & Scatting
jgw.sc
2.000 100000 100000 .

1.000 1.000 2.000 &


log
1.000 2.000 100000 100000
𝑅𝑎𝑤 = 𝑅𝑎𝑤 − 𝑅𝑎𝑤
2.000 0.000 −49999 −49998

Step 2: Back substitution


−49998
𝑥 = = 1.000
−49999
100000 − 100000 1.000
𝑥 = =0
100000

Engr310 – Numerical Methods for Engineers Majdi Adel 37

With scaling: Divide the first row by 100000


Step 1: Eliminating x1 from the second row
0.00002 1.000 1.000 We have to use pivoting here
1.000 1.000 2.000
1.000 1.000 2.000
0.00002 1.000 1.000
0.00002 1.000 1.000 2.000
𝑅𝑎𝑤 = 𝑅𝑎𝑤 − 𝑅𝑎𝑤
1.000 0.000 −1.000 −1.000
Step 2: Back substitution
−1.000
𝑥 = = 1.000
−1.000
2.000 − 1.000 1.000
𝑥 = = 1.000
1.000

Engr310 – Numerical Methods for Engineers Majdi Adel 38

19
10/04/2021

Gauss-Jordan

Engr310 – Numerical Methods for Engineers Majdi Adel 39

btw ① gl ,
Gauss -

Jorden

Gauss-Jordan
It is a variation of Gauss elimination. The difference is when an unknown is eliminated
in the Gauss-Jordan method, it is eliminated from all other equations. In addition, all
rows are normalized by dividing them by their pivot elements. Thus, the elimination
step results in an identity matrix rather than a triangular matrix

It is not necessary to employ back substitution to obtain the solution

Wig 1 MI
69@ 111 AH b- % Ij
y @ gl

Engr310 – Numerical Methods for Engineers Majdi Adel 40

20
10/04/2021

Example
Solve the following linear system using Gaussian-Jordan elimination
3𝑥 − 0.1𝑥 − 0.2𝑥 = 7.85
0.1𝑥 + 7𝑥 − 0.3𝑥 = −19.3
0.3𝑥 − 0.2𝑥 + 10𝑥 = 71.4

3 −0.1 −0.2 7.85


0.1 7 −0.3 −193
0.3 −0.2 10 71.4

Engr310 – Numerical Methods for Engineers Majdi Adel 41

Normalize the first raw by dividing by a11


3 −0.1 −0.2 7.85 1 −0.0333 −0.0667 2.6167
0.1 7 −0.3 −193 0.1 7 −0.3 −193
0.3 −0.2 10 71.4 0.3 −0.2 10 71.4

First reduction to remove x1 from the second and third rows


𝑅𝑎𝑤 = 𝑅𝑎𝑤 − 0.1 𝑅𝑎𝑤 1 −0.0333 −0.0667 2.6167
0 7.0033 −0.2993 −19.5617
𝑅𝑎𝑤 = 𝑅𝑎𝑤 − 0.3 𝑅𝑎𝑤
0 −0.1900 10.0200 70.6150

Normalize the second raw by dividing by a22


1 −0.0333 −0.0667 2.6167
0 1 −0.0419 −2.7932
0 −0.1900 10.0200 70.6150

Engr310 – Numerical Methods for Engineers Majdi Adel 42

21
10/04/2021

Second reduction to remove x2 from the first and third rows


1 −0.0333 −0.0667 2.6167
0 1 −0.0419 −2.7932
0 −0.1900 10.0200 70.6150
𝑅𝑎𝑤 = 𝑅𝑎𝑤 − −0.0333 𝑅𝑎𝑤 1 0 −0.0681 2.5236
0 1 −0.0419 −2.7932
𝑅𝑎𝑤 = 𝑅𝑎𝑤 − −0.1900 𝑅𝑎𝑤
0 0 10.0120 70.0843

Normalize the third raw by dividing by a33


1 0 −0.0681 2.5236
0 1 −0.0419 −2.7932
0 0 1 7.0000

Engr310 – Numerical Methods for Engineers Majdi Adel 43

Third reduction to remove x3 from the first and second rows


1 0 −0.0681 2.5236
0 1 −0.0419 −2.7932
0 0 1 7.0000
𝑅𝑎𝑤 = 𝑅𝑎𝑤 − −0.0681 𝑅𝑎𝑤 1 0 0 3.0000
0 1 0 −2.5000
𝑅𝑎𝑤 = 𝑅𝑎𝑤 − −0.0419 𝑅𝑎𝑤
0 0 1 7.0000

𝑥 = 3.0000
𝑥 = −2.5000
𝑥 = 7.0000

Engr310 – Numerical Methods for Engineers Majdi Adel 44

22
10/04/2021

Example
Solve the following linear system using Gaussian-Jordan elimination
𝑥 −𝑥 =2
2𝑥 − 𝑥 − 𝑥 = 3
𝑥 +𝑥 +𝑥 =6

The answer is x1 = 3, x2 = 1, x3 = 2

Engr310 – Numerical Methods for Engineers Majdi Adel 45

23

You might also like