% gausei, Gauss-Seidels metod på glest diagonaltungt system 
  clear
  n=20; 
  x=zeros(n,1);  b=cos((1:n)*pi/n)';  dxnorm=1;  flops(0)
  while dxnorm>1e-4
    xold=x;
    x(1)=(b(1)-x(2)-x(n))/4;
    for i=2:n-1, x(i)=(b(i)-x(i-1)-x(i+1))/4;  end
    x(n)=(b(n)-x(n-1)-x(1))/4;
    dxnorm=norm(x-xold,inf)
  end
  xsolve=x
flops
