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

eigs finds wrong eigenvectors #2345

Closed
cshaa opened this issue Nov 2, 2021 · 8 comments
Closed

eigs finds wrong eigenvectors #2345

cshaa opened this issue Nov 2, 2021 · 8 comments

Comments

@cshaa
Copy link
Collaborator

cshaa commented Nov 2, 2021

Searching for eigenvalues and eigenvectors of the matrix 1, 2; 3, 4 produces:

math.eigs([
  [1, 2],
  [3, 4]
])
 {
    values: [-0.3723, 5.372],
    vectors: [
        [1e-17, 2.331],
        [-1.000, 5.097]
    ]
}

while the eigenvalues are correct, the eigenvectors are nonsense. The correct eigenvectors are:

[
   [0.4574, 1],
   [-1.457, 1]
]
@josdejong
Copy link
Owner

🤔 . Are the vectors always nonsense or just in this specific case?

@cshaa
Copy link
Collaborator Author

cshaa commented Nov 3, 2021

I've definitely tested a few matrices after implementing eigs for complex matrices and the results were correct for them. But since I don't know what causes this bug yet, I'm not sure how widespread it is... 🤔

But it is definitely a problem in my code, Arkajit's algorithm for symmetric matrices works OK afaik.

@josdejong
Copy link
Owner

Maybe there is somewhere a numerical instability causing these issues, I see 1e-17 in the vectors.

@davidtranhq
Copy link
Contributor

I'm looking into this! I brought this bug to m93a's attention and we suspect it may have something to do with the way the Francis algorithm keeps track of transformations.

@apourzand

This comment has been minimized.

@cshaa
Copy link
Collaborator Author

cshaa commented Nov 5, 2021

@apourzand The behavior you report is correct. The algorithm finds the two eigenvalues, but fails to find eigenvectors – this is fine, as the matrix is a Jordan cell, therefoere not diagonalizable. Sadly, there isn't a way to only run the eigenvalue search without also searching for eigenvectors – for that, see #2180.

@davidtranhq
Copy link
Contributor

davidtranhq commented Apr 20, 2022

Looks like this was fixed with #2478 !

The library now correctly outputs

math.eigs([
  [1, 2],
  [3, 4]
])
 {
    values: [-0.3723, 5.372],
    vectors: [
        [0.514, 2.331], 
        [-0.353, 5.096]
    ]
}

which are scaled vectors of the correct eigenvectors.

@josdejong
Copy link
Owner

O that is a nice surprise 😄

I just checked and you're right. I'll close this issue.

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

No branches or pull requests

4 participants