MATLAB eig function giving different eigenvectors on different computers?

24 vues (au cours des 30 derniers jours)
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 commentaires
Aquatris
Aquatris le 11 Oct 2024
Check the answer here. I think it provides the insight you need for this question.
Bruno Luong
Bruno Luong le 11 Oct 2024
"Check the answer here. I think it provides the insight you need for this question."
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.

Connectez-vous pour commenter.

Réponse acceptée

Bruno Luong
Bruno Luong le 10 Oct 2024
Modifié(e) : Bruno Luong le 10 Oct 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.

Plus de réponses (1)

Walter Roberson
Walter Roberson le 10 Oct 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.

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Produits


Version

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by