METODA HOUSEHOLDER
clc; disp('Introduceti matricea sistemului: '); a=input('A= '); disp('Coloana termenilor liberi: '); b=input('B= '); A=a;B=b; [n,n]=size(A); for i=1:n-1 s=norm(a(i:n,i),2); beta=1/(s^2+abs(a(i,i)*s)); u=zeros(n,1); if a(i,i)==0 t=1; else t=sign(a(i,i)); end u(i)=a(i,i)+t*s; for j=i+1:n u(j)=a(j,i); end H=eye(n)-beta*u*u'; a=H*a b=H*b; end x=zeros(n,1); x(n)=b(n)/a(n,n); for i=n-1:-1:1 p=0; for j=i+1:n p=p+a(i,j)*x(j); end x(i)=(b(i)-p)/a(i,i); end disp('Solutia este: ') x