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.
linalg::rank(A
) linalg::rank(S
)
linalg::rank(A)
computes the rank of the
matrix A.
linalg::rank(S)
computes the rank of the
matrix whose columns are the vectors in S.
The row rank of a matrix is the maximal number of linearly independent row vectors of that matrix. The column rank of a matrix is the maximal number of linearly independent column vectors of that matrix. For each matrix, its row rank is equal to its column rank. This number is called the rank of a matrix.
The component ring of A
or of the vectors
given in S
must be an integral domain (a domain
of category Cat::IntegralDomain
).
linalg::rank
replaces symbolic elements of
a matrix by random integer numbers between 1 and 10^{10}.
Then the function computes the rank of the resulting numeric matrix
by Gaussian elimination (see linalg::gaussElim
).
This approach introduces a tiny chance of getting a wrong result.
Note:

Define the following matrix A
over ℤ:
MatZ := Dom::Matrix(Dom::Integer): A := MatZ([[1, 2, 3, 4], [1, 0, 1, 0], [3, 5, 6, 9]])
Compute the rank of the matrix A
:
linalg::rank(A)
Use the three vectors
to
define the columns of the matrix A
. Compute the
rank of A
:
MatZ := Dom::Matrix(Dom::Integer): S:= { MatZ([0,1,1]), MatZ([0,1,0]), MatZ([0,0,1]) }: linalg::rank(S)
The linalg::rank
function does not use any
simplification rules for special functions, algebraic numbers (radicals),
and so on. If linalg::rank
computes intermediate
expressions that can be simplified to zero, the function can return
incorrect results. For example, create the following matrices:
A := matrix([[exp(x + y), exp(x)], [exp(y), 1]]); B := matrix([[sin(x)^2 + cos(x)^2, 1], [1, 1]]); C := matrix([[sqrt(6), sqrt(2)], [sqrt(3), 1]])
There is only one independent row in each of these matrices.
The rank of the matrices A
, B
,
and C
is 1. The linalg::rank
function
returns 2 because it does not simplify the expressions
, sin^{2} + cos^{2} 
1, and
:
linalg::rank(A), linalg::rank(B), linalg::rank(C)

A matrix of a domain of category 

A list or set of column vectors of the same dimension (a column
vector is an n×1 matrix
of a domain of category 
Nonnegative integer