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

please solve above matrix using partial pivoting on Matlab and display pp use th

ID: 3847871 • Letter: P

Question


please solve above matrix using partial pivoting on Matlab and display pp

use the Gaussian elimination method with partial pivoting to solve the system of near equations IAJIxl lBl, where 0 0 -1 1 lif you can't see the above matrices, please referto the pdf n of the Aos assignment in SurreyLearnu Besides the final solution 12 marksl please save a list of all the swaps made when applying partial pivoting to a matrix calied pp" marks as an example (completely hypothetical, let's assume that during the process we execute 3 now swaps because 12 one between row 2 and 4, the third one between row 3 and 4. of partial pivoting the first one between rowland 3, the second the pp matrix win have the followin you can't vee the above matrix, please refer to the pdr version of the ADs assignmentin surreyLearnl.

Explanation / Answer

% matlab code

function x = ppGaussian(matrixA,columnVector)

n = size(matrixA,1);
%determine augmented matrix
matrixA = [matrixA,columnVector];   

idx = 1;
pp = zeros(n,2);
for i = 1:n-1
p = i;
%comparison to select the pivot
for j = i+1:n
if abs(matrixA(j,i)) > abs(matrixA(i,i))
U = matrixA(i,:);
matrixA(i,:) = matrixA(j,:);
matrixA(j,:) = U;
pp(idx,1) = i;
pp(idx,2) = j;
idx = idx + 1;
end
end
while matrixA(p,i)== 0 & p <= n
p = p+1;
end
if p == n+1
disp('No unique solution');
break
else
if p ~= i
T = matrixA(i,:);
matrixA(i,:) = matrixA(p,:);
matrixA(p,:) = T;
end
end
  
for j = i+1:n
m = matrixA(j,i)/matrixA(i,i);
for k = i+1:n+1
matrixA(j,k) = matrixA(j,k) - m*matrixA(i,k);
end
end
end

if matrixA(n,n) == 0
disp('No unique solution');
return
end

x(n) = matrixA(n,n+1)/matrixA(n,n);
for i = n - 1:-1:1
sumax = 0;
for j = i+1:n
sumax = sumax + matrixA(i,j)*x(j);
end
x(i) = (matrixA(i,n+1) - sumax)/matrixA(i,i);
end

disp('pp: ');
disp(pp);

end

ppGaussian([2 -1 0 0; 0 0 -1 1; 0 -1 2 -1; -1 2 -1 0],[1;0;0;0])

%{
output:

pp:
2 3
2 4
3 4

ans =
1.00000 1.00000 1.00000 1.00000

%}