gives the rank of the matrix m.

Details and Options

  • MatrixRank works on both numerical and symbolic matrices.
  • The rank of a matrix is the number of linearly independent rows or columns.
  • MatrixRank[m,Modulus->n] finds the rank for integer matrices modulo n.
  • MatrixRank[m,ZeroTest->test] evaluates test[m[[i,j]]] to determine whether matrix elements are zero. The default setting is ZeroTest->Automatic.
  • MatrixRank[m,Tolerance->t] gives the minimum rank with each element in a numerical matrix assumed to be correct only to within tolerance t.
  • MatrixRank works with sparse arrays.


open allclose all

Basic Examples  (1)

Find the number of linearly independent rows:

Scope  (10)

Basic Uses  (6)

Find the rank of a machine-precision matrix:

Rank of a complex matrix:

Rank of an exact matrix:

Find the rank of an arbitrary-precision matrix:

Compute the rank of a symbolic matrix:

MatrixRank assumes all symbols to be independent:

Computing the rank of large machine-precision matrices is efficient:

Special Matrices  (4)

The rank of a sparse matrix:

The rank of structured matrices:

IdentityMatrix always has full rank:

HilbertMatrix always has full rank:

Options  (2)

Modulus  (1)

The rank of a matrix depends on the modulus used:

With ordinary arithmetic, m has the full rank of 3:

With arithmetic modulo 5, the rank is only 2:

Tolerance  (1)

The setting of Tolerance can affect the estimated rank for numerical ill-conditioned matrices:

In exact arithmetic, m has full rank:

With machine arithmetic, the default is to consider elements that are too small as zero:

With zero tolerance, even small terms may be taken into account:

With a tolerance greater than the pivot in the middle row, the last two rows are considered zero:

Applications  (2)

Most but not all random 10×10 01 matrices have full rank:

Estimate the average rank of a random 10×10 01 matrix:

Find the ranks of coprimality arrays:

Properties & Relations  (4)

MatrixRank[m] is equal to Length[SingularValueList[m]]:

MatrixRank[m] plus the dimension of the null space is equal to the number of columns of m:

The column and row rank of a matrix are equal:

The outer product of vectors has matrix rank 1:

Possible Issues  (1)

MatrixRank may depend on the precision of the given matrix:

Use exact arithmetic to compute the matrix rank exactly:

Use machine arithmetic. Machine numbers cannot distinguish between and :

Use 24digit-precision arithmetic:

Wolfram Research (2003), MatrixRank, Wolfram Language function, (updated 2007).


Wolfram Research (2003), MatrixRank, Wolfram Language function, (updated 2007).


@misc{reference.wolfram_2021_matrixrank, author="Wolfram Research", title="{MatrixRank}", year="2007", howpublished="\url{}", note=[Accessed: 18-October-2021 ]}


@online{reference.wolfram_2021_matrixrank, organization={Wolfram Research}, title={MatrixRank}, year={2007}, url={}, note=[Accessed: 18-October-2021 ]}


Wolfram Language. 2003. "MatrixRank." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2007.


Wolfram Language. (2003). MatrixRank. Wolfram Language & System Documentation Center. Retrieved from