Page 236 - MATLAB an introduction with applications
P. 236
Numerical Methods ——— 221
Example E4.6: Solve the system of equations by Choleski’s factorization method.
12x – 6x – 6x – 1.5x = 1
1
3
4
2
–6x + 4x + 3x + 0.5x = 2
4
2
1
3
–6x + 3x + 6x + 1.5x = 3
3
2
1
4
–1.5x + 0.5x + 1.5x + x = 4
2
4
3
1
Solution:
MATLAB Solution [Using built-in function]:
Choleski’s method:
>> A = [12 – 6 – 6 – 1.5; – 6 4 3 0.5; – 6 3 6 1.5; – 1.5 0.5 1.5 1];
>> B = [1; 2; 3; 4];
>> [L,U] = lu(A)
L =
1.0000 0 0 0
–0.5000 1.0000 0 0
–0.5000 0 1.0000 0
–0.1250 –0.2500 –0.2500 1.0000
U =
12.0000 –6.0000 –6.0000 –1.5000
0 1.0000 0 –0.2500
0 0 3.0000 0.7500
0 0 0 0.5625
>> L*U
ans =
12.0000 –6.0000 –6.0000 –1.5000
–6.0000 4.0000 3.0000 0.5000
–6.0000 3.0000 6.0000 1.5000
–1.5000 0.5000 1.5000 1.0000
>> d = L\B
d =
1.0000
2.5000
3.5000
3.8750
>> x=U\d
x =
2.7778
4.2222
–0.5556
6.8889