You are on page 1of 1

clear

A=[10,1,-1,2,1,-1;1,12,-1,2,-1,2;-2,1,14,1,2,1;1,-2,-1,11,-1,3;-2,1,2,-1,12,-3;1,-
1,-2,1,2,15];
b=[12,15,17,11,9,16];
X0=zeros(1,6);
X=X0;K=0;Norma=1;
fprintf(' k x(1) x(2) x(3) x(4) x(5) x(6) Norman')
while Norma 0.001
K=K+1;
fprintf('%2d' , K)
for i=16
suma=0;
for j=16
if i~=j
suma=suma+A(i,j)X(j);
end
end
X(i)=(b(i)-suma)A(i,i);
fprintf('%10.4f',X(i))
end
Norma=norm(X0-X);
fprintf('%10.4fn',Norma)
X0=X;
if K15
disp('Nose alcanzo la convergencia')
break
end
end

You might also like