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

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 correct sign) and
detects whether the system is singular based on a near-zero determinant. Define near-zero as
being when the absolute value of the determinant is below a tolerance. When this occurs, the
function should display an error message and terminate. The first line of the function should be:
function [x, D] = GaussPivot2(A, b, tol) where D is the determinant, and tol is the tolerance. Do not use the Matlab det() function.
(b) Showtheresultofrunningyourfunctiononthefollowingsystemofequationswithtol=0.00001
2x2 + 5x3 = 1
2x1+x2 +x3=1 4x1 +2x2 +2x3 =4
 3. Consider the MATLAB function GaussPivot() given in class in slide

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!