Find rank of symbolic matrix
Find Rank of Matrix
syms a b c d A = [a b; c d]; rank(A)
ans = 2
Rank of Symbolic Matrices Is Exact
Symbolic calculations return the exact rank of a matrix while numeric calculations can suffer from round-off errors. This exact calculation is useful for ill-conditioned matrices, such as the Hilbert matrix. The rank of a Hilbert matrix of order n is n.
Find the rank of the Hilbert matrix of order
Then convert the numeric matrix to a symbolic matrix using
find the rank symbolically.
H = hilb(15); rank(H) rank(sym(H))
ans = 12 ans = 15
The symbolic calculation returns the correct rank of
The numeric calculation returns an incorrect rank of
to round-off errors.
Rank Function Does Not Simplify Symbolic Calculations
Consider this matrix
After simplification of
the matrix has a rank of
an incorrect rank of
2 because it does not take
into account identities satisfied by special functions occurring in
the matrix elements. Demonstrate the incorrect result.
syms x A = [1-sin(x) cos(x); cos(x) 1+sin(x)]; rank(A)
ans = 2
rank returns an incorrect result because
the outputs of intermediate steps are not simplified. While there
is no fail-safe workaround, you can simplify symbolic expressions
by using numeric substitution and evaluating the substitution using
Find the correct rank by substituting
a number and evaluating the result using
ans = 1
However, even after numeric substitution,
return incorrect results due to round-off errors.
A — Input
number | vector | matrix | symbolic number | symbolic vector | symbolic matrix
Input, specified as a number, vector, or matrix or a symbolic number, vector, or matrix.
Introduced before R2006a