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

Write a function in MATLAB that takes as input an n times 1 vector p of rearrang

ID: 2084819 • Letter: W

Question

Write a function in MATLAB that takes as input an n times 1 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 times 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 times 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: 0.4, -3, 3, 05, -0.2, 4] and b = [2: -1: 1], 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