#
## Author: M. Turhan ÇOBAN
## Created: 2021-06-05

function retval = gauss_seidel (f,x,alpha)
  n=length(x);
  iter=500;
  xx=zeros(1,n);
  xx=x;
  for k=1:iter
    for i=1:n
      xx1(i)=xx(i);
    endfor
    delta=0.0;
    for j=1:n
      g=f(xx);
      xx(j)=(1.0-alpha)*xx(j)+alpha*g(j);
      delta=delta+abs(xx(j)-xx1(j));
    endfor
    if delta<1e-15 
      break;
    end 
  
  endfor
  retval=xx;
endfunction
