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

Question I need answered: Exploration 3.2.11 Modify your function gausselim from

ID: 2259064 • Letter: Q

Question

Question I need answered:

Exploration 3.2.11 Modify your function gausselim from Exploration 3.1.7 so that it is called as follows: LU=gausselim(A). That is, it no longer takes a vector b as an input argument, nor does it return it as an output argument. The entries of the output argument LU are set as follows: for i > j, the (i,j) entry is equal to the multiplier mij from Algorithm 3.1.6, and for i j, the (i,j) entry is equal to uij, where U is the upper triangular matrix that is the nal result of Gaussian Elimination.

Extra material to help ansswer the question above:

Exploration 3.1.7 Write a Matlab function
[A,b]=gausselim(A,b)
that implements Algorithm 3.1.6

Algorithm 3.1.6 (Gaussian Elimination) Given an n×n matrix A and n-vector b, the following algorithm reduces the system of linear equations Ax = b to an equivalent upper triangular system. A and b are overwritten with the coecients and right-hand side, respectively, of the reduced system.
for j = 1,2,...,n1 do

for i = j + 1,j + 2,...,n do

mij = aij/ajj for k = j + 1,j + 2,...,n do

aik = aik mijajk

end

for bi = bi mijbj

end for

end for

Explanation / Answer

Matlab code

function [L,U]=gausselim(A)
A=[1 5 6;9 5 8;0 8 7];%taking a sample matrix
[m n]=size(A);
if (m ~= n )
disp ( 'LR2 error: Matrix must be square' );
return;
end
% Part 2 : Decomposition of matrix into L and U
L=zeros(m,m);
U=zeros(m,m);
for i=1:m
% Finding L
for k=1:i-1
L(i,k)=A(i,k);
for j=1:k-1
L(i,k)= L(i,k)-L(i,j)*U(j,k);
end
L(i,k) = L(i,k)/U(k,k);
end
% Finding U
for k=i:m
U(i,k) = A(i,k);
for j=1:i-1
U(i,k)= U(i,k)-L(i,j)*U(j,k);
end
end
end
for i=1:m
L(i,i)=1;
end
% Program shows U and L
U
end

output

U =

1.000000000000000 5.000000000000000 6.000000000000000
0 -40.000000000000000 -46.000000000000000
0 0 -2.200000000000001


L =

1.000000000000000 0 0
9.000000000000000 1.000000000000000 0
0 -0.200000000000000 1.000000000000000

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