0% found this document useful (0 votes)
112 views2 pages

Doolittle LU Decomposition Program

This document contains a program to solve a system of linear equations (Ax=b) using the Doolittle method. It begins by clearing variables, getting user input for matrix A and vector b, and checking that A is square. It then calculates the L and U matrices using the Doolittle algorithm. Finally, it uses forward and back substitution on L and U to calculate the solution vector x. The program outputs the input matrix A, matrices L and U, intermediate vector y, and solution vector x.

Uploaded by

Fharhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
112 views2 pages

Doolittle LU Decomposition Program

This document contains a program to solve a system of linear equations (Ax=b) using the Doolittle method. It begins by clearing variables, getting user input for matrix A and vector b, and checking that A is square. It then calculates the L and U matrices using the Doolittle algorithm. Finally, it uses forward and back substitution on L and U to calculate the solution vector x. The program outputs the input matrix A, matrices L and U, intermediate vector y, and solution vector x.

Uploaded by

Fharhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

%% Program Metode dekomposisi LU - Metode Doodlittle

%
% Program Metode Doolittle ini dimodifikasi oleh MZA
math.Lectures Youtube Channel
%
%
% Input
% matriks A dan vektor kolom B
%
% Output
%
% Matriks L, U dan solusi dari SPL AX=B

%%
clear
clc
disp(' METODE DOOLITTLE ')
disp('Press Enter to continue')
pause
clc
%% input
A=input('masukkan matriks A yang akan diproses (Beri tanda
[]) :');
B1=input('Masukkan vektor kolom B (Beri tanda []) :');
B=B1';

[m,n]=size(A);
ordo=length(A);
while m~=n
disp('Matriks harus persegi')
break
end
U=zeros(m);
L=zeros(m);
%inisialisasi diagonal utama matriks L
for j=1:m
L(j,j)=1;
end

%inisialisai baris pertama matriks U sama dengan baris pertama


matriks A
for j=1:m
U(1,j)=A(1,j);
end

%Algoritma pencarian elemen matriks L dan U


for i=2:m
for j=1:m
for k=1:i-1
s1=0;
if k==1
s1=0;
else
for p=1:k-1
s1=s1+L(i,p)*U(p,k);
end
end
1
L(i,k)=(A(i,k)-s1)/U(k,k);
end
for k=i:m
s2=0;
for p=1:i-1
s2=s2+L(i,p)*U(p,k);
end
U(i,k)=A(i,k)-s2;
end
end
end

% Metode Penyulihan Maju untuk mencari vektor Y

Y1(1) = B(1);
for k=2:ordo
sigma1=0;
for j=1:k-1
sigma1=sigma1+L(k,j)*Y1(j);
Y1(k)= B(k)-sigma1;
end
end
Y=Y1';

%Metode penyulihan mundur untuk mencari vektor solusi X


X(ordo)=Y(ordo)/U(ordo,ordo);
for k=ordo-1:-1:1
sigma2=0;
for j=k+1:ordo;
sigma2=sigma2+U(k,j)*X(j);
X(k)=(Y(k)-sigma2)/U(k,k);
end
end

%% Output
disp('Matriks A =')
A
disp('Matriks L =')
L
disp('Matriks U =')
U
disp('Vektor Y =')
Y
disp('Vektor Solusi X =')
X'

You might also like