Why do I see a singular matrix warning here?
31 ビュー (過去 30 日間)
古いコメントを表示
John D'Errico
2021 年 10 月 22 日
コメント済み: Clara Casado-Coterillo
2023 年 10 月 23 日
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 件のコメント
Clara Casado-Coterillo
2023 年 10 月 23 日
when a jacobian in nlparci gives back this warning in nlparci, what should we do?
採用された回答
John D'Errico
2021 年 10 月 22 日
編集済み: John D'Errico
2021 年 10 月 22 日
8 件のコメント
Christine Tobler
2021 年 10 月 22 日
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
2021 年 10 月 23 日
編集済み: Bruno Luong
2021 年 10 月 23 日
"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)
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!