LU Decomposition With Gauss Elimination
LU Decomposition With Gauss Elimination
LU Decomposition With Gauss Elimination
1) LU Decomposition: [A] is decomposed into lower [L] and upper [U] triangular matrics
[L,U] = lu(A)
Forward Elimination step is performed to reduce the original co efficient matrix A. This produces the
following result :
This result can be verified by multiplying this two matrices and comparing them with original matrix. If
the multiplication matrix is same as original matrix than the upper and lower matrices have correct
value.
2) Substitution Step: [L] and [U] are used to find the solution.
D=[L]/[B]= 7.85
-19.5617
70.0843
[U]{X}-{D}=0
X= U/D
X = 3.0000
-2.5000
7.0000
MATLAB Code:
% LU Factorization
clc
clear all
a = [3 -0.1 -0.2; -0.1 7 -0.3; -0.3 -0.2 10];
b = [7.85; -19.3; 71.4];
[l,u]= lu(a)
d=l\b
x=u\d
Results:
% LU Factorization
clc
clear all
a = [3 -0.1 -0.2; -0.1 7 -0.3; -0.3 -0.2 10];
b = [7.85; -19.3; 71.4];
[l,u]= lu(a)
d=l\b
x=u\d
l =
1.0000 0 0
-0.0333 1.0000 0
-0.1000 -0.0300 1.0000
u =
3.0000 -0.1000 -0.2000
0 6.9967 -0.3067
0 0 9.9708
ans =
3.0000 -0.1000 -0.2000
-0.1000 7.0000 -0.3000
-0.3000 -0.2000 10.0000
d =
7.8500
-19.0383
71.6136
x =
3.0153
-2.4063
7.1823
Cholesky Decomposition:
This method is used to find solution of symmetric matrix. This method takes almost half time to find
solution in comparison to find using LU factorization. It also takes almost half storage.
L= chol(A)
If both the results are same than the generated factorization is correct.
To generate solution,
D= LT/b
D= 31.0269
25.0998
6.1101
X=A/Y
X= 1.0000
1.0000
1.0000
MATLAB Code:
clc
clear all
A=[6 15 55; 15 55 225; 55 225 979];
d=L\b
Results:
clc
clear all
A=[6 15 55; 15 55 225; 55 225 979];
d=L\b
b =
76
295
1259
L_trans =
2.4495 6.1237 22.4537
0 4.1833 20.9165
0 0 6.1101
d =
31.0267
25.1002
6.1091