MATLAB eig function giving different eigenvectors on different computers?
31 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Melody
am 10 Okt. 2024
Kommentiert: Bruno Luong
am 11 Okt. 2024
I had my students use [V,D] = eig(A) to compute eigenvectors of the matrix A = [5 -10 -5; 2 14 2; -4 -8 6] as part of an assignment. I noticed they were getting differing results for their V matrices. I investigated this:
On two different machines I own, both having Apple Silicon processors, and using both R2024a and R2024b, the command [V,D] = eig(A) yields the results
V =
0.7454 -0.8234 -0.5750
-0.2981 0.1362 0.5773
0.5963 0.5509 -0.5797
D =
5.0000 0 0
0 10.0000 0
0 0 10.0000
However, when I try the operation using MATLAB online (R2024b) , [V,D] = eig(A) yields the same D matrix but a different V matrix:
V =
-0.7454 -0.0000 -0.6650
0.2981 0.4472 0.5724
-0.5963 -0.8944 -0.4797
Examining my students' answers, most of them match the second result, although a few have the first result.
In both cases the computation A*V - V*D yields a matrix with entries on the order of 1e-14, so all is well numerically in both cases. Anyone know what is causing the difference in results?
2 Kommentare
Bruno Luong
am 11 Okt. 2024
This post mainly deal with EIGS not EIG. EIGS is an iterative method with random starting vector that has even more instability issue from run-o-run on the same computer.
Akzeptierte Antwort
Bruno Luong
am 10 Okt. 2024
Bearbeitet: Bruno Luong
am 10 Okt. 2024
"In both cases the computation A*V - V*D yields a matrix with entries on the order of 1e-14, so all is well numerically in both cases. Anyone know what is causing the difference in results?"
Most likely because the double eigen value 10. The eigen space is then 2-D vector space, the eigen vectors are then arbitrary picked by different library. Nothing to worry since A*V == V*D numerically.
Even for an isolated eigen vector, the correspondign has arbitrary sign in case of real and arbitray complex phase in case of complex. One should not expect the eigen vector returned match on different computers, especially if computer has differnt CPU.
0 Kommentare
Weitere Antworten (1)
Walter Roberson
am 10 Okt. 2024
MATLAB Online is running using Linux on X64 CPUs, not Apple Silicon.
Apple Silicon uses a different library for the calculations - one optimized by Apple.
It is also likely that different releases of MATLAB for different operating systems and different CPUs use different libraries.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Matrix Indexing 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!