kill[all]$;
n:3$;
decimales:5$;
prec:10^decimales$;
A=A:matrix([4,-1,1],[2,5,2],[1,2,4])$;
B=B:matrix([8],[3],[11])$;
gauss-seidel(A,B,n):=(
x:float(zeromatrix(n,1)),
y:float(zeromatrix(n,1)),
for m:1 thru 20 do(
for i:1 thru n do(
 y[i,1]:(B[i,1]-sum(A[i,j]*y[j,1],j,1,i-1)
               -sum(A[i,j]*x[j,1],j,i+1,n))/A[i,i]
),
dif: sum(abs(x[i,1]-y[i,1]),i,1,n),
print ("Iteración ",m, ": ", 
      float(round(transpose(y)*prec)/prec),
       ",Tol=", dif),
x:copymatrix(y)
))$;
gauss-seidel(A,B,n);