Question: We will make function files 1) function [U.c]=GE...(Ab) and 2) function x=ut sys[U.c) on MATLAB by using Gauss Elimination. While we were finding the Upper

 We will make function files 1) function [U.c]=GE...(Ab) and 2) function

x=ut sys[U.c) on MATLAB by using Gauss Elimination. While we were finding

the Upper triangular matrix, we will see the pivot entry is zero.

If this case happens, we will swap the rows. I will try

to explain next. function [.]=GE...(A.b) n=length (b) for k=1: n-1 use 'while"

We will make function files 1) function [U.c]=GE...(Ab) and 2) function x=ut sys[U.c) on MATLAB by using Gauss Elimination. While we were finding the Upper triangular matrix, we will see the pivot entry is zero. If this case happens, we will swap the rows. I will try to explain next. function [.]=GE...(A.b) n=length (b) for k=1: n-1 use 'while" (%locate row that contains 1st nonzero % among nan possible entries) If r=k, no need to swap (% If r not=k, swap rth and kth row, % then go them GE If r>n disp (If all possible pivot entries have zero, print out "A is not invertible and the U and c returned are meaningless." Then quit out) After we will check our code on commend window for this example. Command window: >> A= (1 -1 2-1 2-2 3-3 1110 1-143] >> b= (-8-20-2 4] T >>(US) = GE... (Ab) >>x=ut.sys (US) check both function match Our elimination step is: 1. R2_R2-2R1 R3_R3-R1 R4_R4-R1 2. If we do R3 R3-2/0R2 and R4_R4-0/0R2 will come NaN and Inf numbers. For next step R4_R4-(Inf/NaN) R3 will come NaN number So will do instead of before (for second part) R4_R4-2/-1R3 X= (-7,3,2,2) T U = [1 -1 2-1 02-11 00-1-1 0002] Ux=C C=[-8, 6,-4, 4] T 2) Part (a): >> A= (1 11 221 112] >> b= [4, 6, 6] T >>[U.c] = GEA.b) should get U= [1 11 00-1 001] C= [ 4, -2, 2] T. Because we did elimination such that; 1. R2_R2-2R1 and R3_R3-R1 2) Part (b): What happens A is not invertible? Ax=b1 and Ax=b2 then (A\b1,b2] >> A= A=(1 11 2 2 1 112] b1= [4, 6, 6] T b2=[4, 4, 6] T 1. R2_R2-2R1 and R3_R3-R1 we will see A is not invertible AU A_R(rret) 2. R2_-R2 3. R1_R2-2R1 and R3_R3-R2 so we will see 2nd row has no solution U= [1 1 0 001 000] Ux=c C= [2, 2, 0] T So x1, x3 are leading variables and x2 is free. Infinitely many solutions. U: upper triangular matrix. My old code is here if it is possible you can modify this code. function x=ut_sys(u.c) n=length(c); x=zeros(n:1) function (A,b]-gauss_eliminationn(A,b) n=length(b); for k=1:-1 x(n)=c(n)/(n,n); for j=kin-1 for k=n-1:-1:1 for j=k:-1:1 x(k)=x(k)/(k.k); b(j+1)=(((A[j+1,k)/Ak.k))*(-1))*(b(k)))+(1+1): A[j+1,:)=((( A[j+1,k)/A(k,k))*(-1))*(A(k.:)))+A[j+1.:): end x(j)=x(j)-uj,k+1)*x(k+1); x=x': end end end end end We will make function files 1) function [U.c]=GE...(Ab) and 2) function x=ut sys[U.c) on MATLAB by using Gauss Elimination. While we were finding the Upper triangular matrix, we will see the pivot entry is zero. If this case happens, we will swap the rows. I will try to explain next. function [.]=GE...(A.b) n=length (b) for k=1: n-1 use 'while" (%locate row that contains 1st nonzero % among nan possible entries) If r=k, no need to swap (% If r not=k, swap rth and kth row, % then go them GE If r>n disp (If all possible pivot entries have zero, print out "A is not invertible and the U and c returned are meaningless." Then quit out) After we will check our code on commend window for this example. Command window: >> A= (1 -1 2-1 2-2 3-3 1110 1-143] >> b= (-8-20-2 4] T >>(US) = GE... (Ab) >>x=ut.sys (US) check both function match Our elimination step is: 1. R2_R2-2R1 R3_R3-R1 R4_R4-R1 2. If we do R3 R3-2/0R2 and R4_R4-0/0R2 will come NaN and Inf numbers. For next step R4_R4-(Inf/NaN) R3 will come NaN number So will do instead of before (for second part) R4_R4-2/-1R3 X= (-7,3,2,2) T U = [1 -1 2-1 02-11 00-1-1 0002] Ux=C C=[-8, 6,-4, 4] T 2) Part (a): >> A= (1 11 221 112] >> b= [4, 6, 6] T >>[U.c] = GEA.b) should get U= [1 11 00-1 001] C= [ 4, -2, 2] T. Because we did elimination such that; 1. R2_R2-2R1 and R3_R3-R1 2) Part (b): What happens A is not invertible? Ax=b1 and Ax=b2 then (A\b1,b2] >> A= A=(1 11 2 2 1 112] b1= [4, 6, 6] T b2=[4, 4, 6] T 1. R2_R2-2R1 and R3_R3-R1 we will see A is not invertible AU A_R(rret) 2. R2_-R2 3. R1_R2-2R1 and R3_R3-R2 so we will see 2nd row has no solution U= [1 1 0 001 000] Ux=c C= [2, 2, 0] T So x1, x3 are leading variables and x2 is free. Infinitely many solutions. U: upper triangular matrix. My old code is here if it is possible you can modify this code. function x=ut_sys(u.c) n=length(c); x=zeros(n:1) function (A,b]-gauss_eliminationn(A,b) n=length(b); for k=1:-1 x(n)=c(n)/(n,n); for j=kin-1 for k=n-1:-1:1 for j=k:-1:1 x(k)=x(k)/(k.k); b(j+1)=(((A[j+1,k)/Ak.k))*(-1))*(b(k)))+(1+1): A[j+1,:)=((( A[j+1,k)/A(k,k))*(-1))*(A(k.:)))+A[j+1.:): end x(j)=x(j)-uj,k+1)*x(k+1); x=x': end end end end 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!