Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You will create a function that finds the unique solution to Ax-b equation using

ID: 3733692 • Letter: Y

Question

You will create a function that finds the unique solution to Ax-b equation using Gaussian elimination with partial pivoting (using the absolute maximum possible value of the active column for the pivot) where A is a square matrix and b is a column vector of the same height. The function will take A and b as inputs and give x as the output. Part 1: (Due March 21, 2018 by 8 am) Start by writing a function (with comments) to achieve these: Determine if the matrix A is square. Augment A and b. Find the haximum absolute value in the first column and the row number that this belongs to. Interchange the first row with the row with the maximum first-column-entry. (To achieve this, create a sub- function that interchanges two specified rows for any matrix.) Submit a single m-file with a subfunction that switches rows.

Explanation / Answer

Please find the program for the same.

Here I am getting assigning the values of a by myself, you can get it from the user .

Please find the code below

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

a=[2 1 -1 2 5
4 5 -3 6 9
4 2 -2 9 8
4 11 -4 8 2];

%Gauss elimination method [m,n)=size(a);
[m,n]=size(a); % to get the size of a, i.e, getting the coordinates
for j=1:m-1 % the outer loop to iterate over the rows in a
for z=j+1:m % the inner loop to iterate over the columns in a
if a(j,j)==0
t=a(j,:);a(j,:)=a(z,:); % getting the data in temp variable
a(z,:)=t; % copying back to a
end
end
for i=j+1:m
a(i,:)=a(i,:)-a(j,:)*(a(i,j)/a(j,j));
end
end
x=zeros(1,m);
for s=m:-1:1
c=0;
for k=2:m
c=c+a(s,k)*x(k);
end
x(s)=(a(s,n)-c)/a(s,s); % stroing the result in output variable
end
disp('Gauss elimination method:');
a % prtinting a
x' % printing output

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Sample output

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Happy Coding

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote