Gauss Seidel Method Final
Gauss Seidel Method Final
1
Gauss-Seidel Method
An iterative method.
Basic Procedure:
Algebraically solve each linear equation for xi
-
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
Third equation, solve for x3
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
j 2
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 new
x old
a i i
new
i
100
x i
The inequalities are all true and at least one row is strictly greater than:
Therefore: The solution should converge using the Gauss-Siedel Method
1 3 x 2 5 x3 1 30 51
x1 x1 0.50000
12 12
28 x1 3 x3 28 0.5 31
x2 x2
5
4.9000
5
76 3 x1 7 x2 76 30.50000 74.9000
x3 x3 3.0923
13 13
http://numericalmethods.eng.usf.edu
Gauss-Seidel Method: Example 1
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 1
After Iteration #1
x1 0.5000
x 4.9000
2
x3 3.0923
After Iteration #2
Substituting the x values into the equations
1 34.9000 53.0923 x1 0.14679
x1 0.14679
12 x 3.7153
2
28 0.14679 33.0923 x3 3.8118
x2 3.7153
5
76 30.14679 74.900
x3 3.8118
13
http://numericalmethods.eng.usf.edu
Gauss-Seidel Method: Example 1
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 1
Repeating more iterations, the following values are obtained
Iteration a1 a2 a3
a 1 a 2
a 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
Gauss-Seidel Method: Example 2
Given the system of equations The coefficient matrix is:
3x1 - 0.1x 2 - 0.2x 3 7.85
0.1x1 7x 2 0.3x 3 - 19.3 3 0.1 0.2
3rd iteration
2nd iteration
7.85 0.1(2.4996)) 0.2(7.000291)
x1 3.0000
7.85 0.1(2.79452) 0.2(7.005592) 3
x1 2.99056
3 19.3 0.1(3.0000) 0.3(7.000291)
x2 2.4999
7
19.3 0.1(2.99056) 0.3(7.005592)
x2 2.4996
7
71.4 0.3(3) 0.2(2.4999)
x3 7.000002
10
71.4 0.3(2.99056) 0.2(2.4996)
x3 7.000291
10 x1 3, x2 2.5, x3 7
Iteration x1 x2 x3
1 2.616667 0 0
2.616667 -2.79452 0
2.616667 -2.79452 7.00592
2 2.99056 -2.79452 7.00592
2.99056 -2.4996 7.000592
2.99056 -2.4996 7.000291
3 3 -2.4996 7.000291
3 -2.4999 7.000291
3 -2.4999 7.00002
Final value 3 -2.5 7
21 http://numericalmethods.eng.usf.edu
Gauss-Seidel Method: Example 2
The absolute relative approximate error
2.616667 0
a 1 100 100%
2.616667
2.79452
a 100 100.00%
2
2.79452
7.005592 0
a 3 100 100%
7.005592
The maximum absolute relative error after the first iteration is 100%
Gauss-Seidel Method: Example 2
Iteration #2 absolute relative approximate error
2.99056 2.616667
a 1 100 12.48%
2.99056
2.4996 2.79452
a 2
100 11 .79%
2.4996
7.000291 7.00592
a 3
100 0.0841%
7.000291
The maximum absolute relative error after the first iteration is 12.48%