Question
Please I need help with the following: Write a MATLAB function, called gewop, that solves the linear system Ax=b (withAMn(R),bRn) via Gaussian elimination without pivoting.
Please I need help with the following:
Write a MATLAB function, called gewop, that solves the linear system Ax=b (withAMn(R),bRn) via Gaussian elimination without pivoting. Your code should compute the LU decomposition of A, where the matrices L and U are stored over A. Furthermore, your code should solve the system by solving the lower-triangular system Ly=b (via row-oriented forward substitution) and then solving the upper-triangular system Ux=y (via row-oriented back substitution).
I have the codes for the upper and lower triangular systems.
Lower triangular matrix:
% MATLAB Code for LT matrix G of size n: b=randn(n,1);
for i=1:n
for j=1:i-1
b(i)=b(i)-G(i,j)*b(j);
end
if G(i,i)==0
error(Matrix is singular)
end
b(i)=b(i)/G(i,i);
end
Upper triangular matrix:
for k=1:n
i=n-k+1;
for j=i+1:n
y(i)=y(i)-U(i,j)*y(j);
end
if U(i,i)==0
disp(Matrix is singular)
break
end
y(i)=y(i)/U(i,i);
end
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started