$24
LU Factorization (with Partial Pivoting) Algo-rithm Development
Rules / Suggestions
The following rules apply to ALL of our Algorithm Development Problems. These are helpful when you are testing your function and we will grade you on them.
1. You must use the correct function name.
2. Check number of function inputs and outputs (vector and scalar inputs)
3. Clear variables in workspace prior to running tests
4. If variable names are not given, use appropriate and consistent names
5. Check function for all possible number of inputs (use nargin during devel-opment to catch errors)
6. Run algorithm for at least 2 different input values
7. Check algorithm does not produce extraneous output
8. Comment code for readability
LU Factorization Algorithm
Develop a MATLAB function that determines the LU Factorization of a square matrix. Your algorithm must use partial pivoting. You must name the function luFactor to recieve credit.
For full credit, you must include appropriate error checking. If you are confused about what would be appropriate or have questions, feel free to come to office hours!
Inputs:
• A - coefficient matrix Outputs:
• L - lower triangular matrix
• U - upper triangular matrix
• P - the pivot matrix
FOR TESTING PURPOSES ONLY
Perform LU Factorization on the following system of equations 10x1 + 2x2 − x3 = 27
1
−3x1 − 6x2 + 2x3 = −61.5
x1 + x2 + 5x3 = −21.5
Then, multiply the resulting [L] and [U] matrices to determine that [A] is produced.
2