[TOC]

rref

Reduced row echelon form

Usages

rref(A)

max(size(A))*eps(norm(A, inf))

rref(A, tol)

[R, b] = rref(A)

max(size(A))*eps(norm(A, inf))

[R, b] = rref(A, tol)

Examples

Input
A = [16.00 2.000 3.000 13.00
5.000 11.00 10.00 8.000
9.000 7.000 6.000 12.00
4.000 14.00 15.00 1.000]

% U is the row echelon form.
[L,U] = lu(A);
U, U(4,4)

% U(4,4) ~1e-15 is very small, which
% is considered zero when the
% default tolerance is used.
% This results in rank 3.
R = rref(A)

% However, when a smaller tolerance
% is used, it is considered non-zero.
% This results in rank 4.
R = rref(A,1e-17)
Output
A =
16.00   2.000   3.000   13.00
5.000   11.00   10.00   8.000
9.000   7.000   6.000   12.00
4.000   14.00   15.00   1.000

U =
16.00   2.000   3.000   13.00
0.000   13.50   14.25  -2.250
0.000   0.000  -1.889   5.667
0.000   0.000   0.000   0.000

ans = 1e-15 ×
3.553

R =
1.000   0.000   0.000   1.000
0.000   1.000   0.000   3.000
0.000   0.000   1.000  -3.000
0.000   0.000   0.000   0.000

R =
1.000   0.000   0.000   0.000
0.000   1.000   0.000   0.000
0.000   0.000   1.000   0.000
0.000   0.000   0.000   1.000
Input
A = [1 -5 2 -2;
-1 4 0 3;
1 -1 2 2]
[R,b] = rref(A)
Output
A =
 1.000  -5.000   2.000  -2.000
-1.000   4.000   0.000   3.000
 1.000  -1.000   2.000   2.000

R =
 1.000   0.000   0.000   1.000
 0.000   1.000   0.000   1.000
 0.000   0.000   1.000   1.000

b =
 1.000   2.000   3.000