Off[General::spell1];
Clear[GaussSeidel,a0,b0, M0];
GaussSeidel[a0_,b0_, M0_] :=
Module[{a,b,k,n,x,u},
  a = a0; b = b0; M = M0;
  n = Length[b];
  x = Table[0,{i, n}];
  u = Table[0, {i,n}];
  Clear[i,k];
  For[k=1,k<=M,k++,
    For[i=1, i<=n, i++,
      x[[i]] = (b[[i]] - Sum[a[[i,j]]*
         x[[j]], {j,1,i-1}]
         - Sum[a[[i,j]] x[[j]], 
            {j,i+1,n}])/a[[i,i]]    ];
    Print[N[x,10]];  ]; 
  Return[x]; ] 
  On[General::spell1];

Clear[A,B]; 
A = {{4,-1,1},{4,-8,1},{-2,1,5}};
B = {7,-21,15}; 
StringForm["A= ``    B = ``", MatrixForm[A], MatrixForm[B]]

N[GaussSeidel[A,B,10],10]

Clear[A,B];
A={ {1,1/2,1/3}, {1/3,1,1/2},{1/2,1/3,1} };  
B={11/18,11/18,11/18};

GaussSeidel[A,B,25]//N

Clear[n,Q];
 n=Length[A];
 Q=Table[If[i >= j, A [[i,j]], 0], {i,n},{j,n}];  
 Max[N[Abs[Eigenvalues[IdentityMatrix[n]-Inverse[Q].A]],8]]

Clear[A,B]; 
A = {{1,2},{2,1}};
B = {1/3,1/3};  
StringForm["A= ``    B = ``", MatrixForm[A], MatrixForm[B]]

N[GaussSeidel[A,B,10],10]

Clear[n,Q]; 
 n=Length[A]; 
 Q=Table[If[i >=j, A [[i,j]], 0],  {i,n},{j,n}];  
 Max[N[ Abs[Eigenvalues[IdentityMatrix[n]-Inverse[Q].A]],8]]

Clear[A,B]; 
A = {{1,0,-1/4,-1/4},{0,1,-1/4,-1/4},{-1/4,-1/4,1,0},
      {-1/4,-1/4,0,1}};
B = {1,1,1,1};   
StringForm["A= ``    B = ``", MatrixForm[A], MatrixForm[B]]

N[GaussSeidel[A,B,10],10]

Clear[n,Q]; 
n=Length[A]; 
Q=Table[If[i >= j, A [[i,j]], 0],  {i,n},{j,n}];  
Max[N[ Abs[Eigenvalues[IdentityMatrix[n]-Inverse[Q].A]], 10]]