You are on page 1of 12

EPF 3109

Computer and Numerical


Methods

Solving a System of Linear


Equations
Overview of Numerical Methods for Solving a System of Linear
Algebraic Equations
Direct methods

Upper triangle Lower triangle

Diagonal
Gauss elimination method

Gauss elimination procedure


Gauss elimination method
Issues
Gauss elimination with pivoting
Solving Linear Equations using Gauss Elimination Method

EXAMPLE 1: Solve following system of three linear equations

−4𝑥𝑥 + 3𝑦𝑦 + 𝑧𝑧 = −18.2 Eq. 1


5𝑥𝑥 + 6𝑦𝑦 − 2𝑧𝑧 = −48.8 Eq. 2
2𝑥𝑥 − 5𝑦𝑦 + 4.5𝑧𝑧 = −92.5 Eq. 3

Analytical Solution
−5
Multiply Eq. 1 with ( ) and subtract the result from Eq. 2
4

5𝑥𝑥 + 6𝑦𝑦 − 2𝑧𝑧 = −48.8


5𝑥𝑥 − 3.75𝑦𝑦 − 1.25𝑧𝑧 = 22.75

9.75𝑦𝑦 − 0.75𝑧𝑧 = −71.55 Eq.4


−2
Multiply Eq. 1 with ( ) and subtract the result from Eq. 3
4
2𝑥𝑥 − 5𝑦𝑦 + 4.5𝑧𝑧 = −92.5
2𝑥𝑥 − 1.5𝑦𝑦 − 0.5𝑧𝑧 = 9.1

-3.5𝑦𝑦 + 5𝑧𝑧 = −101.6 Eq. 5


−3.5
Multiply Eq. 4 with ( ) and subtract the result from Eq. 5
9.75

-3.5𝑦𝑦 + 5𝑧𝑧 = −101.6


-3.5𝑦𝑦 + 0.27𝑧𝑧 =25.68

4.73𝑧𝑧 = −127.28
Eq. 6
−4𝑥𝑥 + 3𝑦𝑦 + 𝑧𝑧 = −18.2
−4 3 1 −18.2
9.75𝑦𝑦 − 0.75𝑧𝑧 = −71.55 0 9.75 −0.75 = −71.55
0 0 4.73 −127.28
4.73𝑧𝑧 = −127.28

Then, solve using back-substitution


𝒛𝒛 = −𝟐𝟐𝟐𝟐. 𝟗𝟗

9.75𝑦𝑦 − 0.75(−26.9) = −71.55

𝒚𝒚 = −𝟗𝟗. 𝟒𝟒𝟒𝟒

−4𝑥𝑥 + 3(−9.41) + (−26.9) = −18.2

x= −𝟗𝟗. 𝟐𝟐𝟐𝟐
Check your ANSWER
x = −𝟗𝟗. 𝟐𝟐𝟐𝟐
𝒚𝒚 = −𝟗𝟗. 𝟒𝟒𝟒𝟒
𝒛𝒛 = −𝟐𝟐𝟐𝟐. 𝟗𝟗

−4𝑥𝑥 + 3𝑦𝑦 + 𝑧𝑧 = −18.2


−4𝑥𝑥 + 3𝑦𝑦 + 𝑧𝑧 = −18.21
5𝑥𝑥 + 6𝑦𝑦 − 2𝑧𝑧 = −48.8
5𝑥𝑥 + 6𝑦𝑦 − 2𝑧𝑧 = −48.81
2𝑥𝑥 − 5𝑦𝑦 + 4.5𝑧𝑧 = −92.5
2𝑥𝑥 − 5𝑦𝑦 + 4.5𝑧𝑧 = −𝟗𝟗𝟗𝟗. 𝟒𝟒𝟒𝟒
Solving Linear Equations using Gauss Elimination Method

EXAMPLE 1: Solve following system of three linear equations

−4𝑥𝑥 + 3𝑦𝑦 + 𝑧𝑧 = −18.2 Eq. 1


5𝑥𝑥 + 6𝑦𝑦 − 2𝑧𝑧 = −48.8 Eq. 2
2𝑥𝑥 − 5𝑦𝑦 + 4.5𝑧𝑧 = −92.5 Eq. 3
Numerical Solution (using Octave/Matlab)
−4 3 1 𝑥𝑥 −18.2
5 6 −2 𝑦𝑦 = −48.8
2 −5 4.5 𝑧𝑧 −92.5

Ax=B
A = [-4 3 1;5 6 -2;2 -5 4.5] x= [x ; y ; z]

B = [-18.2; -48.8; -92.5]


Program codes
Command Window
>>
input matrix left : [-4 3 1;5 6 -2;2 -5 4.5]
input matrix right : [-18.2; -48.8; -92.5]
The x, y and z value :
-9.2325
-9.4081
-26.9057

You might also like