18-Jun-2023 06:55:27 rref_test(): MATLAB/Octave version 5.2.0 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: 1 3 0 2 6 3 1 -2 -6 0 -2 -8 3 1 3 9 0 0 6 6 2 -1 -3 0 1 0 9 3 A has rank 3 RREF of A: 1.00000 3.00000 0.00000 0.00000 2.00000 0.00000 0.00000 0.00000 0.00000 0.00000 1.00000 2.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 1.00000 0.33333 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 Test 2, look for inconsistency. Matrix A: 1 -2 3 -1 3 -6 9 -3 0 0 0 0 2 -2 0 1 6 -8 6 0 3 3 6 9 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: 5 7 6 5 7 10 8 7 6 8 10 9 5 7 9 10 Estimated inverse of A: 68.0000 -41.0000 -17.0000 10.0000 -41.0000 25.0000 10.0000 -6.0000 -17.0000 10.0000 5.0000 -3.0000 10.0000 -6.0000 -3.0000 2.0000 Product A_inv * A: 1.00000 0.00000 -0.00000 0.00000 0.00000 1.00000 0.00000 0.00000 -0.00000 -0.00000 1.00000 -0.00000 0.00000 0.00000 0.00000 1.00000 Test 4, independent columns. Matrix A: 1 1 2 3 2 3 4 9 3 0 6 0 4 2 8 0 5 6 10 6 6 3 12 6 7 1 14 2 Number of independent columns is 3 Independent columns of A: 1 1 3 2 3 9 3 0 0 4 2 0 5 6 6 6 3 6 7 1 2 rref_test(): Normal end of execution. 18-Jun-2023 06:55:27