To be self-contained, I introduce the following Lemma that plays the key role in constructing the change of basis matrix.
Lemma
$$
[\exists P(x),Q(x),s.t. P(x)(xI-B)Q(x)=xI-A]\implies \exists S,s.t.,SBS^{-1}=A,
$$
where $P(x),Q(x)$ are unimodular polynomial matrices of a single variable $x$; A,B are constant matrices, and $I$ is the identity matrix. Further, $S$ is the remainder of dividing $P(x)$ by $xI-A$, i.e. $S$ satisfy $P(x)=(xI-A)D(x)+S$ for some polynomial matrix $D(x)$.
I will not prove this lemma now as the question asks about specific examples. The procedures can be summarized as follows:
- Given matrix $A$, find the Smith normal form of $xI-A$. Keep track of the transformation matrices.
- Permute rows and columns of $xI-A$ simultaneously such that each block is of the form
$$\begin{bmatrix}
1 & & \\
& \ddots & \\
& &\phi_{C_k}(x) \\
\end{bmatrix}$$
- Each such block is also the Smith normal form of a corresponding companion matrix $C_k$, and we can stack the transformation matrices and companion matrices together.
- Last rearrange the matrices, and we will get an equation of the form
$$P(x)(xI-C)Q(x)=xI-A$$, where $C$ is a block-diagonal matrix with block entries to be companion matrices, i.e.
$$C=
\begin{bmatrix}
C_{k_1} & & & \\
& C_{k_2} & &\\
& &\ddots & \\
& & &C_{k_l}
\end{bmatrix}.$$
- Following the lemma, $S$ is the remainder of dividing $P(x)$ by $Ix-A$.
I implement the procedure above to the following example question: find the Frobenius normal form and corresponding change of basis matrix of
$$
A=
\begin{bmatrix}
2 & & \\
1 & 2 &\\
& & 2 \\
\end{bmatrix}.
$$
Step1,2: One can show
$$
\begin{bmatrix}
-1 & & \\
x-2 & 1 &\\
& & 1 \\
\end{bmatrix}
\begin{bmatrix}
& 1 & \\
1 & &\\
& & 1 \\
\end{bmatrix}
\begin{bmatrix}
x-2 & & \\
-1 & x-2 &\\
& & x-2 \\
\end{bmatrix}
\begin{bmatrix}
1 & x-2 & \\
& 1 &\\
& & 1 \\
\end{bmatrix}=
\begin{bmatrix}
1 & & \\
& (x-2)^2 &\\
& & x-2 \\
\end{bmatrix}
\equiv A'(x)
$$
$A'(x)$ is permuted Smith normal form. Define
$$
G(x)=
\begin{bmatrix}
-1 & & \\
x-2 & 1 &\\
& & 1 \\
\end{bmatrix}
\begin{bmatrix}
& 1 & \\
1 & &\\
& & 1 \\
\end{bmatrix},
H(x)=
\begin{bmatrix}
1 & x-2 & \\
& 1 &\\
& & 1 \\
\end{bmatrix},
$$
we obtain
$$G(x)(xI-A)H(x)=A'(x).$$
Step 3: Define
$$
A'_1(x)=
\begin{bmatrix}
1 & \\
& (x-2)^2
\end{bmatrix},
A'_2(x)=
\begin{bmatrix}
x-2
\end{bmatrix}
$$
such that
$$A'(x)=
\begin{bmatrix}
A'_1(x) & \\
& A'_2(x)
\end{bmatrix}.$$
$A'_1(x)$ corresponds to the companion matrix
$C_1=\begin{bmatrix}
0 & -4 \\
1 & 4
\end{bmatrix}$. We can find
$$
\begin{bmatrix}
& -1 \\
1 &
\end{bmatrix}
\begin{bmatrix}
1 & x \\
& 1
\end{bmatrix}
(xI-C_1)
\begin{bmatrix}
1 & x-4 \\
& 1
\end{bmatrix}=
\begin{bmatrix}
1 & \\
& x^2-4x+4
\end{bmatrix}.
$$
To write this compactly, define
$$
P_1(x)=
\begin{bmatrix}
& -1 \\
1 &
\end{bmatrix}
\begin{bmatrix}
1 & x \\
& 1
\end{bmatrix},
Q_1(x)=
\begin{bmatrix}
1 & x-4 \\
& 1
\end{bmatrix}.
$$
Step 4: As we don't need to transform $A'_2(x)$(as $A'_2(x)=xI-C_2=x-2$), stack matrices to obtain
$$
G(x)(xI-A)H(x)=
\begin{bmatrix}
P_1(x) & \\
& 1
\end{bmatrix}
(xI-
\begin{bmatrix}
C_1 & \\
& C_2
\end{bmatrix})
\begin{bmatrix}
Q_1(x) & \\
& 1
\end{bmatrix}.
$$
Simplify the equations and obtain
$$
xI-A=
\begin{bmatrix}
1 & 2 & \\
& 1 & \\
& & 1
\end{bmatrix}
(xI-C)
\begin{bmatrix}
1 & 2-x & \\
& (x-2)^2 & \\
& & 1
\end{bmatrix}.
$$
Step 5: notice that
$P'(x)\equiv \begin{bmatrix}
1 & 2 & \\
& 1 & \\
& & 1
\end{bmatrix}$ is already a constant matrix. Therefore, the remainder of dividing $P'(x)$ by $xI-A$ is itself. This says that we have found the change of basis matrix $S$,
$$S=P'(x)=
\begin{bmatrix}
1 & 2 & \\
& 1 & \\
& & 1
\end{bmatrix}.$$
Finally, one can calculate and show
$$
SCS^{-1}=
\begin{bmatrix}
1 & 2 & \\
& 1 & \\
& & 1
\end{bmatrix}
\begin{bmatrix}
0 & -4 & \\
1 & 4 & \\
& & 2
\end{bmatrix}
\begin{bmatrix}
1 & -2 & \\
& 1 & \\
& & 1
\end{bmatrix}=
\begin{bmatrix}
2 & & \\
1 & 2 & \\
& & 2
\end{bmatrix}=A
$$
as desired.