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

please write a code on Matlab and solve this matrix using partial pivoting as de

ID: 3120850 • Letter: P

Question


please write a code on Matlab and solve this matrix using partial pivoting as described make sure pp value is 2 4 and roots are 1 1 1 1
thanks

use the Gaussian elimination method with partial pivoting to solve the system of linear equations Alxlslel, where: 2 -1 0 0 lif you can't see the above matrices, please refer to the pdf version of the A05 assignment in SurreyLearn) Besides the final solution [2 marks], please save a list of all the swaps made when applying partial pivoting to a matrix called "pp" 12 marks]: as an example pletely hypothetical), let's assume that during the process we execute 3 row swaps because (cam of partial pivoting; the first one between row 1 and 3, the second one between row 2 and 4, the third one between row 3 and 4; the pp matrix will have the following values:

Explanation / Answer

function x = GaussPivot(A,b)
% GaussPivot: Gauss elimination pivoting
% x = GaussPivot(A,b): Gauss elimination with pivoting.
% input:
% A = coefficient matrix
% b = right hand side vector
% output:
% x = solution vector
[m,n]=size(A);
if m~=n, error('Matrix A must be square'); end
nb=n+1;
Aug=[A b];
% forward elimination
for k = 1:n-1
% partial pivoting
[big,i]=max(abs(Aug(k:n,k)));
ipr=i+k-1;
if ipr~=k
Aug([k,ipr],:)=Aug([ipr,k],:);
end
for i = k+1:n
factor=Aug(i,k)/Aug(k,k);
Aug(i,k:nb)=Aug(i,k:nb)-factor*Aug(k,k:nb);
end
end
% back substitution
x=zeros(n,1);
x(n)=Aug(n,nb)/Aug(n,n);
for i = n-1:-1:1
x(i)=(Aug(i,nb)-Aug(i,i+1:n)*x(i+1:n))/Aug(i,i);
end