numerical error in eig command
6 次查看(过去 30 天)
显示 更早的评论
If you calculate the eigenvalue of A = [0 1; 0 0], using [Evec, Eval] = eig(A), Matlab will return the answer as:
EVec =
1.0000 -1.0000
0 0.0000
Eval =
0 0
0 0
However this is not correct mathematically. Mathematically, this problem has one eigenvalue Eval = 0 and one eigenvector Evec = [1 0]. The calculated eigenvectors by Matlab are not independent eigenvectors as Evec(:,1) = -Evec(:,2).
If you print the data with longer format, "format longe", the answer is :
EVec =
1.000000000000000e+00 -1.000000000000000e+00
0 2.004168360008973e-292
Eval =
0 0
0 0
It seems that because of the numerical error, Matlab assumes Evec(:,1) and Evec(:,2) as two independent eigenvector! Anyway, this is numerical error.
How could you make sure that in your code where the eigenvalue problem on a matrix with many zeros is the central bit, Matlab does not compute the eigenvectors and eigenvalues incorrectly due to the numerical error?
0 个评论
采纳的回答
Roger Stafford
2015-7-10
While it is quite true that in an ideal mathematical sense the eigenvectors of your matrix A ought to be linearly dependent, you must face the fact that you are using a computer which is subject to round-off errors because it has only a finite number of bits to represent its numbers. For that reason you obtained two vectors which are, strictly speaking, linearly independent because of a very tiny error.
Therefore in your code you must provide a tolerance for such tiny errors rather than expecting your computer to give you mathematically perfect results. This is entirely analogous to the computation .1+.2-.3 which doesn't yield an exact zero.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!