Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
1
Gauss-Seidel Method
An iterative method.
Basic Procedure:
-Algebraically solve each linear equation for xi
-Assume an initial guess solution array
-Solve for each xi and repeat
-Use absolute relative approximate error after each iteration
to check if error is within a pre-specified tolerance.
http://numericalmethods.eng.usf.edu
Gauss-Seidel Method
Why?
The Gauss-Seidel Method allows the user to control round-off error.
http://numericalmethods.eng.usf.edu
Gauss-Seidel Method
Algorithm
A set of n equations and n unknowns:
If: the diagonal elements are
a11 x1 a12 x2 a13 x3 ... a1n xn b1 non-zero
a21 x1 a22 x2 a23 x3 ... a2n xn b2 Rewrite each equation solving
. .
. . for the corresponding unknown
. .
ex:
an1 x1 an 2 x2 an 3 x3 ... ann xn bn
First equation, solve for x1
Second equation, solve for x2
http://numericalmethods.eng.usf.edu
Gauss-Seidel Method
Algorithm
Rewriting each equation
c a12 x 2 a13 x3 a1n x n From Equation 1
x1 1
a11
c2 a21 x1 a23 x3 a2 n xn
x2 From equation 2
a22
cn 1 an 1,1 x1 an 1, 2 x2 an 1, n 2 xn 2 an 1,n xn From equation n-1
xn 1
an 1,n 1
cn an1 x1 an 2 x2 an ,n 1 xn 1 From equation n
xn
ann
http://numericalmethods.eng.usf.edu
Gauss-Seidel Method
Algorithm
General Form of each equation
n n
c1 a1 j x j cn 1 a
j 1
n 1, j xj
j 1
j n 1
x1
j 1 xn 1
a11 an 1,n 1
n
c n a nj x j
n
c2 a2 j x j
j 1 j 1
j n
x2
j2
xn
a 22 a nn
http://numericalmethods.eng.usf.edu
Gauss-Seidel Method
Algorithm
General Form for any row ‘i’
n
ci aij x j
j 1
j i
xi , i 1,2, , n.
aii
http://numericalmethods.eng.usf.edu
Gauss-Seidel Method
Solve for the unknowns
Assume an initial guess for [X] Use rewritten equations to solve for
each value of xi.
Important: Remember to use the
x1 most recent value of xi. Which
x means to apply values calculated to
2 the calculations remaining in the
current iteration.
xn -1
xn
http://numericalmethods.eng.usf.edu
Gauss-Seidel Method
Calculate the Absolute Relative Approximate Error
x inew x iold
a i
new
100
xi
So when has the answer been found?
http://numericalmethods.eng.usf.edu
Gauss-Seidel Method: Example 2
Given the system of equations The coefficient matrix is:
12x 1 3x 2 - 5x 3 1
x 1 5x 2 3x 3 28 12 3 5
http://numericalmethods.eng.usf.edu
Gauss-Seidel Method: Example 2
Checking if the coefficient matrix is diagonally dominant
a11 12 12 a12 a13 3 5 8
12 3 5
A 1 5 3 a 22 5 5 a 21 a 23 1 3 4
3 7 13
a33 13 13 a31 a32 3 7 10
The inequalities are all true and at least one row is strictly greater than:
Therefore: The solution should converge using the Gauss-Siedel Method
http://numericalmethods.eng.usf.edu
Gauss-Seidel Method: Example 2
With an initial guess of
Rewriting each equation
12 3 5 a1 1 x1 1
1 5 3 a 28 x 0
2 2
3 7 13 a3 76 x3 1
1 3x 2 5 x3 1 3 0 51
x1 x1 0.50000
12 12
28 x1 3 x3 28 0.5 31
x2 x2 4.9000
5 5
76 3 x1 7 x 2
x3 76 3 0.50000 7 4.9000
13 x3 3.0923
13
http://numericalmethods.eng.usf.edu
Gauss-Seidel Method: Example 2
The absolute relative approximate error
0.50000 1.0000
a 1 100 67.662%
0.50000
4.9000 0
a 2
100 100.00%
4.9000
3.0923 1.0000
a 3
100 67.662%
3.0923
The maximum absolute relative error after the first iteration is 100%
http://numericalmethods.eng.usf.edu
Gauss-Seidel Method: Example 2
After Iteration #1
x1 0.5000
x 4.9000
2
x3 3.0923
Substituting the x values into the equations After Iteration #2
1 3 4.9000 5 3.0923 x1 0.14679
x1 0.14679
12 x 3.7153
2
28 0.14679 3 3.0923 x3 3.8118
x2 3.7153
5
76 3 0.14679 7 4.900
x3 3.8118
13
http://numericalmethods.eng.usf.edu
Gauss-Seidel Method: Example 2
Iteration #2 absolute relative approximate error
0.14679 0.50000
a 1 100 240.62%
0.14679
3.7153 4.9000
a 2
100 31.887%
3.7153
3.8118 3.0923
a 3 100 18.876%
3.8118
The maximum absolute relative error after the first iteration is 240.62%
This is much larger than the maximum absolute relative error obtained in
iteration #1. Is this a problem?
http://numericalmethods.eng.usf.edu
Gauss-Seidel Method: Example 2
Repeating more iterations, the following values are obtained
Iteration a1 a2 a3
a 1 a a
2 3
x1 0.99919
The solution obtained
x
2 3 .0001
x3 4.0001
x1 1
is close to the exact solution of x 2 3
x3 4
http://numericalmethods.eng.usf.edu