<s>[INST] Computing invariant factors from Smith normal form The goal is to find the Jordan Canonical Form of the matrix 
$$A=\begin{bmatrix}2&1&1&2\\0&2&0&1\\0&0&2&-1\\0&0&0&1\end{bmatrix}$$
Since the matrix is already upper-triangular, it's obvious that the eigenvalues are 2 and 1, where 1 has geometric and algebraic multiplicity 1, so that I could easily find the JCF by computing $\operatorname{rank}{(A-2I)^{i}}$ for each $i$. However, I thought I would instead try to do it by computing the invariant factors by finding the Smith normal form of the characteristic matrix $xI-A$. The problem is that using elementary row and column operations, I only seem able to obtain the matrix 
$$\begin{bmatrix}1&0&0&0\\0&1&0&0\\0&0&(x-2)^2&0\\0&0&0&(x-1)(x-2)\end{bmatrix}$$
My questions are:


*

*Even though this matrix is not in Smith normal form, is it valid to conclude that the elementary divisors are the powers of the irreducible factors that appear in each diagonal entry, i.e. $(x-1)$, $(x-2)^2$, and $(x-2)$? It happens to be true for this $A$, but would it always be true?

*How do I coax the above matrix into Smith normal form?

 [/INST] I'll answer your second question first.
Let
$$P(x) = \begin{bmatrix}1&0&0&0\\0&1&0&0\\0&0&(x-2)^2&0\\0&0&0&(x-1)(x-2)\end{bmatrix}.$$
We need to fix the bottom right $2 \times 2$ principal submatrix. I have explained how to do that here, so I'll just present the results here:
\begin{align*}
\begin{bmatrix}1&0&0&0\\0&1&0&0\\0&0&(x-2)^2&0\\0&0&0&(x-1)(x-2)\end{bmatrix} &\mapsto \begin{bmatrix}1&0&0&0\\0&1&0&0\\0&0&(x-2)^2&(x-1)(x-2)\\0&0&0&(x-1)(x-2)\end{bmatrix} \\
&\mapsto \begin{bmatrix}1&0&0&0\\0&1&0&0\\0&0&(x-2)^2&(x-2)^2+(x-2)\\0&0&0&(x-1)(x-2)\end{bmatrix} \\
&\mapsto \begin{bmatrix}1&0&0&0\\0&1&0&0\\0&0&(x-2)^2&x-2\\0&0&0&(x-1)(x-2)\end{bmatrix} \\
&\mapsto \begin{bmatrix}1&0&0&0\\0&1&0&0\\0&0&x-2&(x-2)^2\\0&0&(x-1)(x-2)&0\end{bmatrix} \\
&\mapsto \begin{bmatrix}1&0&0&0\\0&1&0&0\\0&0&x-2&0\\0&0&(x-1)(x-2)&-(x-1)(x-2)^2\end{bmatrix} \\
&\mapsto \begin{bmatrix}1&0&0&0\\0&1&0&0\\0&0&x-2&0\\0&0&0&-(x-1)(x-2)^2\end{bmatrix} \\
&\mapsto \begin{bmatrix}1&0&0&0\\0&1&0&0\\0&0&x-2&0\\0&0&0&(x-1)(x-2)^2\end{bmatrix}
\end{align*}
Irreducible factors are $x-2$ and $x-1$, while the elementary divisors are $x-2$, $(x-2)^2$ and $x-1$.
I think, but I'm not sure, that what you suggest in your first question can always be done to obtain the correct result. One would have to prove it to actually use it. Personally, I find it easier to just properly reduce the matrix polynomial or to fix it to become the Smith normal form, like I did above.
</s>