Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EigenDecomposition with small matrix entries giving unexpected zeroes #252

Open
afossa opened this issue May 3, 2023 · 1 comment
Open

Comments

@afossa
Copy link

afossa commented May 3, 2023

The eigen-decomposition of symmetric, positive definite matrices should return real and strictly positive eigenvalues.

However, if the matrix has (very?) small entries, some eigenvalues are rounded to 0.0, even after setting epsilon=0.0 in the EigenDecomposition class constructor. This is in contrast with the results provided by implementations such as Matrix.EVD in SMILE or eig in MATLAB which correctly return positive eigenvalues.

Example with a 6x6 matrix:

Hipparchus 1.6345155367040014e-05 1.1026825667505243e-07 2.7548481451847817e-08 1.4945398700162820e-11 0.0000000000000000e+00 0.0000000000000000e+00
SMILE      1.6345155367040017e-05 1.1026825667504563e-07 2.7548481451847437e-08 1.4945398700378445e-11 2.0647209186968416e-21 1.8337646658331150e-22
MATLAB     1.6345155367040000e-05 1.1026825667504600e-07 2.7548481451848700e-08 1.4945398700197100e-11 2.0751061553057500e-21 1.9409437480416100e-22

I attach the code snippet, input matrix and MATLAB output with which I generated the above numbers.
eigen-issue.zip

@maisonobe
Copy link
Contributor

I am not sure we can improve this.
The problem is not related to the eigenvalues themselves, but rather to the the ratio between the smallest and largest eigenvalues which is about 8.4e16.
Scaling the matrix up by 1e10 and the eigenvalues down by 1e10 and setting the epsilon to 1e-20 helped slightly as it allowed to get the fifth eigenvalue, by the last one was still missing.
The matrix is ill-conditioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants