1.

clc
2. A=[…]
3. b=[…]
4. n=4;
5. a=A
6. for i=1:n-1
7.

s=norm(A(i:n,i),2);

8.

beta=1/(s*(s+abs(A(i,i))));

9.

if (A(i,i)>=0)

10. t=1;
11. else t = - 1;
12. end
13.
14.

u=zeros(n,1);
u(i)=A(i,i)+t*s;

j)*x(j). 28. 17. x(n)=b(n)/A(n. end 27. 22. x(i)=(b(i)-s)/A(i. A=H*A 18.1) 21. u(i+1:n)=A(i+1:n. s=s+A(i. H=eye(n)-beta*u*u’. end . for j=i+1:n 25. b=H*b 19. s=0. end 20.i).15.i). for i=n-1:-1:1 23.n). 24. x=zeros(n. 16. 26.

if a(i.1). x(n)=b(n)/a(n. . end %Reolvarea sistemului triunghiular x=zeros(n.A*x clc. a=input('a=') disp('introduceti coloana termenilor liberi'). else t=sign(a(i. b=input('b=') [n. end disp('Solutia sistemului este:'). for i=n-1:-1:1 s=sum(a(i.i). disp('introducerea matricei sistemului').1). x(i)=(b(i)-s)/a(i.n]=size(a). u(i)=a(i.i)==0 t=1. s=norm(a(i:n.i))). disp(‘solutia Householder) 30. u(i+1:n)=a(i+1:n.i)+t*s.i).i+1:n)*x(i+1:n)). for i=1:n-1 fprintf('\n Etapa%d'. c=a.i)). a=H*a b=H*b.n). beta=1/(s^2+s*abs(a(i.disp(‘Verificare’) 32. end u=zeros(n.29. H=eye(n)-beta*u*u'.i). x 31.i).2).

x .

Sign up to vote on this title
UsefulNot useful