On the Wikipedia page on generalized eigenvectors it uses the example of a matrix $A$ given by $$ A = \begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix}, $$ and says that this matrix has a repeated eigenvalue of $1$ with multiplicity $2$, and that the eigenvector $v_1$ and generalized eigenvector $v_2$ are given by $$ v_1 = \begin{pmatrix} 1 \\ 0 \end{pmatrix}, \quad v_2 = \begin{pmatrix} a \\ 1 \end{pmatrix}, $$ where $a$ can be any scalar. However when I create this matrix in MatLab and use $\texttt{eig}$ to find its eigenvalues and eigenvectors I get the repeated eigenvalue of $1$ but the eigenvectors/generalized eigenvector it gives me are $$ v_1 = \begin{pmatrix} 1 \\ 0 \end{pmatrix}, \quad v_2 = \begin{pmatrix} -1 \\ 0 \end{pmatrix}. $$
A = [ 1, 1; 0, 1]
[V, D] = eig(A)
So why is MatLab not returning eigenvectors that match the Wikipedia example?
The answer is very simple:
eigfinds only eigenvectors, not generalized eigenvectors.The vector $\begin{bmatrix}a\\1\end{bmatrix}$ is not a eigenvector of $A$, it is only a generalized eigenvector of $A$, so there is no reason you would expect for
eig(a function which finds eigenvectors) to find it.To quote from the documentation: