Eig doesn't converge - can you explain why?
Show older comments
Hi,
I have been having a problem with the eigenvalue function. I have two 240x240 matrices (which I have attached with this post) that I add together, and then get matrices of eigenvalues and eigenvectors. I have many such matrices like the ones that I posted that are added together and such during the program, but this combination does not work for some reason. It always works with the eigenvalues, so it seems like the eigenvectors are causing the problem. Any clues as to why so? The line of code that I have been using is:
[a,b] = eig(hh(1:240,1:240)+ pot(1:240,1:240));
The reason that I specified the range of indices is that if I use either 1:239 or 2:240 on both "hh" and "pot" at the same time, the eig function doesn't have a problem anymore. Anyway, thanks for any help you can give.
3 Comments
Matt J
on 24 Feb 2015
I'm seeing no obvious problems with the example you posted. The eigenvalues and vectors that I get satisfy their defining equation with high accuracy,
>> A=hh(1:240,1:240)+ pot(1:240,1:240);
>> [V,D] = eig(A);
>> norm(A*V-V*D,inf)/norm(V*D,inf)
ans =
2.8740e-15
You might want to elaborate more on how your expectations are violated.
Benjamin Pound
on 24 Feb 2015
Florian Roemer
on 12 Jul 2017
I encountered a similar problem in Matlab R2014a. For very particular matrices I have
[V,E] = eig(A)
give me the error "Error using eig: eig did not converge", while on the very same matrix
E = eig(A)
works just fine. So I can get the eigenvalues but not the eigenvectors. This problem seems to be fixed in newer versions of Matlab, at least it worked on another machine where I have R2017a installed.
For R2014a, funnily it works if I switch to a generalized eigenvalue problem eig(A,B), which for B=I should give exactly the same result. But I guess it uses a slightly modified algorithm. Therefore, I'm using the following workaround right now:
try
[V,E] = eig(A);
catch
[V,E] = eig(A,eye(size(A)));
end
which works fine in R2014a.
The matrix where I encountered the problem was symmetric but not positive definite, i.e., it had positive and negative eigenvalues and some close to zero (1e-6 where the largest was around 2).
Accepted Answer
More Answers (0)
Categories
Find more on Linear Algebra in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!