How to find Jordan basis of a matrix Assume matrix 
$$A=
\begin{bmatrix}
-1&0&0&0&0\\
-1&1&-2&0&1\\
-1&0&-1&0&1\\
0&1&-1&1&0\\
0&0&0&0&-1
\end{bmatrix}
$$
Its Jordan Canonical Form is
$$J=
\begin{bmatrix}
-1&1&0&0&0\\
0&-1&0&0&0\\
0&0&-1&0&0\\
0&0&0&1&1\\
0&0&0&0&1
\end{bmatrix}
$$
I am trying to find a nonsingular $P$, let $P=\begin{bmatrix}\mathbf{p}_1&\mathbf{p}_2&\mathbf{p}_3&\mathbf{p}_4&\mathbf{p}_5\end{bmatrix}$ s.t. $J=P^{-1}AP\Leftrightarrow AP=PJ$.
I came up with the Wikipedia article on JCF and I think I need to find the generalized eigenvectors so that
$AP=PJ=\begin{bmatrix}-\mathbf{p_1}&\mathbf{p_1}-\mathbf{p_2}&-\mathbf{p_3}&\mathbf{p_4}&\mathbf{p_4}+\mathbf{p_5}\end{bmatrix}$ yielding the systems
$$(A+I)\mathbf{p_1}=\mathbf{0}$$
$$(A+I)^2\mathbf{p_2}=\mathbf{0}$$
$$(A+I)\mathbf{p_3}=\mathbf{0}$$
$$(A-I)\mathbf{p_4}=\mathbf{0}$$
$$(A-I)^2\mathbf{p_5}=\mathbf{0}$$
I solved each of these systems making sure that the vectors $\mathbf{p_i}$ I chose are linearly independent. So I chose
$$P=\begin{bmatrix}\mathbf{p}_1&\mathbf{p}_2&\mathbf{p}_3&\mathbf{p}_4&\mathbf{p}_5\end{bmatrix}=\begin{bmatrix}1&2&-2&0&0\\1&1&2&0&1\\1&1&2&0&0\\0&0&0&1&1\\1&1&-2&0&0\end{bmatrix}$$
which even though is nonsingular I am not getting $AP=PJ$.
What am I doing wrong?
 A: Note that the condition $AP=PJ$ is equivalent to


*

*$Ap_1=-p_1 \to p_1$

*$Ap_2=p_1-p_2\to p_2$

*$Ap_3=-p_3\to p_3$

*$Ap_4=p_4 \to p_4$

*$Ap_5=p_4+p_5 \to p_5$


Since the set up is equivalent, from you results seems that there is something wrong in the calculation indeed $Ap_1\neq p_1-p_2$.
Notably from


*

*$Ap_1=-p_1 \implies (A+I)p_1=0$

*$Ap_2=p_1-p_2\implies (A+I)p_2=p_1$


we obtain


*

*$p_1=(0,1,1,0,0)$

*$p_2=(-1,0,0,0,0)$


from


*

*$Ap_3=-p_3 \implies (A+I)p_3=0$


excluding $p_1$ we obtain


*

*$p_3=(1,0,0,0,1)$


and from


*

*$Ap_4=p_4 \implies (A-I)p_4=0$

*$Ap_5=p_4+p_5 \implies (A-I)p_5=p_4$
we obtain


*

*$p_4=(0,0,0,-1,0)$

*$p_5=(0,-1,0,0,0)$

A: I got the Jordan blocks in slightly different order.
What you seem to be missing is the consistency part: in my
$$ P = 
\left(
\begin{array}{rrrrr}
1 & 0 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 & 1 \\
0 & 1 & 0 & 0 & 0 \\
0 & 0 & 0 & 1 & 0 \\
1 & 0 & 1 & 0 & 0
\end{array}
\right) 
$$
we have a place where we do have $(A+I)^2 p_3 = 0,$ but we have consistency in that $p_2 =(A+I)p_3 .$ It follows automatically that $(A+I)p_2 = (A+I)^2 p_3 = 0.$
We also have $(A-I)^2 p_5 = 0,$ then $p_4 =(A-I)p_5.$ As a result $(A-I) p_4 = 0.$
$$
\left(
\begin{array}{rrrrr}
1 & 0 & 0 & 0 & 0 \\
0 & 0 & 1 & 0 & 0 \\
-1 & 0 & 0 & 0 & 1 \\
0 & 0 & 0 & 1 & 0 \\
0 & 1 & -1 & 0 & 0
\end{array}
\right)
\left(
\begin{array}{rrrrr}
-1 & 0 & 0 & 0 & 0 \\
-1 & 1 & -2 & 0 & 1 \\
-1 & 0 & -1 & 0 & 1 \\
0 & 1 & -1 & 1 & 0 \\
0 & 0 & 0 & 0 & -1
\end{array}
\right)
\left(
\begin{array}{rrrrr}
1 & 0 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 & 1 \\
0 & 1 & 0 & 0 & 0 \\
0 & 0 & 0 & 1 & 0 \\
1 & 0 & 1 & 0 & 0
\end{array}
\right) =
\left(
\begin{array}{rrrrr}
-1 & 0 & 0 & 0 & 0 \\
0 & -1 & 1 & 0 & 0 \\
0 & 0 & -1 & 0 & 0 \\
0 & 0 & 0 & 1 & 1 \\
0 & 0 & 0 & 0 & 1
\end{array}
\right)
$$
To get the Jordan form in the order they report, use my columns but permuted, $p_2p_3p_1p_4p_5$ and then correct $P^{-1}.$ We can correct $P^{-1}$ by permuting the rows to 23145.
