function [x,iter] = GSNR(b,L,varargin)

%  Nonlinear Gauss Seidel with relaxation L
%   (L=1 corresponds to no relaxation)
%   x=solution to x=f(x)
%   f = vector-valued function whose components are the cell entries in varargin
%   b=seed column vector
%   es = stop criterion (default = 0.00001%)
%   maxit = max iterations (default = 50)

if isempty(b),error('a seed vector is required'),end
if isempty(L),L=1;end
if isempty(varargin),error('must include function components as last arguments'),end

iter=0;
maxit=50;
es=0.00001;

x=zeros(length(b),1);;
while(1)

xold=x;

for i=1:length(b)
x(i)=varargin{i}(x);
x(i)=L*x(i)+(1-L)*xold(i);
if x(i) ~= 0
ea(i) = abs((x(i) - xold(i))/x(i)) * 100;
end

end

  iter = iter+1;
  if max(ea)<=es | iter >= maxit, break, end
end