0% found this document useful (0 votes)
82 views23 pages

Gauss Seidel Method Final

The Gauss-Seidel method is an iterative method used to solve systems of linear equations. It works by sequentially updating each unknown variable by algebraically solving one equation for that variable while using recent values for other variables. The method converges to the correct solution when the coefficient matrix is diagonally dominant. An example demonstrates rewriting the equations, calculating initial values, and iteratively updating the values until errors are within a specified tolerance.

Uploaded by

Kenjie Bustillo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views23 pages

Gauss Seidel Method Final

The Gauss-Seidel method is an iterative method used to solve systems of linear equations. It works by sequentially updating each unknown variable by algebraically solving one equation for that variable while using recent values for other variables. The method converges to the correct solution when the coefficient matrix is diagonally dominant. An example demonstrates rewriting the equations, calculating initial values, and iteratively updating the values until errors are within a specified tolerance.

Uploaded by

Kenjie Bustillo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 23

Gauss-Seidel Method

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.

Elimination methods such as Gaussian Elimination and LU


Decomposition are 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
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

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 

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

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.
Gauss-Seidel Method: Example 1
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

3x1  7x2  13x3  76


A   1 5 3 
 3 7 13 
With an initial guess of
Will the solution converge using the
 x1  1
 x   0  Gauss-Siedel method?
 2  
 x3  1
Gauss-Seidel Method: Example 1
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

The process of iteration by Gauss Seidel method will converge if in each


equation of the system the absolute value of the largest coefficient is greater
than the sum of the absolute values of the remaining coefficients.
Gauss-Seidel Method: Example 1
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  3 x 2  5 x3 1  30   51
x1  x1   0.50000
12 12
28  x1  3 x3 28  0.5  31
x2  x2 
5
 4.9000
5
76  3 x1  7 x2 76  30.50000  74.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  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 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

1 0.50000 67.662 4.900 100.00 3.0923 67.662


2 0.14679 240.62 3.7153 31.887 3.8118 18.876
3 0.74275 80.23 3.1644 17.409 3.9708 4.0042
4 0.94675 21.547 3.0281 4.5012 3.9971 0.65798
5 0.99177 4.5394 3.0034 0.82240 4.0001 0.07499
6 0.99919 0.74260 3.0001 0.11000 4.0001 0.00000

 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

0.3x1  0.2 x 2  10x 3  71.4


A  0.1 7  0.3
0.3  0.2 10 
With an initial guess of
Will the solution converge using the
 x1  0
 x   0  Gauss-Siedel method?
 2  
 x3  0
Gauss-Seidel Method: Example 2

Checking if the coefficient matrix is diagonally dominant


The process of iteration by Gauss Seidel method will converge if in
each equation of the system the absolute value of the largest coefficient
is greater than the sum of the absolute values of the remaining
coefficients. That is the coefficient matrix is diagonally dominant.
a11  3  3  a12  a13   0.1   0.2  0.3
 3  0.1  0.2
A  0.1 7  0.3 a22  7  7  a21  a23  0.1   0.3  0.4
0.3  0.2 10 
a33  10  10  a31  a32  0.3   0.2  0.5
The inequalities are all true and at least one row is strictly greater than:
Therefore: The solution should converge using the Gauss-Siedel Method
Gauss-Seidel Method: Example 2
With an initial guess of
Rewriting each equation
 x1  0
 3  0.1  0.2  a 1   7.85 
 0 .1  a    19.3  x   0 
 7  0 . 3  2     2  
0.3  0.2 10  a 3   71.4   x3  0
7.85  0.1x2  0.2 x3
x1  7.85  0.1(0)  0.2(0)
3 x1   2.616667
 19.3  0.1x1  0.3 x3 3
x2   19.3  0.1(2.616667)  0.3(0)
7 x2   2.79452
7
71.4  0.3 x1  0.2 x2
x3  x3 
71.4  0.3(2.616667)  0.2(2.79542)
 7.005592
10 10
Gauss-Seidel Method: Example 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%

This is lesser than the maximum absolute relative error obtained in


iteration #1. The solution of Gauss-Seidel is Converging very fast.After 3 rd
iteration,the solution is attained accurately with very low error.
http://numericalmethods.eng.usf.edu

You might also like