In: Advanced Math
Using Matlab, write code that carries out the following instructions:
**Within your Live Script, create a matrix A by starting with eye(5) and performing the following sequence of elementary row-operations: first, replace (row4) with [(row4) + (row2) ⋅3], then, interchange rows 1 and 3 of the obtained matrix, and, finally, scale row5 of the matrix from the previous step by 6 to get the output matrix A. Display A.
Note: To complete this part, you, should, first, create (and output) the required elementary matrices for the corresponding sets of variables (the variables are specific for each function!) and use consecutive three step left-multiplication to get the matrix A.
% Explain in your Live Script a reason why the obtained matrix A is invertible.
**Calculate (and output) the inverse of A, by using the MATLAB command inv1=inv(A)
**Then, calculate and output the matrix inv2 which is the inverse of A obtained by multiplying (in the reverse order!) the inverses of the elementary matrices whose product is A. (You can apply a MATLAB command inv() to the matrices E1, E2, E3.)
**Run a conditional statement in the Live Scrip that
would check if the matrices inv1 and inv2 match. If yes, output a
message that the inverses match; otherwise, output the message:
“Check the coding!” (This message, if received, should prompt you
to make corrections and re-run the Section.)
ANSWER:
Given That data Within your Live Script, create a matrix A by starting with eye(5) and performing the following sequence of elementary row-operations: first, replace (row4) with [(row4) + (row2) ⋅3], then, interchange rows 1 and 3 of the obtained matrix, and, finally, scale row5 of the matrix from the previous step by 6 to get the output matrix A. Display A.
Note: To complete this part, you, should, first, create (and output) the required elementary matrices for the corresponding sets of variables (the variables are specific for each function!) and use consecutive three step left-multiplication to get the matrix A.
% Explain in your Live Script a reason why the obtained matrix A is invertible.
**Calculate (and output) the inverse of A, by using the MATLAB command inv1=inv(A).
So
Mat lab code:
% Creating Matrix A
A = eye(5)
% Matrix E1
E1 = eye(5);
E1(4, 2) = 1
% Matrix E2
E2 = eye(5);
E2(1, 1) = E2(3, 3) = 0;
E2(1, 3) = E2(3, 1) = 1
% Matrix E3
E3 = eye(5);
E3(5, 5) = 6
% Matrix A
A = E1 * A
A = E2 * A
A = E3 * A
% inv1
inv1 = inv(A)
% inv2
inv2 = inv(E3) * inv(E2) * inv(E1)
% Checking for equality
if inv1 == inv2
disp("Matrices Match")
else
disp("Check Coding")
end;
OUTPUT:
A=
Diagonal Matrix
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
E1 =
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 1 0 1 0
0 0 0 0 1
E2=
0 0 1 0 0
0 1 0 0 0
1 0 0 0 0
0 0 0 1 0
0 0 0 0 1
E3=
Diagonal Matrix
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 6