Professional Documents
Culture Documents
MAFE208IU-L5 - Linear Systems of Equations - Part 2
MAFE208IU-L5 - Linear Systems of Equations - Part 2
MAFE208IU-L5 - Linear Systems of Equations - Part 2
Systems of Equations
Lecture 2
Gauss-Seidel iteration Method
Gauss-Seidel Method
Description
A set of n equations and n unknowns:
The diagonal elements are non-
a11x1 + a12 x2 + a13x3 + ... + a1n xn = b1 zero
a21x1 + a22 x2 + a23x3 + ... + a2n xn = b2 Rewrite each equation solving
. .
. . for the corresponding unknown
. .
ex:
an1x1 + an 2 x2 + an3 x3 + ... + ann xn = bn
First equation, solve for x1
Second equation, solve for x2
MAFE208IU-L5 2
Gauss-Seidel Method
Transformation
Rewriting each equation
b − a x − a x − a1n xn From Equation 1
x1 = 1 12 2 13 3
a11
b2 − a21x1 − a23 x3 − a2 n xn
x2 = From equation 2
a22
b − a x − a x − an −1,n− 2 xn − 2 − an −1,n xn From equation n-1
xn −1 = n −1 n −1,1 1 n −1,2 2
an −1,n−1
bn − an1 x1 − an 2 x2 − − an,n−1 xn −1 From equation n
xn =
ann
MAFE208IU-L5 3
Algorithm for Gauss-Seidel Method
Let x ( k ) = ( x1( k ) , x2( k ) ,...., xn( k ) ) be a given approximate value,
k = 0,1, 2,..., we compute the new approximate value x ( k +1) :
n n
aii aij for all ‘i’ and aii aij for at least one ‘i’
j =1 j =1
j i j i
MAFE208IU-L5 8
Comments on Gauss-Seidel
• Disadvantages:
– it may not converge
– When it converged, it did so very slowly
• Advantages:
– When matrix is very sparse (most elements are
zero), elimination methods waste large amount of
computer memory by storing zeros
– Gauss-Seidel method saves memory because only
nonzero coefficients are involved in the structure
of equations
MAFE208IU-L5 9
Exercise 1
Solve the following system
5 x1 − 2 x2 = 1
x1 + 8 x2 − 2 x3 = 11
− x2 + 7 x3 − 2 x4 = 11
−2 x3 + 5 x4 = 14
Using
a) LU decomposition method
b) Gauss-Seidel iteration method
Use x (0) =(1,1,1,1), stopping condition: | Ea | 0.02
MAFE208IU-L5 10
Exercise 4
Using Gauss-Seidel iteration method, solve the following system
8 x1 + 3 x2 = −21
x1 − 5 x2 + 2 x3 = 10
− x2 + 6 x3 + 2 x4 = 71
3 x3 − 5 x4 + 2 x5 = −2
−2 x4 + 5 x5 = 22
Use x (0) =(1,2,3,4,5), stopping condition: | Ea | 0.05
MAFE208IU-L5 11
Ex 2: Find temperature in a square sheet of metal. The temperature
at the edges of the sheet are kept at : 200, 100, 50, and 0 degrees.
T1,3 = 200 T2,3 = 200
T1,1 T2,1
T0,1 = 100 T3,1 = 50
T1,0 = 0 T2,0 = 0
Temperature at grid points: Ti +1, j + Ti −1, j + Ti , j +1 + Ti , j −1 − 4Ti , j = 0
MAFE208IU-L14 Solve by Gauss-Seidel method, use |𝐸𝑎 | ≤ 0.512
T1,3 = 200 T2,3 = 200
Quiz
Find temperature in a
square sheet of metal.
T0,2 = 10m T1, 2 T2, 2 T3,2 = 10n
The temperature at
edges of the sheet are
kept as in Figure T0,1 = 5m T1,1 T2,1 T3,1 = 5n
Approximate T
at grid points
Temperature at grid points:
T1,0 = 0 T2,0 = 0
Ti +1, j + Ti −1, j + Ti , j +1 + Ti , j −1 − 4Ti , j = 0
mn = The last two digits
Solve by a) Gauss elimination of your student ID number
b) LU decomposition method
c) Gauss-Seidel method, use |𝐸𝑎 | ≤ 0.5
MAFE208IU-L14 13