Why do I see a singular matrix warning here?
32 views (last 30 days)
Show older comments
John D'Errico
on 22 Oct 2021
Commented: Clara Casado-Coterillo
on 23 Oct 2023
I've posted this question as a "response" to a question posed by someone else, but as an answer to another question. Since I cannot move that answer into a question by that person, I'll post the question myself, since this seems to be a question I have seen too often.
A = [2 1 -5; 0 1 -2; 0 0 2];
[V, D] = eig(A);
% Matrix of eigenvectors returned
V
% Eigenvalues for those eigenvectors
diag(D)
% But now, when I try to recover A from the eigenvalues and eigenvectors,
% this fails, and I get a singular matrix warning? Why is that?
V\D*V
Even worse, the result does not reproduce A? What is wrong with eig?
A
1 Comment
Clara Casado-Coterillo
on 23 Oct 2023
when a jacobian in nlparci gives back this warning in nlparci, what should we do?
Accepted Answer
John D'Errico
on 22 Oct 2021
Edited: John D'Errico
on 22 Oct 2021
8 Comments
Christine Tobler
on 22 Oct 2021
Great post, John! I just wanted to point out two MATLAB functions that can be used to check if a matrix is defective.
If you're using the symbolic toolbox, calling eig on a symbolic matrix will tell you this exactly: V only contains linearly independent eigenvectors, while D gives the multiplicities of each eigenvalue. The third output P can be used to map from the eigenvalues in D to the eigenvectors in P.
A = [2 1 -5; 0 1 -2; 0 0 2];
[V, D, P] = eig(sym(A));
V
diag(D)
P
If we're doing numeric computations, "is this matrix defective" can't be answered easily, because any tiny change to the matrix would change the answer. This is similar to the question of "is this matrix low-rank" - adding some tiny random noise will make the matrix be full-rank in exact arithmetic, but when doing numerical computations, we would want to know if the matrix is close up to round-off to a low-rank matrix.
So here also, we can answer the question "is this matrix close to being defective". In a way, the warning about U being ill-conditioned was already doing that, telling us that the eigenvectors found are close to being linearly dependent.
Some more detailed information is given by condeig:
[U, D, s] = condeig(A);
diag(D)
log10(s)
Each value in s gives the sensitivity of the corresponding eigenvalue towards a small change in A. If s(i) is very large it means that the matrix A is close to a matrix for which this i'th eigenvalue "is defective" (that is, that it has larger algebraic than geometric multiplicity).
Bruno Luong
on 23 Oct 2021
Edited: Bruno Luong
on 23 Oct 2021
"But does the form Vb\Db*Vb recover B?"
Actually Vb*Db/Vb recovers B
B=[2 1 -5
0 1 -2
0 0 3]
[Vb,Db] = eig(B)
Br = Vb*Db/Vb
norm(Br - B)
More Answers (0)
See Also
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!