336 CHAPTER 14. NUMERICAL SOLUTIONS OF LINEAR SYSTEMS

The iterates are defined asa11 0 · · · 0

a21 a22. . .

......

. . .. . . 0

an1 · · · ann−1 ann



xr+11

xr+12...

xr+1n



= −

0 a12 · · · a1n

0 0. . .

......

. . .. . . an−1n

0 · · · 0 0



xr1

xr2...

xrn

+

b1

b2...

bn

 (14.5)

If xr converges to some x then this will be a solution to the original equation.

In words, you set every entry in the original matrix which is strictly above the maindiagonal equal to zero to obtain the matrix on the left. To get the matrix on the right,you set every entry of A which is on or below the main diagonal equal to zero. Using theiteration procedure of 14.4 directly, the Gauss Seidel method makes use of the very latestinformation which is available at that stage of the computation.

The following example is the same as the example used to illustrate the Jacobi method.

Example 14.2.2 Use the Gauss Seidel method to solve the system3 1 0 01 4 1 00 2 5 10 0 2 4



x1

x2

x3

x4

=

1234

You can use MATLAB in the same way. You just use different matrices. As is the case

with the Jacobi method, you would not invert the matrix but would use the description ofthe method given above. The following works fine for small systems of equations however.

L=[3 0 0 0;1 4 0 0;0 2 5 0;0 0 2 4];U=[0 1 0 0;0 0 1 0;0 0 0 1;0 0 0 0];d=1; x=[0;0;0;0]; b=[1;2;3;4]; k=1; F=inv(L);while d >.0000001 & k <1000y=-F*U*x+F*b; d=(y-x)’*(y-x); k=k+1;x=y;endxk(((L+U)*x-b)’*((L+U)*x-b))ˆ(1/2)