TASK 4.1: Implement a function that reduces any matrix to reduced row echelon form, and apply it to reduce the following
matrix A to reduced row echelon form. You must implement the gaussian elimination algorithm yourself, not merely call
someone elses library function.
HINT: https://en.wikipedia.org/wiki/Gaussian_elimination
[17]: A = np.array([[1, 0, 1, 1],
[1, 0, 1, 1],
[0, 1, 1, 1],
[1, 1, 1, 0],
[1, 1, 1, 0]])
def gaussian_elim(A):
#YOUR CODE HERE
return A
print(gaussian_elim(A))
[[1 0 1 1]
[1 0 1 1]
[0 1 1 1]
[1 1 1 0]
[1 1 1 0]]
Use the code below to verify your result.
[12]: import sympy as sp
disp_A = np.array(sp.Matrix(A).rref()[0])
print(disp_A)
[[1 0 0 -1]
[0 1 0 -1]
[0 0 1 2]
[0 0 0 0]
[0 0 0 0]]