numerical error in eig command
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
H Sadeghi
le 10 Juil 2015
Commenté : H Sadeghi
le 10 Juil 2015
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 commentaires
Réponse acceptée
Roger Stafford
le 10 Juil 2015
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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Linear Algebra dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!