3. 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
admission.edhole.com
4. Gauss-Seidel Method
http://numericalmethods.eng.usf.edu
Why?
The Gauss-Seidel Method allows the user to control round-off error.
Elimination methods such as Gaussian Elimination and LU
Decomposition are prone to prone to round-off error.
Also: If the physics of the problem are understood, a close initial
guess can be made, decreasing the number of iterations needed.
admission.edhole.com
5. Gauss-Seidel Method
http://numericalmethods.eng.usf.edu
Algorithm
A set of n equations and n unknowns:
11 1 12 2 13 3 1 1 a x a x a x ... a x b n n + + + + =
21 1 22 2 23 3 2 a x a x a x ... a x b 2n n + + + + =
. .
. .
. .
n n n nn n n a x + a x + a x + ...+ a x = b 1 1 2 2 3 3
If: the diagonal elements are
non-zero
Rewrite each equation solving
for the corresponding unknown
ex:
First equation, solve for x1
Second equation, solve for x2
admission.edhole.com
6. Gauss-Seidel Method
http://numericalmethods.eng.usf.edu
Algorithm
Rewriting each equation
x c - a x - a x
-
a = 1 12 2 13 3 1
n xn 1 a
11
x = c - a x - a x
-
a x
2 21 1 23 3 2
c a x a x
a x a x
n - 1 n - 1,1 1 n - 1,2 2 n - 1, n - 2 n - 2 n -
1,
n n
1, 1
c a x a x a x
n n n n n n
nn
n
n n
n
n n
a
x
a
x
a
1 1 2 2 , 1 1
1
22
2
- -
- -
-
- - - -
=
- - - -
=
From Equation 1
From equation 2
From equation n-1
From equation n
admission.edhole.com
7. Gauss-Seidel Method
n
c a x
n - 1 n -
1,
j j
n j j
- ¹ =
1
1
n
c a x
n nj j
n j j
http://numericalmethods.eng.usf.edu
Algorithm
General Form of each equation
å j j
c a x
1 1
1
1
1 a
11
x
n
j j
¹ =
-
=
å j
c a x
2 2
1
2
22
2 a
x
j
n
j j
¹ =
-
=
1, 1
1
- -
-
- å
=
n n
n a
x
nn
n a
x
å
¹ =
-
=
1
admission.edhole.com
9. Gauss-Seidel Method
Solve for the unknowns
http://numericalmethods.eng.usf.edu
Assume an initial guess for [X]
ù
ú ú ú ú ú ú
û
é
ê ê ê ê ê ê
ë
x
1
2
x
n-
n
x
x
1
Use rewritten equations to solve for
each value of xi.
Important: Remember to use the
most recent value of xi. Which
means to apply values calculated to
the calculations remaining in the
current iteration.
admission.edhole.com
10. Gauss-Seidel Method
Calculate the Absolute Relative Approximate Error
100
http://numericalmethods.eng.usf.edu
x x
x
new
i
old
i
new
i
a i e = - ´
So when has the answer been found?
The iterations are stopped when the absolute relative
approximate error is less than a prespecified tolerance for all
unknowns.
admission.edhole.com
11. Gauss-Seidel Method: Example 2
12 3 5
ù
é -
=
1 5 3
http://numericalmethods.eng.usf.edu
Given the system of equations
12x 3x - 5x 1 1 2 3 + =
x 5x 3x 28 1 2 3 + + =
3x 7x 13x 76 1 2 3 + + =
With an initial guess of
ù
ú ú ú
û
1
é
=
ê ê ê
ë
ù
ú ú ú û
é
ê ê ê
ë
0
1
x
1
2
3
x
x
The coefficient matrix is:
[ ]
ú ú ú
û
ê ê ê
ë
3 7 13
A
Will the solution converge using the
Gauss-Siedel method?
admission.edhole.com
12. Gauss-Seidel Method: Example 2
12 12 3 5 8 11 12 13 a = = ³ a + a = + - =
http://numericalmethods.eng.usf.edu
[ ]
ù
ú ú ú
û
é -
=
12 3 5
ê ê ê
ë
1 5 3
3 7 13
A
Checking if the coefficient matrix is diagonally dominant
5 5 1 3 4 22 21 23 a = = ³ a + a = + =
13 13 3 7 10 33 31 32 a = = ³ a + a = + =
The inequalities are all true and at least one row is strictly greater than:
Therefore: The solution should converge using the Gauss-Siedel Method
admission.edhole.com
13. Gauss-Seidel Method: Example 2
ù
1
é
=
ù
é
0
x
1
2
x
1 x = - + =
2 x = - - =
x = 76 - 3 0.50000 - 7 4.9000
=
3 http://numericalmethods.eng.usf.edu
Rewriting each equation
ù
ú ú ú û
é
=
ê ê ê
ë
ù
ú ú ú
û
é
ê ê ê
ë
12 3 5
ù
ú ú ú
û
é -
ê ê ê
ë
1
28
76
1 5 3
3 7 13
a
1
2
a
x = - x + x
3
a
1 3 5 2 3
12
1
x = - x - x
28 3 1 3
5
2
x = - x - x
76 3 7 1 2
13
3
With an initial guess of
ú ú ú
û
ê ê ê
ë
ú ú ú
û
ê ê ê
ë
1
3
x
( ) ( ) 0.50000
12
1 3 0 5 1
( ) ( ) 4.9000
5
28 0.5 3 1
( ) ( ) 3.0923
13
admission.edhole.com
14. Gauss-Seidel Method: Example 2
The absolute relative approximate error
a 1 Î = - ´ =
100 67.662%
http://numericalmethods.eng.usf.edu
0.50000 1.0000
0.50000
a 2 Î = - ´ =
100 100.00%
4.9000 0
4.9000
a 3 Î = - ´ =
100 67.662%
3.0923 1.0000
3.0923
The maximum absolute relative error after the first iteration is 100%
admission.edhole.com
15. Gauss-Seidel Method: Example 2
ù
é
=
ù
é
0.5000
x
1
Substituting the x values into the equations After Iteration #2 ú ú ú
ù
ú ú ú
û
0.14679
é
=
ê ê ê
ë
ù
ú ú ú
û
é
ê ê ê
ë
3.7153
3.8118
x
1
2
x
x
3
http://numericalmethods.eng.usf.edu
After Iteration #1
4.9000
2
x
( ) ( ) 0.14679
x = 1 - 3 4.9000 + 5 3.0923
=
1 12
( ) ( ) 3.7153
x = 28 - 0.14679 - 3 3.0923
=
2 5
( ) ( ) 3.8118
x = 76 - 3 0.14679 - 7 4.900
=
3 13
û
ê ê ê
ë
ú ú ú
û
ê ê ê
ë
3.0923
3
x
admission.edhole.com
16. Gauss-Seidel Method: Example 2
Iteration #2 absolute relative approximate error
1 Î = - ´ = a
100 240.62%
http://numericalmethods.eng.usf.edu
0.14679 0.50000
0.14679
2 Î = - ´ = a
100 31.887%
3.7153 4.9000
3.7153
3 Î = - ´ = a
100 18.876%
3.8118 3.0923
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
adimteraistiosn i#o1.n Is. tehids ah porolbele.mc?om
17. Gauss-Seidel Method: Example 2
Repeating more iterations, the following values are obtained
a 2 e a 3 Iteration a e 1 a2 a3
http://numericalmethods.eng.usf.edu
a 1 e
123456
0.50000
0.14679
0.74275
0.94675
0.99177
0.99919
67.662
240.62
80.23
21.547
4.5394
0.74260
4.900
3.7153
3.1644
3.0281
3.0034
3.0001
100.00
31.887
17.409
4.5012
0.82240
0.11000
3.0923
3.8118
3.9708
3.9971
4.0001
4.0001
67.662
18.876
4.0042
0.65798
0.07499
0.00000
ù
ú ú ú
û
ù
é
=
ê ê ê
ë
0.99919
3.0001
ù
ú ú ú
û
é
ê ê ê
ë
1
3
4
x
1
2
3
x
x
ú ú ú
û
é
=
ê ê ê
ë
ù
ú ú ú
û
é
ê ê ê
ë
4.0001
x
1
2
x
3
x
The solution obtained
ias cdlomse itos tsheio exnac.te sodluhtioon loef .com