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

Enter the matrix A and the vector b in MATLAB: A = [2 1 -4 2 2 2 -3 1 4 1 -7 3 6 4 -8 3], b = [6 8 -11 3] The exact solution to the system Ax = b is the vector x = (-1, 8, 1, -2)^T. Enter [L, U, P] = lu(A) to find the LU decomposition of the matrix PA and verify that PA = LU. Use the LU decomposition you found in part (a) to solve the system Ax = b. Call the computed solution x_lu. Enter the vector x and compare your solution x_lu from part (b) with the exact solution x by computing norm(x_lu - x) (the norm function gives the magnitude of the vector, that is, for a vector a = (a_1, a_2, ..., a_n)^T, the norm of a is defined as: norm(a) = Squareroot a^2_1 + a^2_2 + ... + a^2_n).

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

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site