## Compute the rational canonical form of a given matrix

Compute the rational canonical form of the following matrices.

 $A = \begin{bmatrix} 0 & -1 & -1 \\ 0 & 0 & 0 \\ -1 & 0 & 0 \end{bmatrix}$
 $B = \begin{bmatrix} c & 0 & -1 \\ 0 & c & 1 \\ -1 & 1 & c \end{bmatrix}$
 $C = \begin{bmatrix} 422 & 465 & 15 & -30 \\ -420 & -463 & -15 & 30 \\ 840 & 930 & 32 & -60 \\ -140 & -155 & -5 & 12 \end{bmatrix}$

Consider the matrix $A$. First, we use elementary row and column operations to put $xI - A$ in Smith Normal Form. Evidently the following sequence of ERCOs works:

1. $R_1 - xR_3 \rightarrow R_1$
2. $R_1 \leftrightarrow R_3$
3. $C_3 - xC_1 \rightarrow C_3$
4. $R_2 - xR_3 \rightarrow R_2$
5. $C_3 - (1-x^2)C_2 \rightarrow C_3$
6. $R_2 \leftrightarrow R_3$

The resulting matrix is $\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & x^3-x \end{bmatrix}$. Thus the only invariant factor of $A$ is $x^3-x$, and so the rational canonical form of $A$ is $\begin{bmatrix} 0 & 0 & 0 \\ 1 & 0 & 1 \\ 0 & 1 & 0 \end{bmatrix}$.

Now consider the matrix $B$. Again, we use ERCOs to get $xI-B$ in Smith Normal Form. Evidently the following sequence of operations suffices.

1. $R_1 - (x-c)R_3 \rightarrow R_1$
2. $C_2 + C_1 \rightarrow C_1$
3. $C_3 - (x-c)C_1 \rightarrow C_3$
4. $C_2 + (x-c)C_3 \rightarrow C_2$
5. $R_1 + (1-(x-c)^2)R_2 \rightarrow R_1$
6. $R_1 \leftrightarrow R_3$
7. $C_2 \leftrightarrow C_3$
8. $-C_2 \rightarrow C_2$
9. $-C_3 \rightarrow C_3$

Resulting in the matrix $\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & x^3 - 3cx^2 - (2-3c^2)x - c(c^2-2) \end{bmatrix}$. The corresponding rational canonical form is then $\begin{bmatrix} 0 & 0 & c^3-2c \\ 1 & 0 & 2-3c^2 \\ 0 & 1 & 3c \end{bmatrix}$.

Finally, consider the matrix $C$. Again we use ERCOs to get $xI-C$ in Smith Normal Form. Evidently the following sequence of operations suffices:

1. $R_2 - 3R_4 \rightarrow R_2$
2. $R_3 + 6R_4 \rightarrow R_3$
3. $R_1 + 3R_4 \rightarrow R_1$
4. $\frac{1}{140}R_4 \rightarrow R_4$
5. $R_1 - (x-2)R_4 \rightarrow R_1$
6. $C_2 - \frac{155}{140}C_1 \rightarrow C_2$
7. $C_3 - \frac{5}{140}C_1 \rightarrow C_3$
8. $C_4 - \frac{x-2}{140}C_1 \rightarrow C_4$
9. $\frac{155}{140}R_2 + R_1 \rightarrow R_1$
10. $3C_2 + C_4 \rightarrow C_4$
11. $\frac{5}{140}R_3 + R_1 \rightarrow R_1$
12. $-6C_3 + C_4 \rightarrow C_4$
13. $R_1 \leftrightarrow R_4$
14. $-140R_4 \rightarrow R_4$

Resulting in the matrix $\begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & x-2 & 0 & 0 \\ 0 & 0 & x-2 & 0 \\ 0 & 0 & 0 & (x-2)(x+3) \end{bmatrix}$. The rational canonical form of $C$ is thus $\begin{bmatrix} 2 & 0 & 0 & 0 \\ 0 & 2 & 0 & 0 \\ 0 & 0 & 0 & 6 \\ 0 & 0 & 1 & -1 \end{bmatrix}$.