The question I am working on is to compute the Jordan normal form of $$A := \begin{pmatrix} 2 & 1 & 5 \\ 0 & 1 & 3\\ 1 & 0 & 1\end{pmatrix}.$$ The characteristic polynomial and minimal polynomial of $A$ is $x^{2}(x - 4)$. Then the Jordan normal form of $A$ is given by $$J := \begin{pmatrix} 0 & 1 & 0\\ 0 & 0 & 0\\ 0 & 0 & 4 \end{pmatrix}.$$ Then there exist a matrix $P$ such that $P^{-1}AP = J$.
I am having an issue finding $P$. From the theory of Jordan normal forms, $P = [w_{1}\, w_{2}\, w_{3}]$ where $w_{1}, w_{2}$ is the basis of the nullspace of $(A - 0\cdot I)^{2}$ (where $I$ is the identity matrix) and $w_{3}$ is the basis of the nullspace of $(A - 4\cdot I)$. We first consider $(A - 0 \cdot I)^{2}$. As $$A^{2} = \begin{pmatrix} 9 & 3 & 18\\ 3 & 1 & 6\\ 3& 1 & 6\end{pmatrix} \sim \begin{pmatrix} 1 & 1/3 & 2 \\ 0 & 0 & 0 \\ 0 & 0 & 0 \end{pmatrix}$$ (where the $\sim$ denotes row equivalence), the nullspace of $A^{2}$ is spanned the column vectors $\{(-2, 0, 1)^{t}, (-1, 3, 0)^{t}\}$. Next we consider $(A - 4 \cdot I)$. We have $$A - 4I = \begin{pmatrix} -2 & 1 & 5\\ 0 & -3 & 3\\ 1 & 0 & -3 \end{pmatrix} \sim \begin{pmatrix} 1 & 0 & -3\\0 & 1 & -1\\ 0 & 0 & 0\end{pmatrix}.$$ Then the nullspace is spanned by the column vector $(3, 1, 1)^{t}$.
Therefore we should have $$P = \begin{pmatrix} -2 & -1 & 3\\0 & 3 & 1\\ 1 & 0 & 1 \end{pmatrix}.$$ However, when I compute $P^{-1}AP$, I get $$P^{-1}AP = \begin{pmatrix} -1 & -1 & 0\\ 1 & 1 & 0\\0 & 0 & 4\end{pmatrix} \neq J.$$ Where did I go wrong? Is there something wrong on how I computed $P$?
To calculate the eigenvectors for $\lambda=0$ you want to find a chain. You need to find $\vec{u}_1$ and $\vec{u}_2$ such that $A\vec{u}_2=\vec{u}_1$ and $A\vec{u}_1=0$. Clearly there exists such a solution as zero is an e-value of $A$ hence $A$ is singular. For example, $\vec{u}_1 = ( -2, -6, 2)$ and $\vec{u}_2 = (-1,-6,0)$. I believe these will put the matrix in the form you desire.