## Compute all the matrices having a given characteristic polynomial

Find all the possible rational canonical forms of matrices having characteristic polynomial $c(x) = x^2(x^2+1)^2$.

Let $F$ be a field. Our solution depends on how the polynomial $x^2+1$ factors over $F$.

Suppose $x^2+1$ is irreducible in $F$. (For instance, in $\mathbb{Q}$ or $\mathbb{Z}/(3)$.) If $A$ is a matrix with characteristic polynomial $c(x)$, then the minimal polynomial of $A$ must divide $c(x)$ and be divisible by $x$ and by $x^2+1$. There are four such divisors, and with the minimal polynomial chosen, in each case the remaining invariant factors are determined. These are as follows.

1. $x(x^2+1)$, $x(x^2+1)$
2. $x$, $x(x^2+1)^2$
3. $x^2+1$, $x^2(x^2+1)$
4. $x^2(x^2+1)^2$

The corresponding rational canonical forms are as follows.

1. $\begin{bmatrix} 0 & 0 & 0 & 0 & 0 & 0 \\ 1 & 0 & -1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & -1 \\ 0 & 0 & 0 & 0 & 1 & 0 \end{bmatrix}$
2. $\begin{bmatrix} 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & -1 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & -2 \\ 0 & 0 & 0 & 0 & 1 & 0 \end{bmatrix}$
3. $\begin{bmatrix} 0 & -1 & 0 & 0 & 0 & 0 \\ 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & -1 \\ 0 & 0 & 0 & 0 & 1 & 0 \end{bmatrix}$
4. $\begin{bmatrix} 0 & 0 & 0 & 0 & 0 & 0 \\ 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & -1 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & -2 \\ 0 & 0 & 0 & 0 & 1 & 0 \end{bmatrix}$

Every $6 \times 6$ matrix over $F$ whose characteristic polynomial is $c(x)$ is similar to exactly one matrix on this list.

Now suppose $x^2+1$ factors over $\varepsilon$ in $F$. (For instance, in $\mathbb{C}$ or $\mathbb{Z}/(5)$.) Since $x^2+1$ has degree 2, there is only one way this can happen- namely, $F$ contains both roots of $x^2+1$. If these roots are called $\varepsilon$ and $\eta$, then comparing coefficients in $(x-\eta)(x-\varepsilon) = x^2+1$, we see that $-\eta = \varepsilon$. Now the irreducible factorization of $c(x)$ over $F$ is $c(x) = x^2(x-\eta)^2(x+\eta)^2$. Now if $A$ is a matrix with characteristic polynomial $c(x)$, then the minimal polynomial of $A$ must divide $c(x)$ and is divisible by $x(x-\eta)(x+\eta)$. There are eight such divisors of $c(x)$, and for each choice of the minimal polynomial, the remaining invariant factors are determined. The possible lists of invariant factors for $A$ are as follows.

1. $x(x-\eta)(x+\eta)$, $x(x-\eta)(x+\eta)$
2. $(x-\eta)(x+\eta)$, $x^2(x-\eta)(x+\eta)$
3. $x(x+\eta)$, $x(x-\eta)^2(x+\eta)$
4. $x(x-\eta)$, $x(x-\eta)(x+\eta)^2$
5. $x$, $x(x-\eta)^2(x+\eta)^2$
6. $x-\eta$, $x^2(x-\eta)(x+\eta)^2$
7. $x+\eta$, $x^2(x-\eta)^2(x+\eta)$
8. $x^2(x-\eta)^2(x+\eta)^2$

The corresponding rational canonical form matrices are as follows.

1. $\begin{bmatrix} 0 & 0 & 0 & 0 & 0 & 0 \\ 1 & 0 & -1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & -1 \\ 0 & 0 & 0 & 0 & 1 & 0 \end{bmatrix}$
2. $\begin{bmatrix} 0 & -1 & 0 & 0 & 0 & 0 \\ 1 & 0 & 0 & 0 & 0 & 0 \\ 0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 & 0 & 0 \\ 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & -1 \\ 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & -2 \\ 0 & 0 & 0 & 0 & 1 & 0 \end{bmatrix}$

Every $6 \times 6$ matrix over $F$ having characteristic polynomial $c(x)$ is similar to exactly one matrix in this list.