15-May-2025 20:47:35 rref_test(): MATLAB/Octave version 6.4.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 solution of a nonsingular square linear system; * the inverse of a nonsingular square matrix. * the determinant of a square matrix. * the column rank of a rectangular matrix; * the independent columns of a rectangular matrix * if a linear system is consistent; 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.0000 3.0000 0 0 2.0000 0 0 0 0 0 1.0000 2.0000 0 0 0 0 0 0 0 1.0000 0.3333 0 0 0 0 0 0 0 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.0000e+00 7.4607e-14 -3.1974e-14 6.3949e-14 5.3291e-15 1.0000e+00 8.8818e-15 3.5527e-15 -1.7764e-15 -2.8422e-14 1.0000e+00 -3.5527e-15 4.6629e-15 1.7542e-14 5.5511e-15 1.0000e+00 Test 4, determinant. Matrix A: 5 7 6 5 7 10 8 7 6 8 10 9 5 7 9 10 Estimated determinant of A = 1: MATLAB det(A) = 1 Test 5, 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. 15-May-2025 20:47:35