MATLAB Answers

0

Rank of Symbolic Matrix returns incorrectly

Asked by Brian Ulinski on 3 Jul 2019
Latest activity Commented on by Brian Ulinski on 4 Jul 2019
Hello all,
I am trying to invert a 5x5 matrix of mixed symbolics and numbers. All columns are linearly independent, concluded by inspection. However rank() returns 4 and the inverse of the matrix returns a 5x5 matrix where all elements are Inf.
Is there a better way to invert this matrix? It is not singular, as an inverse is returned, but it seems to be of indeterminate form.
Code:
% define coefficients
mu1 = sym('mu1');
mu2 = sym('mu2');
mu3 = sym('mu3');
gam1 = sym('gam1');
gam2 = sym('gam2');
gam3 = sym('gam3');
L = sym('L');
% define matrices
B = [1 -1 -1 0 0
gam1/mu1 gam2/mu2 -gam2/mu2 0 0
0 exp(-gam2*L) exp(gam2*L) -exp(-gam3*L) -exp(gam3*L)
0 (-gam2/mu2)*exp(-gam2*L) (gam2/mu2)*exp(gam2*L) (gam3/mu3)*exp(-gam3*L) (-gam3/mu3)*exp(gam3*L)
0 0 0 0 0]
rank(B)
inv(B)

  0 Comments

Sign in to comment.

2 Answers

Answer by Walter Roberson
on 3 Jul 2019
 Accepted Answer

An array with a row or column that is all zero cannot be full rank. It is not enough for columns to be linearly independent: rows must be as well.

  2 Comments

Put it like this: 5 columns with only 4 non-zero elements in the same columns in each can never be linearly independent. You can always write at least one of those columns as a linear combination of the others, even if that linear combination may be unbearably messy to write in symbolic form.
Big facepalm over here. It's been a long week.

Sign in to comment.


Answer by John D'Errico
on 3 Jul 2019

"Concuded by inspection." I've gotta laugh at that.
B =
[ 1, -1, -1, 0, 0]
[ gam1/mu1, gam2/mu2, -gam2/mu2, 0, 0]
[ 0, exp(-L*gam2), exp(L*gam2), -exp(-L*gam3), -exp(L*gam3)]
[ 0, -(gam2*exp(-L*gam2))/mu2, (gam2*exp(L*gam2))/mu2, (gam3*exp(-L*gam3))/mu3, -(gam3*exp(L*gam3))/mu3]
[ 0, 0, 0, 0, 0]
Do you see that the 5th row of B is IDENTICALLY zero? Not just small, or close, but flat out zero.
Is it true that the rank of a 5x5 mtrix with one zero row is at MOST 4? (Yes.)
Is it true this matrix is not invertible? (Yes.)
It is very much singular. No inverse exists. When inv returns inf or NaNs for the inverse, that is a signal that the result is meaningless.
inv(B)
ans =
[ Inf, Inf, Inf, Inf, Inf]
[ Inf, Inf, Inf, Inf, Inf]
[ Inf, Inf, Inf, Inf, Inf]
[ Inf, Inf, Inf, Inf, Inf]
[ Inf, Inf, Inf, Inf, Inf]
Is there a better way to invert that matrix? (No, since an inverse does not exist. It cannot exist. It will never exist.)
So, concluded by inspection? A bad conclusion.
A pseudo-inverse will exist. But that is only of value some of the time, and it will be highly computationally intensive to compute in fully symbolic form. A pseudo-inverse has some properties that may or may not be of value, but it is NOT an inverse.

  0 Comments

Sign in to comment.