function x=gauss1(a,b)
% Gauss elimination
n=length(b);	  
carpan=0;
toplam=0;
%pivoting
	p=k;
	buyuk=abs(a(k)(k));
	for(ii=k+1;ii<n;ii++)
	{  dummy=Math.abs(a(ii)(k));
	   if(dummy > buyuk) {buyuk=dummy;p=ii;}
	}
	if(p!=k)
	{ for(jj=k;jj<n;jj++)
	  { dummy=a(p)(jj);
	    a(p)(jj)=a(k)(jj);
	    a(k)(jj)=dummy;
	  }
	  dummy=b(p);
	  b(p)=b(k);
	  b(k)=dummy;
	}


  %gauss eleme
  for k=1:n
    for i=k+1:n
      carpan=a(i,k)/a(k,k);
       a(i,k)=0;
       for j=k+1:n
          a(i,j)=a(i,j)-carpan*a(k,j); 
       end
           b(i)   =b(i)   -carpan*b(k);
    end
  end
  %back substituting
  x(n)=b(n)/a(n,n);
  for i=n-1:-1:1
    toplam=0;
    for j=i+1:n
      toplam=toplam+a(i,j)*x(j);end
    x(i)=(b(i)-toplam)/a(i,i);
  end
end