Using Mathlab Solve the following equations using LU factori
Using Mathlab,
Solve the following equations using LU factorization “lu”, and Cholesky factorization “chol” using MATLAB
2x + 3y + 5z – 12 = 0
7x + 11y + 13z – 18 = 0
17x + 19y + 23z – 24 = 0
Solution
%lu factorization
A=[2 3 5;7 11 13;17 19 23];
b=[12;18;24];
[L,U,P]=lu(A);
y=(P*b);
y=L\\y;
x=U\\y
>> m4
x =
-2.0000
-3.0000
5.0000
cholesky factorization
%cholesky factorization
A=[2 3 5;7 11 13;17 19 23];
b=[12;18;24];
L=chol(A);
L1=conj(L);
L1=transpose(L1);
y=L\\b;
x=L1\\y
