You are on page 1of 19

Gauss-Seidel 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
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.

http://numericalmethods.eng.usf.edu
Gauss-Seidel Method
Algorithm

A set of n equations and n unknowns:

. .
. .
If: the diagonal elements are
non-zero
a11 x1  a12 x2  a13 x3  ...  a1n xn  b1
. .

Rewrite each equation solving


for the corresponding unknown
a21 x1  a22 x2  a23 x3  ...  a2n xn  b2
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
c1  a12 x 2  a13 x3   a1n x n From Equation 1
x1 
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
xn  From equation n
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

How or where can this equation be used?

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 
Gauss-Seidel Method
Calculate the Absolute Relative Approximate Error

x new
x old
a i  i
new
i
 100
x i

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.

http://numericalmethods.eng.usf.edu
Example: Thermal Coefficient
A trunnion of diameter 12.363”
has to be cooled from a room
temperature of 80°F before it is
shrink fit into a steel hub.

The equation that gives the


diametric contraction ΔD of
the trunnion in dry-ice/alcohol
(boiling temperature is −108°F Figure 1 Trunnion to be slid
is given by: through the hub after
108 contracting.
D  12.363   (T )dT
80
Example: Thermal Coefficient
 a a T a T 2
The expression for the thermal expansion coefficient, 1 2 3
is obtained using regression analysis and hence solving the following
simultaneous linear equations:

 24  2860 7.26 105   a1   1.057 10 4 


   
  2860 7.26 105  1.86472 108  a2    1.04162 10  2 
7.26 105  1.86472 108 5.24357  1010   a3   2.56799 
 

Find the values of a1, a2,and a3 using Gauss-Seidel Method.


Example: Thermal Coefficient
The system of equations is:
 24  2860 7.26 105   a1   1.057 10 4 
   
  2860 7.26 105  1.86472 108  a2    1.04162 10  2 
7.26 105  1.86472 108 5.24357  1010   a3   2.56799 
 

Initial Guess:  a1  0


 a   0 
Assume an initial guess of  2  
 a3  0
Example: Thermal Coefficient
Rewriting each equation
Iteration 1

 24  2860 7.26 105   a1   1.057 10 4 


   
  2860 7.26 105  1.86472 108  a2    1.04162 10 2 
7.26  105  1.86472 108 5.24357 1010   a3   2.56799 
 
1.057 104    2860  0  7.26 105  0
a1   4.4042 106
24

a2 

 1.04162 102    2860  4.4042 106   1.86472 108  0 3.0024  10 9

7.26 105

2.56799  7.26 105  4.4042106    1.86472108   3.0024 109 12


a3   1.3269  10
5.243571010
Example: Thermal Coefficient
Finding the absolute relative approximate error

xinew  xiold At the end of the first iteration


a i  new
100
xi
 a1   4.4042 10 
6

4.4042 10 6  0 a    3.0024  10 9 


a 1  6
100  100 %  2  
4.4042 10  a3   1.3269  10 12 
3.0024 10 9  1000
a  9
100  100 % The maximum absolute
2
3.0024 10 relative approximate error is
100%.
 1.3269 10 12  100
a 3  12
100  100 %
 1.3269 10
Example: Thermal Coefficient
Iteration 2
 a1   4.4042 10 from Iteration 1 the values of a are found:
6
Using
a    3.0024 10 9  i
 2  
 a3   1.3269 10 
12

a1 

1.057  10 4    2860  3.0024 10 9  7.26 105   1.3269  10 12 
24
 4.8021 10 6

 1.04162 102    2860  4.8021106    1.86472 108     1.3269 1012 


a2 
7.26  105
 4.2291109

2.56799  7.26 105  4.802110 6    1.86472  108   4.229110 9


a3 
5.24357 1010
 2.4738 1012
Example: Thermal Coefficient
Finding the absolute relative approximate error
4.8021 106  4.4042  106
a 1  6
100  8.2864 %
4.8021 10
4.221109  3.0024  109
a  9
 100  29.007 %
2
4.2291110
 2.4738  1012  (1.3269 1012 )
a 3  12
 100  46.360 %
 2.4738 10
At the end of the second iteration The maximum absolute
relative approximate error is
 a1   4.802110 
6
46.360%.
a    4.229110 9 
 2  
 a3   2.4738 10 12 
Example: Thermal Coefficient
Repeating more iterations, the following values are obtained

Iteration a1 a 1 % a2 a 2 % a3 a 3 %
1 4.4042×10−6 100 3.0024×10−9 100 −1.3269×10−12 100
2 4.8021×10−6 8.2864 4.2291×10−9 29.0073 −2.4738×10−12 46.3605
3 4.9830×10−6 3.6300 4.6471×10−9 8.9946 −3.4917×10−12 29.1527
4 5.0636×10−6 1.5918 4.7023×10−9 1.1922 −4.4083×10−12 20.7922
5 5.0980×10−6 0.6749 4.6033×10−9 2.1696 −5.2399×10−12 15.8702
6 5.1112×10−6 0.2593 4.4419×10−9 3.6330 −5.9972×10−12 12.6290

! Notice – After six iterations, the absolute relative approximate errors are
decreasing, but are still high.
Example: Thermal Coefficient
Repeating more iterations, the following values are obtained

Iteration a1 a 1 % a2 a 2 % a3 a 3 %
75 5.0692×10−6 2.2559×10−4 2.0139×10−9 0.02428 −1.4049×10−11 0.01125
76 5.0691×10−6 2.0630×10−4 2.0135×10−9 0.02221 −1.4051×10−11 0.01029

The value of closely approaches the true value of


 a1   5.069110 
6
 a1   5.0690 10 
6

a    2.0135  10 9  a    2.0087 10 9 


 2    2  
 a3   1.405110 11   a3   1.4066 10 
11
Example: Thermal Coefficient
The polynomial that passes through the three data points is then

  T   a1  a2T  a3T 2

 5.06915 10 6  2.00135 10 9 T  1.405110 11 T 2

You might also like