MatrixRank
✖
MatrixRank

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 and structured arrays.
Examples
open allclose allBasic Examples (3)Summary of the most common use cases
Find the number of linearly independent rows of a numerical matrix:

https://wolfram.com/xid/0cg3r9da2-3io3t

Find the number of linearly independent rows of a symbolic matrix:

https://wolfram.com/xid/0cg3r9da2-tjk2jw

Compute the rank of a rectangular matrix:

https://wolfram.com/xid/0cg3r9da2-3foezn

Scope (12)Survey of the scope of standard use cases
Basic Uses (7)
Find the rank of a machine-precision matrix:

https://wolfram.com/xid/0cg3r9da2-gzis3e


https://wolfram.com/xid/0cg3r9da2-bjja1q

Rank of an exact, rectangular matrix:

https://wolfram.com/xid/0cg3r9da2-zo4y0v


https://wolfram.com/xid/0cg3r9da2-piv3b5

Find the rank of an arbitrary-precision matrix with more rows than columns:

https://wolfram.com/xid/0cg3r9da2-yo7vbd


https://wolfram.com/xid/0cg3r9da2-p8sjhl

Compute the rank of a symbolic matrix:

https://wolfram.com/xid/0cg3r9da2-fxlyis

MatrixRank assumes all symbols to be independent:

https://wolfram.com/xid/0cg3r9da2-gtn59g

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

https://wolfram.com/xid/0cg3r9da2-dkq7nk

https://wolfram.com/xid/0cg3r9da2-lx8juz

Compute the rank of a matrix with finite field elements:

https://wolfram.com/xid/0cg3r9da2-nw2qll

Special Matrices (5)

https://wolfram.com/xid/0cg3r9da2-ocj3kf


https://wolfram.com/xid/0cg3r9da2-fm3xwv

The rank of structured matrices:

https://wolfram.com/xid/0cg3r9da2-ebpduc


https://wolfram.com/xid/0cg3r9da2-dhkxvx


https://wolfram.com/xid/0cg3r9da2-wdjmwi


https://wolfram.com/xid/0cg3r9da2-j45yx1

IdentityMatrix always has full rank:

https://wolfram.com/xid/0cg3r9da2-8vb729


https://wolfram.com/xid/0cg3r9da2-pflv9c

HilbertMatrix always has full rank:

https://wolfram.com/xid/0cg3r9da2-q1l839

Compute the rank of a matrix of univariate polynomials of degree
:

https://wolfram.com/xid/0cg3r9da2-cupbp5

https://wolfram.com/xid/0cg3r9da2-j0guy7

Options (2)Common values & functionality for each option
Modulus (1)
The rank of a matrix depends on the modulus used:

https://wolfram.com/xid/0cg3r9da2-eozjbj
With ordinary arithmetic, m has the full rank of 3:

https://wolfram.com/xid/0cg3r9da2-b00497

With arithmetic modulo 5, the rank is only 2:

https://wolfram.com/xid/0cg3r9da2-db5dy3

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

https://wolfram.com/xid/0cg3r9da2-b22du7
In exact arithmetic, m has full rank:

https://wolfram.com/xid/0cg3r9da2-cs7883

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

https://wolfram.com/xid/0cg3r9da2-d2wixt

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

https://wolfram.com/xid/0cg3r9da2-nxde1

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

https://wolfram.com/xid/0cg3r9da2-nkdcs6

Applications (11)Sample problems that can be solved with this function
Spans and Linear Independence (5)
The following three vectors are not linearly independent:

https://wolfram.com/xid/0cg3r9da2-gocnsl

Therefore the matrix rank of the matrix whose rows are the vectors is 2:

https://wolfram.com/xid/0cg3r9da2-l8nbp1

The following three vectors are linearly independent:

https://wolfram.com/xid/0cg3r9da2-keoxxm

Therefore the matrix rank of the matrix whose rows are the vectors is 3:

https://wolfram.com/xid/0cg3r9da2-8mo3ba

Determine if the following vectors are linearly independent or not:

https://wolfram.com/xid/0cg3r9da2-qnovlz
The rank of the matrix formed from the vectors is less than four, so they are not linearly independent:

https://wolfram.com/xid/0cg3r9da2-sotoh0

Find the dimension of the column space of the following matrix:

https://wolfram.com/xid/0cg3r9da2-fq6172
The dimension of the space of all linear combinations of the columns equals the matrix rank:

https://wolfram.com/xid/0cg3r9da2-oi7hun

Find the dimension of the subspace spanned by the following vectors:

https://wolfram.com/xid/0cg3r9da2-shxd3q
Since the matrix rank of the matrix formed by the vectors is three, that is the dimension of the subspace:

https://wolfram.com/xid/0cg3r9da2-doh8f0

Equation Solving and Invertibility (6)
Determine if the following system of equations has a unique solution:

https://wolfram.com/xid/0cg3r9da2-upikkb
Rewrite the system in matrix form:

https://wolfram.com/xid/0cg3r9da2-zs7ify

The coefficient matrix has full rank, so the system has a unique solution:

https://wolfram.com/xid/0cg3r9da2-6x59zk

Verify the result using Solve:

https://wolfram.com/xid/0cg3r9da2-tqujfz

Determine if the following matrix has an inverse:

https://wolfram.com/xid/0cg3r9da2-soeczx
The rank is less than the dimension of the matrix, so it is not invertible:

https://wolfram.com/xid/0cg3r9da2-1itznp

Verify the result using Inverse:

https://wolfram.com/xid/0cg3r9da2-sfsjp9


Determine if the following matrix has a nonzero determinant:

https://wolfram.com/xid/0cg3r9da2-1q7xab
Since it has full rank, its determinant must be nonzero:

https://wolfram.com/xid/0cg3r9da2-0wktjf

Confirm the result using Det:

https://wolfram.com/xid/0cg3r9da2-xxnsh

is an eigenvalue of
if
does not have full rank. Moreover, a matrix is deficient if it has an eigenvalue whose multiplicity is greater than the difference between the rank of
and the number of columns. Show that
is an eigenvalue for the following matrix
:

https://wolfram.com/xid/0cg3r9da2-5fmzho

https://wolfram.com/xid/0cg3r9da2-qf2h5t

Confirm the result using Eigenvalues:

https://wolfram.com/xid/0cg3r9da2-x53b0b

The matrix is deficient because 2 appears twice, but the difference in rank is only one:

https://wolfram.com/xid/0cg3r9da2-dxfyw9

Confirm the result with Eigensystem, which indicates deficiency by padding the eigenvector list with zeros:

https://wolfram.com/xid/0cg3r9da2-qbcxdp

Most but not all random 10×10 0–1 matrices have full rank:

https://wolfram.com/xid/0cg3r9da2-by0vsd

Estimate the average rank of a random 10×10 0–1 matrix:

https://wolfram.com/xid/0cg3r9da2-hlp98e

Find the ranks of coprimality arrays:

https://wolfram.com/xid/0cg3r9da2-t8utl

https://wolfram.com/xid/0cg3r9da2-jac2l


https://wolfram.com/xid/0cg3r9da2-joxgvx

Compute the first 50 such arrays. Only the first three have full rank:

https://wolfram.com/xid/0cg3r9da2-gawh6p

Visualize the growth in rank versus the dimension of the matrix:

https://wolfram.com/xid/0cg3r9da2-fj1rnx

Properties & Relations (9)Properties of the function, and connections to other functions
By the rank-nullity theorem, MatrixRank[m] is the number of columns minus the dimension of the null space:

https://wolfram.com/xid/0cg3r9da2-gxkm9m

https://wolfram.com/xid/0cg3r9da2-f42s8h

https://wolfram.com/xid/0cg3r9da2-c0wcxx


https://wolfram.com/xid/0cg3r9da2-dzhaqc

The column and row rank of a matrix are equal:

https://wolfram.com/xid/0cg3r9da2-bh2j57

https://wolfram.com/xid/0cg3r9da2-d8v2ib

MatrixRank[m] equals the number of nonzero rows in RowReduce[m]:

https://wolfram.com/xid/0cg3r9da2-r3i6g7

https://wolfram.com/xid/0cg3r9da2-tqbxyq


https://wolfram.com/xid/0cg3r9da2-ji740x

For a square matrix, m has full rank if and only if Det[m]!=0:

https://wolfram.com/xid/0cg3r9da2-wdl5f0

https://wolfram.com/xid/0cg3r9da2-m3c6cz


https://wolfram.com/xid/0cg3r9da2-jdbcx4

For a square matrix, m has full rank if and only if the null space is empty:

https://wolfram.com/xid/0cg3r9da2-3raccb

https://wolfram.com/xid/0cg3r9da2-5pyzjz


https://wolfram.com/xid/0cg3r9da2-fy748r

For a square matrix, m has full rank if and only if m has an inverse:

https://wolfram.com/xid/0cg3r9da2-xhqrgz

https://wolfram.com/xid/0cg3r9da2-5gvptr


https://wolfram.com/xid/0cg3r9da2-4o8e3f


For a square matrix, m has full rank iff LinearSolve[m,b] has a solution for a generic b:

https://wolfram.com/xid/0cg3r9da2-sduw6z

https://wolfram.com/xid/0cg3r9da2-oclh3t


https://wolfram.com/xid/0cg3r9da2-7noouu

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

https://wolfram.com/xid/0cg3r9da2-cm9elg

https://wolfram.com/xid/0cg3r9da2-h0mjv9


https://wolfram.com/xid/0cg3r9da2-bzanbk

The outer product of vectors has matrix rank 1:

https://wolfram.com/xid/0cg3r9da2-b0jbqq

https://wolfram.com/xid/0cg3r9da2-dzw1jd

Possible Issues (2)Common pitfalls and unexpected behavior
MatrixRank may depend on the precision of the given matrix:

https://wolfram.com/xid/0cg3r9da2-d63v26
Use exact arithmetic to compute the matrix rank exactly:

https://wolfram.com/xid/0cg3r9da2-x9m0c

Use machine arithmetic. Machine numbers cannot distinguish between and
:

https://wolfram.com/xid/0cg3r9da2-epi0zb

Use 24‐digit-precision arithmetic:

https://wolfram.com/xid/0cg3r9da2-cnd3yv

MatrixRank assumes all symbols to be independent:

https://wolfram.com/xid/0cg3r9da2-hdj0vs

The special case gives a different result:

https://wolfram.com/xid/0cg3r9da2-nqgyjw

Wolfram Research (2003), MatrixRank, Wolfram Language function, https://reference.wolfram.com/language/ref/MatrixRank.html (updated 2024).
Text
Wolfram Research (2003), MatrixRank, Wolfram Language function, https://reference.wolfram.com/language/ref/MatrixRank.html (updated 2024).
Wolfram Research (2003), MatrixRank, Wolfram Language function, https://reference.wolfram.com/language/ref/MatrixRank.html (updated 2024).
CMS
Wolfram Language. 2003. "MatrixRank." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/MatrixRank.html.
Wolfram Language. 2003. "MatrixRank." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/MatrixRank.html.
APA
Wolfram Language. (2003). MatrixRank. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MatrixRank.html
Wolfram Language. (2003). MatrixRank. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MatrixRank.html
BibTeX
@misc{reference.wolfram_2025_matrixrank, author="Wolfram Research", title="{MatrixRank}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/MatrixRank.html}", note=[Accessed: 26-March-2025
]}
BibLaTeX
@online{reference.wolfram_2025_matrixrank, organization={Wolfram Research}, title={MatrixRank}, year={2024}, url={https://reference.wolfram.com/language/ref/MatrixRank.html}, note=[Accessed: 26-March-2025
]}