Question: 3. Consider the MATLAB function GaussPivot() given in class in slide 5-31. (a) Modify GaussPivot() so that it computes and returns the determinant (with the
function xGausspivot (A.b) t GaussPivot: Gauss elimination pivoting x GaussPivot (A.b): Gauss elimination with pivoting. t input: A coefficient matrix t b right hand side vector output: x solution vector Im, n]-size(A): it m-en, error( Matrix A must be square'): end nb-n+1: Aug= [A b] ; s forward elimination for k1:n-1 t partial pivoting tbig, il-max (abs (Aug (k:n,k))) ipr-i+k-1 if ipr-k end for i- k+l:n factor-Aug (i,k) /Aug (k,k) i end end back substitution xszeros (n, 1) i x ( n )-Aug ( n , nb) /Aug ( n , n ) for i n-1:-1:1 x(i) -(Aug (i.nb) -Aug (1, i+1:n) x(1+n)/Aug(s,1) end function xGausspivot (A.b) t GaussPivot: Gauss elimination pivoting x GaussPivot (A.b): Gauss elimination with pivoting. t input: A coefficient matrix t b right hand side vector output: x solution vector Im, n]-size(A): it m-en, error( Matrix A must be square'): end nb-n+1: Aug= [A b] ; s forward elimination for k1:n-1 t partial pivoting tbig, il-max (abs (Aug (k:n,k))) ipr-i+k-1 if ipr-k end for i- k+l:n factor-Aug (i,k) /Aug (k,k) i end end back substitution xszeros (n, 1) i x ( n )-Aug ( n , nb) /Aug ( n , n ) for i n-1:-1:1 x(i) -(Aug (i.nb) -Aug (1, i+1:n) x(1+n)/Aug(s,1) end
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
