Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

3. Write a function in MATLAB that takes as input an nx1 vector p of rearranged

ID: 3598301 • Letter: 3

Question

3. Write a function in MATLAB that takes as input an nx1 vector p of rearranged integers from 1 to n representing a permutation matrix P whose i-th row is the p(i)-th row of the identity matrix; an n x n matrix B whose upper triangular portion stores U and strictly lower triangular portion stores L of the LU factorization of the matrix PA: and an n× 1 vector b. Have this function output the solution to Ax = b. Use only basic programming. Only submit the code, but to make sure your code works, if you input p = [3; 1:2, B = [2,-1, 3:04.-3, 3:05,-02, 4] and b = [2,-1; 11, you should output x = [0.53:-0.83;-0.30]

Explanation / Answer

%matlab code for the factorzation


A = [ 1 2 3
4 5 6
7 8 0 ];
[L1,U] = lu(A)
L1*U
X = inv(U)*inv(L1)
[L2,U,P] = lu(A)
L2 = P*L1
P*A - L2*U
d = det(A)
d = det(L2)*det(U)
B = bucky;
[L2,U,P,Q] = lu(B);
Z = P*B*Q - L2*U;
norm(Z,1)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote