Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Can i know the step and have the code? Question 4: Gaussian Elimination and LU Factorization with MATLAB (40 marks) You will use MATLAB to
Can i know the step and have the code?
Question 4: Gaussian Elimination and LU Factorization with MATLAB (40 marks) You will use MATLAB to carry out elementary row operations (Gaussian Elimination) and to obtain the matrix factorization P=LU for a square 3 x 3 matrix P. (a) Initialize the random number generator by using Random Seed where abcd are the last four digits of your student ID number. Make sure your included this line in your write-up. Generate a random 3 x 3 matrix P and calculate the three principal minors of P. The LU factorization P=LU is only possible when all the principal minors are non-zero. Since P is a random matrix, this situation is certainly satisfied. If any of the number after the matrix P is zero, repeat this step again until you can generate a matrix P with all three numbers after P is non-zero. Make sure you include all the matrices that you generate this way in your assignment report. When the matrix P for all three principal minors are non-zero, transform the matrix P into an upper-triangular matric U using only one type of row operation: adding a multiple of one row to a row below. You will choose multipliers to put zeros below the diagonal elements. At the end of the LU algorithm Uwill be upper triangular. Start by entering the initial value U = P in MATLAB. using m-file called coli.m. The m-file requires a 3 x 3 matrix U to be already defined in your workspace. Execute this file by typing coli at the MATLAB prompt. The matrix L1 should be unit lower triangular with non-zero entries only on the diagonal and in column 1. Set up U = L1 * U using MATLAB. Remember that the command X = Y in MATLAB means to replace the current value of the variable X by the current value of the variable Y. The new matrix U should have zeros in the first column below the main diagonal. (b) Next, for the LU factorization put a zero below the main diagonal in column 2 of U. Use the MATLAB editor to create a m-file called col2.m This procedure required the matrix U modified from (a). Execute this file by typing col2 at the MATLAB prompt. The matrix L2 should be unit lower triangular with non-zero entries on the diagonal and in column 2. Now set U=L2 * U using MATLAB. The new matrix U should have all zeros below the main diagonal. Using MATLAB to verify that U = L2 * L1 * P (c) To complete the P=LU factorization, calculate inv(L1), inv(L2), L = inv(L1)*inv(L2) Question 4: Gaussian Elimination and LU Factorization with MATLAB (40 marks) You will use MATLAB to carry out elementary row operations (Gaussian Elimination) and to obtain the matrix factorization P=LU for a square 3 x 3 matrix P. (a) Initialize the random number generator by using Random Seed where abcd are the last four digits of your student ID number. Make sure your included this line in your write-up. Generate a random 3 x 3 matrix P and calculate the three principal minors of P. The LU factorization P=LU is only possible when all the principal minors are non-zero. Since P is a random matrix, this situation is certainly satisfied. If any of the number after the matrix P is zero, repeat this step again until you can generate a matrix P with all three numbers after P is non-zero. Make sure you include all the matrices that you generate this way in your assignment report. When the matrix P for all three principal minors are non-zero, transform the matrix P into an upper-triangular matric U using only one type of row operation: adding a multiple of one row to a row below. You will choose multipliers to put zeros below the diagonal elements. At the end of the LU algorithm Uwill be upper triangular. Start by entering the initial value U = P in MATLAB. using m-file called coli.m. The m-file requires a 3 x 3 matrix U to be already defined in your workspace. Execute this file by typing coli at the MATLAB prompt. The matrix L1 should be unit lower triangular with non-zero entries only on the diagonal and in column 1. Set up U = L1 * U using MATLAB. Remember that the command X = Y in MATLAB means to replace the current value of the variable X by the current value of the variable Y. The new matrix U should have zeros in the first column below the main diagonal. (b) Next, for the LU factorization put a zero below the main diagonal in column 2 of U. Use the MATLAB editor to create a m-file called col2.m This procedure required the matrix U modified from (a). Execute this file by typing col2 at the MATLAB prompt. The matrix L2 should be unit lower triangular with non-zero entries on the diagonal and in column 2. Now set U=L2 * U using MATLAB. The new matrix U should have all zeros below the main diagonal. Using MATLAB to verify that U = L2 * L1 * P (c) To complete the P=LU factorization, calculate inv(L1), inv(L2), L = inv(L1)*inv(L2)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started