MATLAB: Eig doesn’t converge – can you explain why


I have been having a problem with the eigenvalue function. I have two 240×240 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.

Best Answer

Hi Benjamin,
I encountered the same problem. I am also interested in knowing why this problem occurs. If you look for a workaround, here is one which worked for me: I just 'smooth' my matrix. If A is the matrix you want to use eig on and which is causing problem, I did:
% First we compute the squared Frobenius norm of our matrix
nA = sum(sum(A.^2));
% Then we make this norm be meaningful for element wise comparison
nA = nA / numel(A);
% Finally, we smooth our matrix
As = A;
As( As.^2 < 1e-10*nA ) = 0;
Just in case you want to check that the results are indeed what you want, I checked the validity of the results:
% We check that the result is correct
ev = eig(A);
[eVs,evs] = eig(As);
fprintf('Error of smoothing: %g%%\n',100*norm(ev-evs)/norm(ev));
Since our new matrix is very close to the original one, and since the eigen values are continuous functions of our matrix elements, the result of eig on this new smoothed matrix should be very close to the original. You can also smooth your matrix more or less by adjusting the 1e-10.
I attached my example. I get an error of 5e-9 and eig works.
I hope I helped. Good luck !