Jordan decomposition - help with calculation of transformationmatrices? Let $$A=\begin{pmatrix}5&1&1 \\-1&3&1\\0&0&4\end{pmatrix}$$
The Jordan-decomposition is $$A=\begin{pmatrix}-1&-1&-1/2 \\1&0&0\\0&0&-1/2\end{pmatrix}\begin{pmatrix}4&1&0 \\0&4&1\\0&0&4\end{pmatrix}\begin{pmatrix}0&1&0 \\-1&-1&1\\0&0&-2\end{pmatrix}$$
And it drives me crazy that I don't get it ! 
The characteristic polynomial is $p(\lambda)=(\lambda-4)^3$ therefore $\lambda=4$ has algebraic multiplicity $3$
Then
$(A-4I)=\begin{pmatrix}1&1&1 \\-1&-1&1\\0&0&0\end{pmatrix} \Rightarrow \dim(\text{kernel})=2<3$
$(A-4I)^2=\begin{pmatrix}0&0&2 \\0&0&-2\\0&0&0\end{pmatrix}\Rightarrow \dim(\text{kernel})=1<3$
The matrix is not diagonalizable, so we get 
$$J=\begin{pmatrix}4&1&0 \\0&4&1\\0&0&4\end{pmatrix}$$
Now I need the eigenvectors/eigenspaces/generalized eigenvetors/spaces and here is the part I have trouble with.
$(A-4I)v=\begin{pmatrix}1&1&1 \\-1&-1&1\\0&0&0\end{pmatrix}v=0 \Rightarrow v_1=-v_2 \land v_3=0 \Rightarrow v=\begin{pmatrix}1\\-1\\0\end{pmatrix} $
$(A-4I)^2u=\begin{pmatrix}0&0&2 \\0&0&-2\\0&0&0\end{pmatrix}u=0 \Rightarrow u_3=0\Rightarrow u=\begin{pmatrix}1\\0\\0\end{pmatrix}, u*=\begin{pmatrix}0\\1\\0\end{pmatrix}$
I don't understand how/what wolfram alpha did -.-
What did I wrong ? Thanks for answers.
 A: I like to run the thing backwards. We have $(A-4I)^3 = 0$ but $(A-4I)^2 \neq 0.$ So, we can find a column vector, call it $r,$ such that $(A-4I)^2 r \neq 0.$ For example, we can take $r = (0,0,1)^T.$ Then let $q = (A-4I)r,$ so that $(A-4I)^2 q = 0,$ but $(A-4I)q \neq 0.$ Finally $p = (A-4I)q,$ so $(A-4I)p = 0$ but $p \neq 0.$ Then make the coefficient matrix on the right, call it $P,$ with columns $(p,q,r).$ Jordan form becomes $P^{-1}A P.$ I got
$$
P =
\left(
\begin{array}{rrr}
2 & 1 & 0 \\
-2 & 1 & 0 \\
0 & 0 & 1 \\
\end{array}
\right)
$$
$$
AP =
\left(
\begin{array}{rrr}
8 & 6 & 1 \\
-8 & 2 & 1 \\
0 & 0 & 4 \\
\end{array}
\right)
$$
For the columns $p,q,r,$ we can see that $$ Ap = 4p, \; Aq = p + 4 q, \; Ar = q + 4r. $$
You also need
$$
P^{-1} =
\left(
\begin{array}{rrr}
\frac{1}{4} & -\frac{1}{4} & 0 \\
\frac{1}{2} & \frac{1}{2} & 0 \\
0 & 0 & 1 \\
\end{array}
\right)
$$
I like this method as there is little additional work after confirming the matrices $A-4I$ and $(A-4I)^2.$ 
Let's see, if you use that same column vectors but order $P$ backwards as $r,q,p,$ you get a different Jordan form with the extra $1$ entries below the main diagonal, rather than above. This is, more or less, a proof that a matrix and its transpose are always similar.
A: We are looking for P such that $P^{-1}AP=J$ thus you need to solve the following systems $AP=PJ$ that is
$Av_1=4v_1$
$Av_2=v_1+4v_2$
$Av_3=v_2+4v_3$
where $v_1$,$v_2$,$v_3$ are the columns of P.
Once we find $v_1$ from the first system, we can find $v_2$ from the second and finally $v_3$ from the third.
See also this example
Making matrix upper triangular by finding Jordan Normal Form
More in detail
$Av_1=4v_1\implies (A-4I)v_1=0\implies \begin{pmatrix}1&1&1 \\-1&-1&1\\0&0&0\end{pmatrix}v_1=0\\\implies  v_1=\begin{pmatrix}-1 \\1\\0\end{pmatrix}$
$Av_2=v_1+4v_2\implies (A-4I)v_2=v_1 \implies \begin{pmatrix}1&1&1 \\-1&-1&1\\0&0&0 \end{pmatrix} v_2=\begin{pmatrix}-1 \\1&\\0\end{pmatrix}\\\implies  v_2=\begin{pmatrix}-1 \\0\\0\end{pmatrix}$
$Av_3=v_2+4v_3\implies (A-4I)v_3=v_2 \implies \begin{pmatrix}1&1&1 \\-1&-1&1\\0&0&0 \end{pmatrix} v_3=\begin{pmatrix}-1 \\0&\\0\end{pmatrix}\\\implies  v_3=\begin{pmatrix}-\frac12 \\0\\-\frac12\end{pmatrix}$
Thus
$$P=\begin{pmatrix}-1&-1&-1/2 \\1&0&0\\0&0&-1/2\end{pmatrix}$$
