29-Jul-2021 01:44:30 rref_test(): MATLAB/Octave version 9.9.0.1467703 (R2020b) rref() computes the reduced row echelon form (RREF) of a matrix. The RREF is susceptible to roundoff error. With that in mind, it can be used to determine: * the rank of a square matrix; * the column rank of a rectangular matrix; * the independent columns of a rectangular matrix * if a linear system is consistent; * the inverse of a square invertible matrix. Test 1, just get the RREF. Matrix A: Col: 1 2 3 4 5 Row 1 : 1 3 0 2 6 2 : -2 -6 0 -2 -8 3 : 3 9 0 0 6 4 : -1 -3 0 1 0 Col: 6 7 Row 1 : 3 1 2 : 3 1 3 : 6 2 4 : 9 3 A has rank 3 RREF of A: Col: 1 2 3 4 5 Row 1 : 1 3 0 0 2 2 : 0 0 0 1 2 3 : 0 0 0 0 0 4 : 0 0 0 0 0 Col: 6 7 Row 1 : 0 0 2 : 0 0 3 : 1 0.333333 4 : 0 0 Test 2, look for inconsistency. Matrix A: Col: 1 2 3 4 Row 1 : 1 -2 3 -1 2 : 3 -6 9 -3 3 : 0 0 0 0 4 : 2 -2 0 1 5 : 6 -8 6 0 6 : 3 3 6 9 7 : 1 1 2 3 A has rank 3 RHS b1: 1: 1 2: 2 3: 3 4: 4 5: 5 6: 5 7: 7 [A;b1] has rank 4 Linear system A*x=b1 is INCONSISTENT. RHS b2: 1: 4 2: 12 3: 0 4: 2 5: 12 6: 9 7: 3 [A;b2] has rank 3 Linear system A*x2=b2 is CONSISTENT. Solution of A*x2=b2: 1: 1 2: 0 3: 1 4: 0 Compare b2 and A*x2: 1: 4 4 2: 12 12 3: 0 0 4: 2 2 5: 12 12 6: 9 9 7: 3 3 Test 3, inverse. Matrix A: Col: 1 2 3 4 Row 1 : 5 7 6 5 2 : 7 10 8 7 3 : 6 8 10 9 4 : 5 7 9 10 Estimated A_inv: Col: 1 2 3 4 Row 1 : 68 -41 -17 10 2 : -41 25 10 -6 3 : -17 10 5 -3 4 : 10 -6 -3 2 A_inv * A: Col: 1 2 3 4 Row 1 : 1 0 0 0 2 : 0 1 0 0 3 : 0 0 1 0 4 : 0 0 0 1 Test 4, independent columns. Matrix A: Col: 1 2 3 4 Row 1 : 1 1 2 3 2 : 2 3 4 9 3 : 3 0 6 0 4 : 4 2 8 0 5 : 5 6 10 6 6 : 6 3 12 6 7 : 7 1 14 2 Number of independent columns is 3 Independent columns of A: Col: 1 2 3 Row 1 : 1 1 3 2 : 2 3 9 3 : 3 0 0 4 : 4 2 0 5 : 5 6 6 6 : 6 3 6 7 : 7 1 2 rref_test(): Normal end of execution. 29-Jul-2021 01:44:30