Page 1
Chapter 04.08
Gauss-Seidel Method
After reading this chapter, you should be able to:
1. solve a set of equations using the Gauss-Seidel method,
2. recognize the advantages and pitfalls of the Gauss-Seidel method, and
3. determine under what conditions the Gauss-Seidel method always converges.
Why do we need another method to solve a set of simultaneous linear equations?
In certain cases, such as when a system of equations is large, iterative methods of solving
equations are more advantageous. Elimination methods, such as Gaussian elimination, are
prone to large round-off errors for a large set of equations. Iterative methods, such as the
Gauss-Seidel method, give the user control of the round-off error. Also, if the physics of the
problem are well known, initial guesses needed in iterative methods can be made more
judiciously leading to faster convergence.
What is the algorithm for the Gauss-Seidel method? Given a general set of n equations and
n unknowns, we have
1 1 3 13 2 12 1 11
... c x a x a x a x a
n n
= + + + +
2 2 3 23 2 22 1 21
... c x a x a x a x a
n n
= + + + +
. .
. .
. .
n n nn n n n
c x a x a x a x a = + + + + ...
3 3 2 2 1 1
If the diagonal elements are non-zero, each equation is rewritten for the corresponding
unknown, that is, the first equation is rewritten with
1
x on the left hand side, the second
equation is rewritten with
2
x on the left hand side and so on as follows
Page 2
Chapter 04.08
Gauss-Seidel Method
After reading this chapter, you should be able to:
1. solve a set of equations using the Gauss-Seidel method,
2. recognize the advantages and pitfalls of the Gauss-Seidel method, and
3. determine under what conditions the Gauss-Seidel method always converges.
Why do we need another method to solve a set of simultaneous linear equations?
In certain cases, such as when a system of equations is large, iterative methods of solving
equations are more advantageous. Elimination methods, such as Gaussian elimination, are
prone to large round-off errors for a large set of equations. Iterative methods, such as the
Gauss-Seidel method, give the user control of the round-off error. Also, if the physics of the
problem are well known, initial guesses needed in iterative methods can be made more
judiciously leading to faster convergence.
What is the algorithm for the Gauss-Seidel method? Given a general set of n equations and
n unknowns, we have
1 1 3 13 2 12 1 11
... c x a x a x a x a
n n
= + + + +
2 2 3 23 2 22 1 21
... c x a x a x a x a
n n
= + + + +
. .
. .
. .
n n nn n n n
c x a x a x a x a = + + + + ...
3 3 2 2 1 1
If the diagonal elements are non-zero, each equation is rewritten for the corresponding
unknown, that is, the first equation is rewritten with
1
x on the left hand side, the second
equation is rewritten with
2
x on the left hand side and so on as follows
nn
n n n n n n
n
n n
n n n n n n n n n
n
n n
n n
a
x a x a x a c
x
a
x a x a x a x a c
x
a
x a x a x a c
x
a
x a x a x a c
x
1 1 , 2 2 1 1
1 , 1
, 1 2 2 , 1 2 2 , 1 1 1 , 1 1
1
22
2 3 23 1 21 2
2
11
1 3 13 2 12 1
1
- -
- -
- - - - - - -
-
- - - -
=
- - - -
=
- - -
=
- - -
=
? ?
? ?
?
?
? ?
? ?
These equations can be rewritten in a summation form as
11
1
1
1 1
1
a
x a c
x
n
j
j
j j ?
?
=
-
=
22
2
1
2 2
2
a
x a c
x
j
n
j
j
j ?
?
=
-
=
.
.
.
1 , 1
1
1
, 1 1
1
- -
- ?
=
- -
-
?
-
=
n n
n
n j
j
j j n n
n
a
x a c
x
nn
n
n j
j
j nj n
n
a
x a c
x
?
?
=
-
=
1
Hence for any row i ,
. , , 2 , 1 ,
1
n i
a
x a c
x
ii
n
i j
j
j ij i
i
? =
-
=
?
?
=
Now to find
i
x ’s, one assumes an initial guess for the
i
x ’s and then uses the rewritten
equations to calculate the new estimates. Remember, one always uses the most recent
estimates to calculate the next estimates,
i
x . At the end of each iteration, one calculates the
absolute relative approximate error for each
i
x as
Page 3
Chapter 04.08
Gauss-Seidel Method
After reading this chapter, you should be able to:
1. solve a set of equations using the Gauss-Seidel method,
2. recognize the advantages and pitfalls of the Gauss-Seidel method, and
3. determine under what conditions the Gauss-Seidel method always converges.
Why do we need another method to solve a set of simultaneous linear equations?
In certain cases, such as when a system of equations is large, iterative methods of solving
equations are more advantageous. Elimination methods, such as Gaussian elimination, are
prone to large round-off errors for a large set of equations. Iterative methods, such as the
Gauss-Seidel method, give the user control of the round-off error. Also, if the physics of the
problem are well known, initial guesses needed in iterative methods can be made more
judiciously leading to faster convergence.
What is the algorithm for the Gauss-Seidel method? Given a general set of n equations and
n unknowns, we have
1 1 3 13 2 12 1 11
... c x a x a x a x a
n n
= + + + +
2 2 3 23 2 22 1 21
... c x a x a x a x a
n n
= + + + +
. .
. .
. .
n n nn n n n
c x a x a x a x a = + + + + ...
3 3 2 2 1 1
If the diagonal elements are non-zero, each equation is rewritten for the corresponding
unknown, that is, the first equation is rewritten with
1
x on the left hand side, the second
equation is rewritten with
2
x on the left hand side and so on as follows
nn
n n n n n n
n
n n
n n n n n n n n n
n
n n
n n
a
x a x a x a c
x
a
x a x a x a x a c
x
a
x a x a x a c
x
a
x a x a x a c
x
1 1 , 2 2 1 1
1 , 1
, 1 2 2 , 1 2 2 , 1 1 1 , 1 1
1
22
2 3 23 1 21 2
2
11
1 3 13 2 12 1
1
- -
- -
- - - - - - -
-
- - - -
=
- - - -
=
- - -
=
- - -
=
? ?
? ?
?
?
? ?
? ?
These equations can be rewritten in a summation form as
11
1
1
1 1
1
a
x a c
x
n
j
j
j j ?
?
=
-
=
22
2
1
2 2
2
a
x a c
x
j
n
j
j
j ?
?
=
-
=
.
.
.
1 , 1
1
1
, 1 1
1
- -
- ?
=
- -
-
?
-
=
n n
n
n j
j
j j n n
n
a
x a c
x
nn
n
n j
j
j nj n
n
a
x a c
x
?
?
=
-
=
1
Hence for any row i ,
. , , 2 , 1 ,
1
n i
a
x a c
x
ii
n
i j
j
j ij i
i
? =
-
=
?
?
=
Now to find
i
x ’s, one assumes an initial guess for the
i
x ’s and then uses the rewritten
equations to calculate the new estimates. Remember, one always uses the most recent
estimates to calculate the next estimates,
i
x . At the end of each iteration, one calculates the
absolute relative approximate error for each
i
x as
100
new
old new
×
-
= ?
i
i i
i
a
x
x x
where
new
i
x is the recently obtained value of
i
x , and
old
i
x is the previous value of
i
x .
When the absolute relative approximate error for each xi is less than the pre-specified
tolerance, the iterations are stopped.
Example 1
The upward velocity of a rocket is given at three different times in the following table
Table 1 Velocity vs. time data.
Time, t (s) Velocity, v (m/s)
5 106.8
8 177.2
12 279.2
The velocity data is approximated by a polynomial as
( ) 12 5 ,
3 2
2
1
= = + + = t a t a t a t v
Find the values of
3 2 1
and , , a a a using the Gauss-Seidel method. Assume an initial guess of
the solution as
?
?
?
?
?
?
?
?
?
?
=
?
?
?
?
?
?
?
?
?
?
5
2
1
3
2
1
a
a
a
and conduct two iterations.
Solution
The polynomial is going through three data points ( ) ( ) ( )
3 3 2 2 1 1
, and , , , , v t v t v t where from the
above table
8 . 106 , 5
1 1
= = v t
2 . 177 , 8
2 2
= = v t
2 . 279 , 12
3 3
= = v t
Requiring that ( )
3 2
2
1
a t a t a t v + + = passes through the three data points gives
( )
3 1 2
2
1 1 1 1
a t a t a v t v + + = =
( )
3 2 2
2
2 1 2 2
a t a t a v t v + + = =
( )
3 3 2
2
3 1 3 3
a t a t a v t v + + = =
Substituting the data ( ) ( ) ( )
3 3 2 2 1 1
, and , , , , v t v t v t gives
( ) ( ) 8 . 106 5 5
3 2
2
1
= + + a a a
( ) ( ) 2 . 177 8 8
3 2
2
1
= + + a a a
( ) ( ) 2 . 279 12 12
3 2
2
1
= + + a a a
Page 4
Chapter 04.08
Gauss-Seidel Method
After reading this chapter, you should be able to:
1. solve a set of equations using the Gauss-Seidel method,
2. recognize the advantages and pitfalls of the Gauss-Seidel method, and
3. determine under what conditions the Gauss-Seidel method always converges.
Why do we need another method to solve a set of simultaneous linear equations?
In certain cases, such as when a system of equations is large, iterative methods of solving
equations are more advantageous. Elimination methods, such as Gaussian elimination, are
prone to large round-off errors for a large set of equations. Iterative methods, such as the
Gauss-Seidel method, give the user control of the round-off error. Also, if the physics of the
problem are well known, initial guesses needed in iterative methods can be made more
judiciously leading to faster convergence.
What is the algorithm for the Gauss-Seidel method? Given a general set of n equations and
n unknowns, we have
1 1 3 13 2 12 1 11
... c x a x a x a x a
n n
= + + + +
2 2 3 23 2 22 1 21
... c x a x a x a x a
n n
= + + + +
. .
. .
. .
n n nn n n n
c x a x a x a x a = + + + + ...
3 3 2 2 1 1
If the diagonal elements are non-zero, each equation is rewritten for the corresponding
unknown, that is, the first equation is rewritten with
1
x on the left hand side, the second
equation is rewritten with
2
x on the left hand side and so on as follows
nn
n n n n n n
n
n n
n n n n n n n n n
n
n n
n n
a
x a x a x a c
x
a
x a x a x a x a c
x
a
x a x a x a c
x
a
x a x a x a c
x
1 1 , 2 2 1 1
1 , 1
, 1 2 2 , 1 2 2 , 1 1 1 , 1 1
1
22
2 3 23 1 21 2
2
11
1 3 13 2 12 1
1
- -
- -
- - - - - - -
-
- - - -
=
- - - -
=
- - -
=
- - -
=
? ?
? ?
?
?
? ?
? ?
These equations can be rewritten in a summation form as
11
1
1
1 1
1
a
x a c
x
n
j
j
j j ?
?
=
-
=
22
2
1
2 2
2
a
x a c
x
j
n
j
j
j ?
?
=
-
=
.
.
.
1 , 1
1
1
, 1 1
1
- -
- ?
=
- -
-
?
-
=
n n
n
n j
j
j j n n
n
a
x a c
x
nn
n
n j
j
j nj n
n
a
x a c
x
?
?
=
-
=
1
Hence for any row i ,
. , , 2 , 1 ,
1
n i
a
x a c
x
ii
n
i j
j
j ij i
i
? =
-
=
?
?
=
Now to find
i
x ’s, one assumes an initial guess for the
i
x ’s and then uses the rewritten
equations to calculate the new estimates. Remember, one always uses the most recent
estimates to calculate the next estimates,
i
x . At the end of each iteration, one calculates the
absolute relative approximate error for each
i
x as
100
new
old new
×
-
= ?
i
i i
i
a
x
x x
where
new
i
x is the recently obtained value of
i
x , and
old
i
x is the previous value of
i
x .
When the absolute relative approximate error for each xi is less than the pre-specified
tolerance, the iterations are stopped.
Example 1
The upward velocity of a rocket is given at three different times in the following table
Table 1 Velocity vs. time data.
Time, t (s) Velocity, v (m/s)
5 106.8
8 177.2
12 279.2
The velocity data is approximated by a polynomial as
( ) 12 5 ,
3 2
2
1
= = + + = t a t a t a t v
Find the values of
3 2 1
and , , a a a using the Gauss-Seidel method. Assume an initial guess of
the solution as
?
?
?
?
?
?
?
?
?
?
=
?
?
?
?
?
?
?
?
?
?
5
2
1
3
2
1
a
a
a
and conduct two iterations.
Solution
The polynomial is going through three data points ( ) ( ) ( )
3 3 2 2 1 1
, and , , , , v t v t v t where from the
above table
8 . 106 , 5
1 1
= = v t
2 . 177 , 8
2 2
= = v t
2 . 279 , 12
3 3
= = v t
Requiring that ( )
3 2
2
1
a t a t a t v + + = passes through the three data points gives
( )
3 1 2
2
1 1 1 1
a t a t a v t v + + = =
( )
3 2 2
2
2 1 2 2
a t a t a v t v + + = =
( )
3 3 2
2
3 1 3 3
a t a t a v t v + + = =
Substituting the data ( ) ( ) ( )
3 3 2 2 1 1
, and , , , , v t v t v t gives
( ) ( ) 8 . 106 5 5
3 2
2
1
= + + a a a
( ) ( ) 2 . 177 8 8
3 2
2
1
= + + a a a
( ) ( ) 2 . 279 12 12
3 2
2
1
= + + a a a
or
8 . 106 5 25
3 2 1
= + + a a a
2 . 177 8 64
3 2 1
= + + a a a
2 . 279 12 144
3 2 1
= + + a a a
The coefficients
3 2 1
and , , a a a for the above expression are given by
?
?
?
?
?
?
?
?
?
?
=
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
2 . 279
2 . 177
8 . 106
1 12 144
1 8 64
1 5 25
3
2
1
a
a
a
Rewriting the equations gives
25
5 8 . 106
3 2
1
a a
a
- -
=
8
64 2 . 177
3 1
2
a a
a
- -
=
1
12 144 2 . 279
2 1
3
a a
a
- -
=
Iteration #1
Given the initial guess of the solution vector as
?
?
?
?
?
?
?
?
?
?
=
?
?
?
?
?
?
?
?
?
?
5
2
1
3
2
1
a
a
a
we get
25
) 5 ( ) 2 ( 5 8 . 106
1
- -
= a
6720 . 3 =
( ) ( )
8
5 6720 . 3 64 2 . 177
2
- -
= a
8150 . 7 - =
( ) ( )
1
8510 . 7 12 6720 . 3 144 2 . 279
3
- - -
= a
36 . 155 - =
The absolute relative approximate error for each
i
x then is
100
6720 . 3
1 6720 . 3
1
×
-
= ?
a
% 76 . 72 =
100
8510 . 7
2 8510 . 7
2
×
-
- -
= ?
a
% 47 . 125 =
100
36 . 155
5 36 . 155
3
×
-
- -
= ?
a
% 22 . 103 =
Page 5
Chapter 04.08
Gauss-Seidel Method
After reading this chapter, you should be able to:
1. solve a set of equations using the Gauss-Seidel method,
2. recognize the advantages and pitfalls of the Gauss-Seidel method, and
3. determine under what conditions the Gauss-Seidel method always converges.
Why do we need another method to solve a set of simultaneous linear equations?
In certain cases, such as when a system of equations is large, iterative methods of solving
equations are more advantageous. Elimination methods, such as Gaussian elimination, are
prone to large round-off errors for a large set of equations. Iterative methods, such as the
Gauss-Seidel method, give the user control of the round-off error. Also, if the physics of the
problem are well known, initial guesses needed in iterative methods can be made more
judiciously leading to faster convergence.
What is the algorithm for the Gauss-Seidel method? Given a general set of n equations and
n unknowns, we have
1 1 3 13 2 12 1 11
... c x a x a x a x a
n n
= + + + +
2 2 3 23 2 22 1 21
... c x a x a x a x a
n n
= + + + +
. .
. .
. .
n n nn n n n
c x a x a x a x a = + + + + ...
3 3 2 2 1 1
If the diagonal elements are non-zero, each equation is rewritten for the corresponding
unknown, that is, the first equation is rewritten with
1
x on the left hand side, the second
equation is rewritten with
2
x on the left hand side and so on as follows
nn
n n n n n n
n
n n
n n n n n n n n n
n
n n
n n
a
x a x a x a c
x
a
x a x a x a x a c
x
a
x a x a x a c
x
a
x a x a x a c
x
1 1 , 2 2 1 1
1 , 1
, 1 2 2 , 1 2 2 , 1 1 1 , 1 1
1
22
2 3 23 1 21 2
2
11
1 3 13 2 12 1
1
- -
- -
- - - - - - -
-
- - - -
=
- - - -
=
- - -
=
- - -
=
? ?
? ?
?
?
? ?
? ?
These equations can be rewritten in a summation form as
11
1
1
1 1
1
a
x a c
x
n
j
j
j j ?
?
=
-
=
22
2
1
2 2
2
a
x a c
x
j
n
j
j
j ?
?
=
-
=
.
.
.
1 , 1
1
1
, 1 1
1
- -
- ?
=
- -
-
?
-
=
n n
n
n j
j
j j n n
n
a
x a c
x
nn
n
n j
j
j nj n
n
a
x a c
x
?
?
=
-
=
1
Hence for any row i ,
. , , 2 , 1 ,
1
n i
a
x a c
x
ii
n
i j
j
j ij i
i
? =
-
=
?
?
=
Now to find
i
x ’s, one assumes an initial guess for the
i
x ’s and then uses the rewritten
equations to calculate the new estimates. Remember, one always uses the most recent
estimates to calculate the next estimates,
i
x . At the end of each iteration, one calculates the
absolute relative approximate error for each
i
x as
100
new
old new
×
-
= ?
i
i i
i
a
x
x x
where
new
i
x is the recently obtained value of
i
x , and
old
i
x is the previous value of
i
x .
When the absolute relative approximate error for each xi is less than the pre-specified
tolerance, the iterations are stopped.
Example 1
The upward velocity of a rocket is given at three different times in the following table
Table 1 Velocity vs. time data.
Time, t (s) Velocity, v (m/s)
5 106.8
8 177.2
12 279.2
The velocity data is approximated by a polynomial as
( ) 12 5 ,
3 2
2
1
= = + + = t a t a t a t v
Find the values of
3 2 1
and , , a a a using the Gauss-Seidel method. Assume an initial guess of
the solution as
?
?
?
?
?
?
?
?
?
?
=
?
?
?
?
?
?
?
?
?
?
5
2
1
3
2
1
a
a
a
and conduct two iterations.
Solution
The polynomial is going through three data points ( ) ( ) ( )
3 3 2 2 1 1
, and , , , , v t v t v t where from the
above table
8 . 106 , 5
1 1
= = v t
2 . 177 , 8
2 2
= = v t
2 . 279 , 12
3 3
= = v t
Requiring that ( )
3 2
2
1
a t a t a t v + + = passes through the three data points gives
( )
3 1 2
2
1 1 1 1
a t a t a v t v + + = =
( )
3 2 2
2
2 1 2 2
a t a t a v t v + + = =
( )
3 3 2
2
3 1 3 3
a t a t a v t v + + = =
Substituting the data ( ) ( ) ( )
3 3 2 2 1 1
, and , , , , v t v t v t gives
( ) ( ) 8 . 106 5 5
3 2
2
1
= + + a a a
( ) ( ) 2 . 177 8 8
3 2
2
1
= + + a a a
( ) ( ) 2 . 279 12 12
3 2
2
1
= + + a a a
or
8 . 106 5 25
3 2 1
= + + a a a
2 . 177 8 64
3 2 1
= + + a a a
2 . 279 12 144
3 2 1
= + + a a a
The coefficients
3 2 1
and , , a a a for the above expression are given by
?
?
?
?
?
?
?
?
?
?
=
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
2 . 279
2 . 177
8 . 106
1 12 144
1 8 64
1 5 25
3
2
1
a
a
a
Rewriting the equations gives
25
5 8 . 106
3 2
1
a a
a
- -
=
8
64 2 . 177
3 1
2
a a
a
- -
=
1
12 144 2 . 279
2 1
3
a a
a
- -
=
Iteration #1
Given the initial guess of the solution vector as
?
?
?
?
?
?
?
?
?
?
=
?
?
?
?
?
?
?
?
?
?
5
2
1
3
2
1
a
a
a
we get
25
) 5 ( ) 2 ( 5 8 . 106
1
- -
= a
6720 . 3 =
( ) ( )
8
5 6720 . 3 64 2 . 177
2
- -
= a
8150 . 7 - =
( ) ( )
1
8510 . 7 12 6720 . 3 144 2 . 279
3
- - -
= a
36 . 155 - =
The absolute relative approximate error for each
i
x then is
100
6720 . 3
1 6720 . 3
1
×
-
= ?
a
% 76 . 72 =
100
8510 . 7
2 8510 . 7
2
×
-
- -
= ?
a
% 47 . 125 =
100
36 . 155
5 36 . 155
3
×
-
- -
= ?
a
% 22 . 103 =
At the end of the first iteration, the estimate of the solution vector is
?
?
?
?
?
?
?
?
?
?
-
- =
?
?
?
?
?
?
?
?
?
?
36 . 155
8510 . 7
6720 . 3
3
2
1
a
a
a
and the maximum absolute relative approximate error is 125.47%.
Iteration #2
The estimate of the solution vector at the end of Iteration #1 is
?
?
?
?
?
?
?
?
?
?
-
- =
?
?
?
?
?
?
?
?
?
?
36 . 155
8510 . 7
6720 . 3
3
2
1
a
a
a
Now we get
( )
25
) 36 . 155 ( 8510 . 7 5 8 . 106
1
- - - -
= a
056 . 12 =
( )
8
) 36 . 155 ( 056 . 12 64 2 . 177
2
- - -
= a
882 . 54 - =
( ) ( )
1
882 . 54 12 056 . 12 144 2 . 279
3
- - -
= a
= 34 . 798 -
The absolute relative approximate error for each
i
x then is
100
056 . 12
6720 . 3 056 . 12
1
×
-
= ?
a
% 543 . 69 =
( )
100
882 . 54
8510 . 7 882 . 54
2
×
-
- - -
= ?
a
% 695 . 85 =
( )
100
34 . 798
36 . 155 34 . 798
3
×
-
- - -
= ?
a
% 540 . 80 =
At the end of the second iteration the estimate of the solution vector is
?
?
?
?
?
?
?
?
?
?
-
- =
?
?
?
?
?
?
?
?
?
?
54 . 798
882 . 54
056 . 12
3
2
1
a
a
a
and the maximum absolute relative approximate error is 85.695%.
Conducting more iterations gives the following values for the solution vector and the
corresponding absolute relative approximate errors.
Read More