I try to compute eigenvalues of the tridiagonal matrix coming from finite difference scheme. For small mesh size, eigs works well. But for large size it fails. Here is an example where eigs fails. Is there any other way to reliably compute a few eigenvectors in matlab ?

n = 1000; h = 1/n;
e = ones(n,1);
A = (1/h)*spdiags([e, -2*e, e], -1:1, n, n);
e = eigs(A,10,'LA')
  • $\begingroup$ I should correct the title. eigs just fails for this tridiagonal matrix. eig works fine. $\endgroup$ – cfdlab Jul 26 '13 at 12:57
  • $\begingroup$ Have you checked the output flag to see if the iterative process is converging or it is exiting for another reason? Aternatively, setting some of the options may help. $\endgroup$ – Daryl Jul 26 '13 at 22:36
  • $\begingroup$ The computation was failing to converge. The answer by Bill Greene below solved it. $\endgroup$ – cfdlab Jul 27 '13 at 10:50

I was able to solve your example by using one of the eigs options to increase the number of Lanczos vectors used in the eigensolution from the default (20 in your case) to 50:

opts.p = 50;
e = eigs(A,10,'LA',opts)

I don't believe the algorithm is extremely sensitive to this number but, obviously, some experimentation with your real problem will be necessary to see if you can select a value that will consistently work.

I don't know of any other MATLAB functions for calculating a few eigenvalues from large, sparse matrices.


Since your matrices are tridiagonal, you could use an eigenvalue algorithm specifically designed for tridiagonal matrices. Here is one you could try (I haven't tried it though), trideigs by Vasil Yordanov.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.