# 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. Jul 26, 2013 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. Jul 26, 2013 at 22:36
• The computation was failing to converge. The answer by Bill Greene below solved it. Jul 27, 2013 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.