numerical error in eig command
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
H Sadeghi
am 10 Jul. 2015
Kommentiert: H Sadeghi
am 10 Jul. 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 Kommentare
Akzeptierte Antwort
Roger Stafford
am 10 Jul. 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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Linear Algebra finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!