numeric
::rank
Numerical estimate of the rank of a matrix
MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.
MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.
numeric::rank(A
, <eps
>, options
)
numeric::rank(A)
returns an integer indicating
the rank of the matrix A.
All entries of the input matrix must be numerical, i.e., they must be floatingpoint numbers or expressions that can be converted to floatingpoint numbers.
The rank of a matrix coincides with the number of nonzero singular values.
A numerical estimate of the rank is computed by counting all singular values that are larger than eps s_{m}ax, where s_{m}ax is the largest singular value. (All smaller singular values are regarded as roundoff artifacts and treated as zero.)
The function is sensitive to the environment variable DIGITS
,
which determines the numerical working precision.
We consider a quadratic matrix of rank 2:
A := matrix([[1, 1, I], [1, 2, 3], [2, 4, 6]]): numeric::rank(A)
Hilbert matrices have full rank. However, they are extremely
illconditioned and it is difficult to compute their rank numerically.
The 10×10 Hilbert
matrix has rank 10. Numerically, however, some of the singular values
are so small that they may be regarded as zero resulting in a smaller
numerical rank. In particular, with the default value eps
= ,
two singular values are smaller than eps s_{m}ax where s_{m}ax
= is
the maximal singular value:
A := linalg::hilbert(10): numeric::singularvalues(A)
numeric::rank(A)
We specify a second argument eps = 10^{
14}
to allow smaller singular values to be
regarded as nonzero. Now, the numerical rank is 10:
numeric::rank(A, 10^(14))
delete A:
We consider a nonsquare matrix of rank 1:
A := matrix([[0, 0], [I, 1], [I, 1]]): numeric::rank(A)
delete A:
We demonstrate the difference between hardware floats and software floats:
A := linalg::hilbert(15): numeric::rank(A, 10^(20), SoftwareFloats), numeric::rank(A, 10^(20), HardwareFloats)
delete A:

An m×n matrix
of domain type 

Relative tolerance: regard all singular values 

With With Compared to the If no If the result cannot be computed with hardware floats, software arithmetic by the MuPAD kernel is tried. If the current value of There may be several reasons for hardware arithmetic to fail:
If neither If Note that NoteFor illconditioned matrices, the results returned with 
Positive integer.