I am done with part a and need some help with part b and c T
I am done with part a, and need some help with part b and c. Thnaks.
Part a
>> A=[2,2,4,6;1,2,1,4;-3,-3,-7,-8;2,1,3,3]
A =
2 2 4 6
1 2 1 4
-3 -3 -7 -8
2 1 3 3
>> A=[2,2,4,6;1,2,1,4;-4,-3,-7,-8;2,1,3,3]
A =
2 2 4 6
1 2 1 4
-4 -3 -7 -8
2 1 3 3
>> b=[6;8;-11;3]
b =
6
8
-11
3
>> [L,U,P]=lu(A)
L =
1.0000 0 0 0
-0.2500 1.0000 0 0
-0.5000 0.4000 1.0000 0
-0.5000 -0.4000 -1.0000 1.0000
U =
-4.0000 -3.0000 -7.0000 -8.0000
0 1.2500 -0.7500 2.0000
0 0 0.8000 1.2000
0 0 0 1.0000
P =
0 0 1 0
0 1 0 0
1 0 0 0
0 0 0 1
>> y = L\\b
y =
6.0000
9.5000
-11.8000
-2.0000
>> x = U\\y
x =
20.2500
3.7500
-11.7500
-2.0000
>> %verify PA = LU
>> P*A
ans =
-4 -3 -7 -8
1 2 1 4
2 2 4 6
2 1 3 3
>> L*U
ans =
-4 -3 -7 -8
1 2 1 4
2 2 4 6
2 1 3 3
Solution
Matlab 2016a Code
clear all
clc
A=[2 2 4 6;
1 2 1 4;
-4 -3 -7 -8;
2 1 3 3];
b=[6;8;-11;3];
x=[-1;8;1;-2];
%Part (a)
[L,U,P]=lu(A);
P*A
L*U
P*A-L*U
%Part (b)
y=inv(L)*b
x_lu=inv(U)*y
%Part (c)
norm(x_lu-x)
![I am done with part a, and need some help with part b and c. Thnaks. Part a >> A=[2,2,4,6;1,2,1,4;-3,-3,-7,-8;2,1,3,3] A = 2 2 4 6 1 2 1 4 -3 -3 -7 -8 2 1 I am done with part a, and need some help with part b and c. Thnaks. Part a >> A=[2,2,4,6;1,2,1,4;-3,-3,-7,-8;2,1,3,3] A = 2 2 4 6 1 2 1 4 -3 -3 -7 -8 2 1](/WebImages/26/i-am-done-with-part-a-and-need-some-help-with-part-b-and-c-t-1067518-1761558651-0.webp)
![I am done with part a, and need some help with part b and c. Thnaks. Part a >> A=[2,2,4,6;1,2,1,4;-3,-3,-7,-8;2,1,3,3] A = 2 2 4 6 1 2 1 4 -3 -3 -7 -8 2 1 I am done with part a, and need some help with part b and c. Thnaks. Part a >> A=[2,2,4,6;1,2,1,4;-3,-3,-7,-8;2,1,3,3] A = 2 2 4 6 1 2 1 4 -3 -3 -7 -8 2 1](/WebImages/26/i-am-done-with-part-a-and-need-some-help-with-part-b-and-c-t-1067518-1761558651-1.webp)