Write a function called that takes in one argument, a matrix, performs gaussian elimination
utilizing a partial pivoting strategy and elementary row operations only. Your function must not
perform any permutations of the columns of the input matrix. Your function must return the the
row echelon form of the input matrix. Before returning, your function must print the determinant
of the input matrix. You may not use any of the following built in functions: det, lu, rref, qr, inv,
rank, svd, sprank.
This question should be done in MATLAB code, however it\'s fine if you do this in JAVA, C, or
C++
Solution
Coding Hints
Your gaussian-elimination function should use secondary functions called by your main function
as a structuring mechanism. A good place to start is to note that after the initial parameter
checking, the process consists of two main steps. First, reduce the coefficient matrix to upper
triangular form (modifying the constant vector in parallel). Second, perform the back-
substitution to obtain the solution vector from the upper triangular matrix and the (modified)
constant vector. We can write a secondary function to perform each step. Our main function thus
starts out looking like this:
function solution_vec = gauss_reduce(param_mat, const_vec)
% check for consistent size of param_mat and const_vec
...
% reduce coefficient matrix to upper triangular form, modifying the
% constant vector appropriatly
[ut_mat, new_const_vec] = ut_reduce(param_mat, const_vec);
% Compute the solution vector using back substitution
solution_vec = back_subst(ut_mat, new_const_vec);
% we are done
end
The ut_reduce() function uses its own subsidiary functions. Specifically, you should write a
function called reduce_column() with prototype
function [new_mat, new_const_vec] =
reduce_column(param_mat, const_vec, column)
that returns a modified matrix (and constant vector) in which the input matrix has been reduced