rref_test, a MATLAB code which calls rref(), which evaluates the reduced row echelon form (RREF) of a matrix, which can be singular or rectangular.

While the RREF is often used in introductory linear algebra courses, it is very susceptible to roundoff error, and hence the results of many of the tasks which it is used to illustrate can only be relied on when the matrix is small, contains only integer entries, and care is taken to avoid any division operation that is not exact.

The RREF can be regarded as a form of Gauss-Jordan elimination, applied to a general MxN matrix.

A matrix is in reduced row echelon form if:

MATLAB includes a build in function

        R = rref ( A );
which returns in R the RREF of matrix A. It also uses a tolerance to try to mitigate the susceptibility of the algorithm to roundoff.

The RREF can be used to determine:


The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.


rref_test is available in a MATLAB version.

Related Data and Programs:

llsq, a MATLAB code which solves the simple linear least squares (LLS) problem of finding the formula of a straight line y=a*x+b which minimizes the root-mean-square (RMS) error to a set of N data points.

polyominoes, a MATLAB code which defines, solves, and plots a variety of polyomino tiling problems, which are solved by a direct algebraic approach involving the reduced row echelon form (RREF) of a specific matrix, instead of the more typical brute-force or backtracking methods.

qr_solve, a MATLAB code which computes the linear least squares (LLS) solution of a rectangular linear system A*x=b.

row_echelon_integer, a MATLAB code which carries out the exact computation of the integer row echelon form (IREF) and integer reduced row echelon form (IRREF) of an integer matrix.

test_lls, a MATLAB code which implements linear least squares (LLS) test problems which seek a vector x which minimizes the error in the rectangular linear system A*x=b.


  1. Charles Cullen,
    An Introduction to Numerical Linear Algebra,
    PWS Publishing Company, 1994,
    ISBN: 978-0534936903,
    LC: QA185.D37.C85.

Source Code:

Last revised on 07 December 2018.