This method belongs to the LU factoring system. From matrix A, there are two matrices L and U, in this method the matrix L is triangular inferior and in the diagonal it has 1 (unitary), while U is a superior triangular matrix. Being the triangular matrices, we can calculate each element of the matrix A by means of...
Pseudocode.
Input A, b
n= # de filas de A
L=eye(n);
U=zeros(n);
for k=1:n
for j=k:n
suma=0;
for i=1:k-1
suma=suma+L(k,i)*U(i,j);
end
U(k,j)=A(k,j)-suma;
end
for i=k:n
suma=0;
for j=1:k-1
suma=suma+L(i,j)*U(j,k);
end
L(i,k)=(A(i,k)-suma)/U(k,k);
end
end
for i=1:n
suma=0;
for p=1:i-1
suma=suma+L(i,p)*d(p,1);
end
d(i,1)=(b(i,1)-suma)/L(i,i);
end
for i=n:-1:1
suma=0;
for p=i+1:n
suma=suma+U(i,p)*X(p,1);
end
X(i,1)=(d(i,1)-suma)/U(i,i);
end
Code.
Clc
A=input('ingrese la matriz: ');
b=input('ingrese la matriz de términos independientes: ');
n=size(A,1);
L=eye(n);
U=zeros(n);
for k=1:n
for j=k:n
suma=0;
for i=1:k-1
suma=suma+L(k,i)*U(i,j);
end
U(k,j)=A(k,j)-suma;
end
for i=k:n
suma=0;
for j=1:k-1
suma=suma+L(i,j)*U(j,k);
end
L(i,k)=(A(i,k)-suma)/U(k,k);
end
end
disp('U=')
disp(U)
disp('L=')
disp(L)
disp('L*U=')
disp(L*U)
for i=1:n
suma=0;
for p=1:i-1
suma=suma+L(i,p)*d(p,1);
end
d(i,1)=(b(i,1)-suma)/L(i,i);
end
disp('d=');
disp(d);
for i=n:-1:1
suma=0;
for p=i+1:n
suma=suma+U(i,p)*X(p,1);
end
X(i,1)=(d(i,1)-suma)/U(i,i);
end
disp(‘La solucion es::')
disp(X)
B=A*X