Off[General::spell1];
Clear[JacobiMethod,a0,b0, M0];
JacobiMethod[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++,
       u[[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]]    ];
    For[j=1, j<=n, j++,
       x[[j]] = u[[j]]   ]; 
    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[JacobiMethod[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};

JacobiMethod[A,B,30]//N

Max[N[ Abs[Eigenvalues[A -IdentityMatrix[3]]], 10]]

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

N[JacobiMethod[A,B,10],10]

Eigenvalues[A - IdentityMatrix[2]]

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[JacobiMethod[A,B,10],10]

Max[N[ Eigenvalues[A - IdentityMatrix[4]], 10]]