Question: 1 0 . 6 Develop your own M - file to determine the ( L U ) factorization of a square matrix without

10.6 Develop your own M-file to determine the \( L U \) factorization of a square matrix without partial pivoting. That is, develop a function that is passed the square matrix and returns the triangular matrices [L] and [U]. Test your function by using it to solve the system in Prob. 10.3. Confirm that your function is working properly by verifying that \([L][U]=[A]\) and by using the built-in function lu.
Hint: most of the code is listed below.
```
function [L, U]= LUNaive (A)
% LUNaive(A):
% LU decomposition without pivoting.
% input:
% A = coefficient matrix
% output:
% L = lower triangular matrix
% U = upper triangular matrix
m,n]=size(A);
if m~=n, error('Matrix A must be square'); end
L = eye(n);
```
```
% forward elimination
for k =1:n-1
for i = k+1:n
L(i,k)}=\textrm{U}(i,k)/\textrm{U}(k,k)
U(i,k)=0;
```
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
end
end
1 0 . 6 Develop your own M - file to determine

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!