Identify generalized eigenvectors in MATLAB

Let A be a large sparse matrix (not invertible). A has repeated eigenvalues (say $\lambda_i$) which has degenerate eigenvectors (say more than 2). what is the best way (or algorithm) to identify generalized eigenvectors corresponding to $\lambda_i$.

I know the method is to solve for n generalized eigenvectors by $$(A-\lambda I)x_k=x_{k-1}$$ for $k=2,3, \dots n$, or $$(A-\lambda I)^n x=0$$ I tried to identify the eigenvectors of the latter method using MATLAB function $eigs(A,n,'sm')$.

Q1. which one is the best out of these two? Is there any other way to identify generalized eigenvectors accurately?. Accuracy is the main concern.

Q2. I tried algorithms in http://www.mathworks.com/help/matlab/math/systems-of-linear-equations.html#brzoiix. But not sure about the best choice.

Q3. How to confirm there are exactly n eigenvectors of $\lambda_i$ are degenerate so that I need to identify n generalized eigenvectors.

• This is actually a serious problem, because arbitrarily small perturbations of a nondiagonalizable matrix are diagonalizable. So numerical methods for finding the Jordan form of a large nondiagonalizable matrix are hard. – Ian Aug 19 '16 at 3:15
• Why do you need generalized eigenvectors? You can't find generalized eigenvectors numericaly. – Pawel Kowal Aug 19 '16 at 5:48
• @PawelKowal, Really?. I have to generate a full eigenbasis to define the solution of a system of linear ODE. But when the eigenvectors are degenerate, I have to go for generalized eigenvectors. Do u have any suggestion on this matter? – Midhun Kathanaruparambil Aug 19 '16 at 13:12
• Analytically, this is true, but numerically you just wind up simulating the ODE itself instead of trying to find the generalized eigenvectors. Finding generalized eigenvectors is hard because you more or less have to do everything in exact arithmetic. – Ian Aug 19 '16 at 14:37
• Solution to a linear ODE problem $\dot{x} = Ax$, $x(0) = x_0$ is given by $x(t)=\exp(tA)x_0$. In order to find analytic expression of $x$, the best way to calculate $\exp(tA)$ is to use the Jordan decomposition of $A$. But in order to find solution numerically you need to compute $\exp(tA)$ differently. You may also use methods, that does not require computing $\exp(tA)$. – Pawel Kowal Aug 19 '16 at 18:26