Question: Please run the following question in Matlab code Below is the example the question wants referenced Example 1: one step of Gaussian elimination % %
Please run the following question in Matlab code

Below is the example the question wants referenced
Example 1: one step of Gaussian elimination % % In this example, we first generate a matrix that has all elements in the % first 2 columns below the diagonal eliminated (zeroed out). Then we look % at the 3rd column, find the largest entry in modulus from the 3rd row to % the last row, then swap the 3rd row and the row containing this element. % After that, we multiply the new 3rd row by a proper factor and add it to % the 6th row, repeat for the 5th, etc, through the last row, so that the % elements in the 3rd column below the diagonal are all eliminated. % typical initial format setting and cleaning before we run each new code format short g; % or "format short e" are most commonly used clear; clc; % construct the initial matrix rng(2^6+1); A = -round(5*randn(7,7)); A(2:end,1) = 0; A(3:end,2) = 0; disp(A); % find the largest element in modulus (absolute value) in the 3rd column on % the 3rd through the last row [~,idx] = max(abs(A(3:end,3))); % locate the row containing the largest element, then swap the 3rd row and % this row idx = idx-1+3; A([3 idx],:) = A([idx 3],:); % for each of the 4th, 5th, ..., last row, multiply the 3rd row by a proper % factor and add it to these rows to eliminate the elements in the 3rd % column and 4th, 5th, ..., last row for k = 4 : size(A,1) t = -A(k,3)/A(3,3); A(k,:) = A(3,:)*t + A(k,:); end % manually zero out the elements that should be zero in exact arithmetic % (and are usually very small compared to A(3,3) in computer arithmetic) A(4:end,3) = 0;
(See Example 1) Run command rng default, then generate a 8 x 8 random matrix the same way as Example 1 given in crashcourse... For each subproblem below, display the matrix after the required operations are completed. (a) Zero out the elements in the last 3 columns that are above the diagonal (for ex- ample, in the 2nd to the last column, zero out those in rows I through 6). (b) Check the 5th column, consider the top portion of this column, from row 1 through row 5. Find the largest (in absolute value) element in this partial column. Swap the row containing this largest element with the 5th row. (c) Multiply the 5th row by proper numbers and add to row 1 through row 1, so that the elements in the 5th column above the diagonal (in rows 1 through 4) are zeroed out. Check if those elements are sufficiently small in modulus; if so, set them as zeros. (See Example 1) Run command rng default, then generate a 8 x 8 random matrix the same way as Example 1 given in crashcourse... For each subproblem below, display the matrix after the required operations are completed. (a) Zero out the elements in the last 3 columns that are above the diagonal (for ex- ample, in the 2nd to the last column, zero out those in rows I through 6). (b) Check the 5th column, consider the top portion of this column, from row 1 through row 5. Find the largest (in absolute value) element in this partial column. Swap the row containing this largest element with the 5th row. (c) Multiply the 5th row by proper numbers and add to row 1 through row 1, so that the elements in the 5th column above the diagonal (in rows 1 through 4) are zeroed out. Check if those elements are sufficiently small in modulus; if so, set them as zeros
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
