MATLAB eig function giving different eigenvectors on different computers?
16 次查看(过去 30 天)
显示 更早的评论
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 个评论
Bruno Luong
2024-10-11
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.
采纳的回答
Bruno Luong
2024-10-10
编辑:Bruno Luong
2024-10-10
"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 个评论
更多回答(1 个)
Walter Roberson
2024-10-10
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!