<s>[INST] 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.
 [/INST] 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.
</s>