CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Wiki > Gauss-Seidel method

Gauss-Seidel method

From CFD-Wiki

(Difference between revisions)
Jump to: navigation, search
(fixed dot product notation)
(towards a uniform notation for linear systems : A*Phi = B)
Line 1: Line 1:
We seek the solution to set of linear equations: <br>
We seek the solution to set of linear equations: <br>
-
:<math> A \cdot X = Q </math> <br>
+
:<math> A \cdot \Phi = B </math> <br>
For the given matrix '''A''' and vectors '''X''' and '''Q'''. <br>
For the given matrix '''A''' and vectors '''X''' and '''Q'''. <br>
In matrix terms, the definition of the Gauss-Seidel method can be expressed as : <br>
In matrix terms, the definition of the Gauss-Seidel method can be expressed as : <br>
<math>  
<math>  
-
x^{(k)}  = \left( {D - L} \right)^{ - 1} \left( {Ux^{(k - 1)}  + q} \right)
+
\phi^{(k)}  = \left( {D - L} \right)^{ - 1} \left( {U\phi^{(k - 1)}  + b} \right)
</math><br>
</math><br>
Where '''D''','''L''' and '''U''' represent the diagonal, lower triangular and upper triangular matrices of coefficient matrix '''A''' and k is iteration counter.<br>
Where '''D''','''L''' and '''U''' represent the diagonal, lower triangular and upper triangular matrices of coefficient matrix '''A''' and k is iteration counter.<br>
Line 19: Line 19:
:::  <math> \sigma = 0 </math> <br>
:::  <math> \sigma = 0 </math> <br>
:::  for j := 1 step until i-1 do <br>
:::  for j := 1 step until i-1 do <br>
-
::::      <math> \sigma  = \sigma  + a_{ij} x_j^{(k)} </math>
+
::::      <math> \sigma  = \sigma  + a_{ij} \phi_j^{(k)} </math>
:::    end (j-loop) <br>
:::    end (j-loop) <br>
:::  for j := i+1 step until n do <br>
:::  for j := i+1 step until n do <br>
-
::::      <math> \sigma  = \sigma  + a_{ij} x_j^{(k-1)} </math>
+
::::      <math> \sigma  = \sigma  + a_{ij} \phi_j^{(k-1)} </math>
:::    end (j-loop) <br>
:::    end (j-loop) <br>
-
:::    <math>  x_i^{(k)}  = {{\left( {q_i - \sigma } \right)} \over {a_{ii} }} </math>
+
:::    <math>  \phi_i^{(k)}  = {{\left( {b_i - \sigma } \right)} \over {a_{ii} }} </math>
::  end (i-loop)
::  end (i-loop)
::  check if convergence is reached
::  check if convergence is reached

Revision as of 20:46, 15 December 2005

We seek the solution to set of linear equations:

 A \cdot \Phi = B

For the given matrix A and vectors X and Q.
In matrix terms, the definition of the Gauss-Seidel method can be expressed as :
 
\phi^{(k)}  = \left( {D - L} \right)^{ - 1} \left( {U\phi^{(k - 1)}  + b} \right)
Where D,L and U represent the diagonal, lower triangular and upper triangular matrices of coefficient matrix A and k is iteration counter.

The pseudocode for the Gauss-Seidel algorithm:

Algorithm


Chose an intital guess X^{0} to the solution
for k := 1 step 1 untill convergence do
for i := 1 step until n do
 \sigma = 0
for j := 1 step until i-1 do
 \sigma  = \sigma  + a_{ij} \phi_j^{(k)}
end (j-loop)
for j := i+1 step until n do
 \sigma  = \sigma  + a_{ij} \phi_j^{(k-1)}
end (j-loop)
  \phi_i^{(k)}  = {{\left( {b_i  - \sigma } \right)} \over {a_{ii} }}
end (i-loop)
check if convergence is reached
end (k-loop)



Return to Numerical Methods

My wiki