# MatrixRank MatrixRank[m]

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 .
• 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 all

## Basic Examples(3)

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

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

Compute the rank of a rectangular matrix:

## Scope(11)

### Basic Uses(6)

Find the rank of a machine-precision matrix:

Rank of a complex matrix:

Rank of an exact, rectangular matrix:

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

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(5)

The rank of a sparse matrix:

The rank of structured matrices:

IdentityMatrix always has full rank:

HilbertMatrix always has full rank:

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

## 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(11)

### Spans and Linear Independence(5)

The following three vectors are not linearly independent:

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

The following three vectors are linearly independent:

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

Determine if the following vectors are linearly independent or not:

The rank of the matrix formed from the vectors is less than four, so they are not linearly independent:

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

The dimension of the space of all linear combinations of the columns equals the matrix rank:

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

Since the matrix rank of the matrix formed by the vectors is three, that is the dimension of the subspace:

### Equation Solving and Invertibility(6)

Determine if the following system of equations has a unique solution:

Rewrite the system in matrix form:

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

Verify the result using Solve:

Determine if the following matrix has an inverse:

The rank is less than the dimension of the matrix, so it is not invertible:

Verify the result using Inverse: Determine if the following matrix has a nonzero determinant:

Since it has full rank, its determinant must be nonzero:

Confirm the result using Det: 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 :

Confirm the result using Eigenvalues:

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

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

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:

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

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

## Properties & Relations(9)

By the rank-nullity theorem, MatrixRank[m] is the number of columns minus the dimension of the null space:

The column and row rank of a matrix are equal:

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

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

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

For a square matrix, m has full rank if and only if m has an inverse: For a square matrix, m has full rank iff LinearSolve[m,b] has a solution for a generic b:

MatrixRank[m] is equal to :

The outer product of vectors has matrix rank 1:

## Possible Issues(2)

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:

MatrixRank assumes all symbols to be independent:

The special case gives a different result: