A=[4 3 0;
3 4 -1;
0 -1 4]
C=[24;30;-24]
x=GaussSeidelWithOverrelaxation(A,C)
function x=GaussSeidelWithRelaxation(A,C)
x=zeros(size(C));
xold=x;
omega=1.9;
[n,n]=size(A);
residual=A*x-C
counter=0;
while max(abs(residual)) > 1.0e-8
for i=1:n
sum=0.0;
for j=1:n
if j~=i
sum=sum-A(i,j)*x(j);
end
end
x(i)=(sum+C(i))/A(i,i);
end
x=omega*x+(1-omega)*xold;
residual=A*x-C;
xold=x
counter=counter+1
end
end