Matlab code for crout method

Taimoor_Gondal 8,970 views 1 slides Jun 19, 2016
Slide 1
Slide 1 of 1
Slide 1
1

About This Presentation

Numerical analysis is a simple to calculate the competitions for the equations . this algorithm helps to solve equations using crouts method in MATLAB


Slide Content

Taimoor Muzaffar Gondal FA(13)-BEE-240 SECTION -5E
NUMERICAL ANALYSIS
Q 1-)
Write Down The Code For Crouts Factorization?

Y = [2 -1 0 0;-1 2 -1 0;0 -1 2 -1;0 0 -1 2];
clc
%%% code for Crouts decomposition

L = zeros(length(Y));
U = zeros(length(Y));

for j = 1: length(Y)
for i = 1:length(Y)
sum = 0;
p = j-1;
for k = 1:p
sum = sum+(L(i,k)*U(k,j));
end
if i == j
U(i,j) = 1;
end
if i >= j
L(i,j) = Y(i,j) - sum;
else
U(i,j) = (1/L(i,i))*(Y(i,j) -sum);
end
end
end
%%% display

Y
L
U
---------------------
Out Put:
Y =
2 -1 0 0
-1 2 -1 0
0 -1 2 -1
0 0 -1 2

L =
2.0000 0 0 0
-1.0000 1.5000 0 0
0 -1.0000 1.3333 0
0 0 -1.0000 1.2500

U =
1.0000 -0.5000 0 0
0 1.0000 -0.6667 0
0 0 1.0000 -0.7500
0 0 0 1.0000