# matlab eigs: wrong eigenvalues for tridiagonal matrix

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')

• I should correct the title. eigs just fails for this tridiagonal matrix. eig works fine. – cpraveen Jul 26 '13 at 12:57
• 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. – Daryl Jul 26 '13 at 22:36
• The computation was failing to converge. The answer by Bill Greene below solved it. – cpraveen Jul 27 '13 at 10:50

opts.p = 50;

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.