0% found this document useful (0 votes)
11 views29 pages

Class Session File

Uploaded by

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

Class Session File

Uploaded by

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

College of Engineering and Computer Science

Department of Architectural Engineering & IT


Lebanese French University

Numerical Analysis
Lesson #: 2
Title: Gauss elimination method matrix

Spring Semester 2024 – 2025


Instructor: Dr. Mohammed Fadhil Hama
Solving System of linear equations
by numerical analysis – using
matrix
We can use the gauss elimination method

Steps to find unknowns in set of linear equations by matrix method:

1. Find systems of linear equations

2. Change to matrix form

3. Change to special matrix

4. Solve it (preferably by computer)


1. System of linear equations
We would need a collection of linear equations

Number equations must ≥ number of unknowns


Solving systems of linear equations means:
To find a value to each of the unknown variables
i.e. x, y, and z
Solving System of linear equations
by numerical analysis – using
matrix
Steps to find unknowns in set of linear equations by matrix

method:

1. Find systems of linear equations

2. Change to matrix form (exercise in next slides)

3. Change to special matrix

4. Solve it (preferably by computer)


2. Change to matrix form
• Using matrix forms A∙x = b

Matrix Size of A:
Rows = number of linear
equations
Columns = number of variables
Exercise – change linear equation to
matrix form

3 x + 4 y =3
5 y +2 x =7
Exercise – change linear equation to
matrix form
Exercise – change linear equation to
matrix form
− x +7 y=40 4 y +3 z =8
2 4 y +2 z=− 10 5 y +2 x =−7
z −9 y + 3 x=1 8 x −2 z +3 y =5
Solving System of linear equations
by numerical analysis – using matrix
Steps to find unknowns in set of linear equations by matrix

method:

1. Find systems of linear equations

2. Change to matrix form

3. Change to special matrix ( in next slides)

4. Solve it (preferably by computer)


3. Change to special matrix
Special matrixes

1. Identity matrix

2. Diagonal matrix

3. Upper triangular matrix

4. Lower triangular matrix


Change to special matrix
1 – Identity matrix
Solution:

[ ][ ] [ ]
1 0 0 𝑥 𝑎 a=x
0 1 0 𝑦 = 𝑏
The
b=y
0 0 1 𝑧 𝑐 diagonal is
c=z
always 1.
Change to special matrix
2 – Diagonal matrix
Solution

[ ][ ] [ ]
𝑎 11 0 0 𝑥 𝑎 steps:
0 𝑎22 0 𝑦 = 𝑏 a₁₁x + 0y +
𝑧 𝑐 0z= a
0 0 𝑎33
a₁₁x = a
x = a/a₁₁ x = a/a₁₁
in the
Y = b/a₂₂ diagonal are
Z = c/a₃₃ any numbers
Change to special matrix
3 – upper triangular matrix

[ ][ ] [ ]
𝑎 11 𝑎1 2 𝑎1 3 𝑥 𝑎
0 𝑎 22 𝑎1 3 𝑦 = 𝑏
0 0 𝑎 33 𝑧 𝑐 This process is
called:
Backward
Start with: substitution
z = c/₃₃ Diagonal cannot be
Then go up to find y, zero!
then
Change to special matrix
4 – lower triangular matrix

[ ][ ] [ ]
𝑎 11 0 0 𝑥 𝑎
𝑎 21 𝑎 22 0 𝑦 = 𝑏 This process is
𝑎 31 𝑎3 2 𝑎 33 𝑧 𝑐 called:
forward substitution
Start with: Diagonal cannot be
x = a/a₁₁ zero!
Then go down to find y, then
Special matrixes

1. Identity matrix
Important note:
2. Diagonal matrix In any of these 4 special
matrixes, the determinant
cannot be equal to zero!
3. Upper triangular matrix
That means none of the
diagonal values can be
(preferred)
zero.

4. Lower triangular matrix You are allowed to


Example with upper triangular
matrix using Gauss elimination
Gauss elimination:
1. Create the matrix form
2. Change the elements below the diagonal to zero
( 𝑦𝑜𝑢 𝑤𝑎𝑛𝑡 𝑡𝑜 𝑚𝑎𝑘𝑒 𝑧𝑒𝑟𝑜 ) −(𝑅𝑜𝑤 1 𝑣𝑎𝑙𝑢𝑒 𝑜𝑓 𝑡h𝑎𝑡 𝑐𝑜𝑙𝑢𝑚𝑛 𝑓𝑟𝑜𝑚 𝑑𝑖𝑎𝑔𝑜𝑛𝑎𝑙)׿
-> do this for ever column in that row
-> blue color indicates scaling factor, it does not change

[ ][ ] [ ]
𝑎 11 𝑎1 2 𝑎1 3 𝑥 𝑎
0 𝑎 22 𝑎1 3 𝑦 = 𝑏
0 0 𝑎 33 𝑧 𝑐

3. Use backward substitution to solve for the unknowns (x, y, z)


Example with upper triangular
matrix using Gauss elimination
y + 2z = 4
2x + 4y +z = 1
3x +2y +z = 2
Example with upper triangular
matrix using Gauss elimination
y + 2z = 4
2x + 4y +z = 1
3x +2y +z = 2

[ ][ ] [ ]
0 1 2 𝑥 4
2 4 1 𝑦 = 1 Is this
3 2 1 𝑧 2 correct?
Example with upper triangular
matrix using Gauss elimination
y + 2z = 4
2x + 4y +z = 1
3x +2y +z = 2

[ ][ ] [ ]
2 4 1 𝑥 1 Change the
0 1 2 𝑦 = 4 rows, why?
3 2 1 𝑧 2
Example with upper triangular
matrix using Gauss elimination

[ ][ ] [ ]
(you want to make zero) – (Row1 value of that 2 4 1 𝑥 1
column from diagonal)x[(you want to make 0 1 2 𝑦 = 4
zero) / (Row1 value of that column from 3 2 1 𝑧 2
diagonal)]
[3 – 2x(3/2)] multiply this by
[2 – 4x(3/2)] multiply this by
[1 – 1x(3/2)] multiply this by
[2 – 1x(3/2)] multiply this by
Diagonal
part

Scaling factor: remains the same


Example with upper triangular
matrix using Gauss elimination

[ ][ ] [ ]
(you want to make zero) – (Row1 value of that
2 4 1 𝑥 1
column from diagonal)x[(you want to make
zero) / (Row1 value of that column from 0 1 2 𝑦 = 4
diagonal)] 3 2 1 𝑧 2
[3 – 2x(3/2)] = 0
[2 – 4x(3/2)] = -4

[ ][ ] [ ]
[1 – 1x(3/2)] = -1/2
2 4 1 𝑥 1
[2 – 1x(3/2)] = 1/2
0 1 2 𝑦 = 4
Now make this
0 −4 −1/ 2 𝑧 1/ 2
zero (next slide)
Example with upper triangular
matrix using Gauss elimination

[ ][ ] [ ]
2 4 1 𝑥 1
Diagonal
part
0 1 2 𝑦 = 4
0 −4 −1/ 2 𝑧 1/ 2

[-4 – 1x(-4/1)] multiply this by


[-1/2 – 2x(-4/1)] multiply this by
[1/2 – 4x(-4/1)] multiply this by
Example with upper triangular
matrix using Gauss elimination

[ ][ ] [ ]
2 4 1 𝑥 1
0 1 2 𝑦 = 4
0 −4 −1/ 2 𝑧 1/ 2

[-4 – 1x(-4/1)] = 0
[-1/2 – 2x(-4/1)] = 15/2

[ ][ ] [ ]
[1/2 – 4x(-4/1)] = 33/2 2 4 1 𝑥 1
0 1 2 𝑦 = 4
0 0 15 / 2 𝑧 33/ 2
Example with upper triangular
matrix using Gauss elimination
Looks like this

[ ][ ] [ ] [ ][ ] [ ]
2 4 1 𝑥 1 𝑎 11 𝑎1 2 𝑎1 3 𝑥 𝑎
0 1 2 𝑦 = 4 0 𝑎 22 𝑎1 3 𝑦 = 𝑏
0 0 𝑎 33 𝑧 𝑐
0 0 15 / 2 𝑧 33/ 2
(15/2) z = (33/2)(from row 3)
z = 33/15
y + 2z = 4 (from row 2)
y + 2(33/15) = 4 Proof the values are
y = (-6/15) correct:
2x + 4y + z = 1 (from row 1) y + 2z = 4
2x + 4(-6/15) + (33/15) = 1 2x + 4y +z = 1
x = 3/15 3x +2y +z = 2
Classwork question
solve with upper triangular matrix using Gauss
elimination

Find x and y:
2x + 3y = 4
4x +9y = 6
Example with upper triangular
matrix using Gauss elimination

[ ][ ] [ ]
Find x and y: 2 3 𝑥 4
2x + 3y = 4 =
4x +9y = 6 4 9 𝑦 6

[4 – 2x(4/2)] = 0
[9 – 3x(4/2)] = 3
[6 – 4x(4/2)] = -2
[ 2
0
3
3 ][ ] [ ]
𝑥
𝑦
=
4
−2
Example with upper triangular
matrix using Gauss elimination
Find x and y:
2x + 3y = 4
4x +9y = 6 [ 2
0
3
3 ][ ] [ ]
𝑥
𝑦
=
4
−2

3y = -2 (from row
2)
Proof the values are
y = -2/3
correct:
2x + 3y = 4 (from
2x + 3y = 4
row 1)
4x +9y = 6
2x+ 3(-2/3) = 4
Classwork question
solve with upper triangular matrix using Gauss
elimination
End of Class

Thank you, Any questions?

You might also like