// Resuelve Ax=b usando el metodo Gauss-Seidel
A=[4 3 0; 3 4 -1; 0 -1 4]
b=[24; 30;-24]
N = 3;
x=[1; 1; 1];
xt=[1; 1; 1];
eps = 1e-7
iter = 100;


for it = 1: iter
   for i = 1: N
      sum = 0.0;
      for j = 1: (i-1)
         sum = sum + A(i,j) * xt(j);
      end
      for j = (i+1): N
         sum = sum + A(i,j) * x(j);
      end
      if A(i,i) == 0.0 then
         exit(1);
      end
      xt(i) = (b(i) - sum) / A(i,i);
   end
   xt
   sw = 0;
   for i = 1: N
      if abs(x(i) - xt(i)) >= eps then
         sw = 1;
      end
      x(i)=xt(i);
   end
   if sw == 0 then
      break;
   end
end
it
x

