Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books

Students also viewed these Databases questions

Question

=+c. Does it use short, concise sentences?

Answered: 1 week ago

Question

=+10. How are inflation and unemployment related in the short run?

Answered: 1 week ago

Question

=+8. Why is productivity important?

Answered: 1 week ago