Let's say I have the minimal polynomial and characteristic polynomial of a matrix and all its invariant factor compositions. How do I get a rational canonical form matrix from this?
How to Derive Rational Canonical Form from Polynomials
abstract-algebralinear algebramatrices
Related Solutions
If $A\in M_3$ has one eigenvalue $a$, then its characteristic polynomial is $(x-a)^3$, and its minimal polynomial is $x-a$, $(x-a)^2$, or $(x-a)^3$. The only corresponding possibilities for Jordan form are, respectively, 3 blocks of size 1 ($A=aI$), a block of size 2 and hence another of size 1, and one block of size 3. Similarly, the possibilities are determined if there is more than one eigenvalue.
In $M_4$, consider the matrices $\begin{bmatrix}0 & 1 & 0 & 0\\ 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 1\\0 & 0 & 0 & 0\end{bmatrix}$ and $\begin{bmatrix}0 & 1 & 0 & 0\\ 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0\\0 & 0 & 0 & 0\end{bmatrix}$.
From the characteristic polynomial $(x-a_1)^{n_1}\cdots (x-a_k)^{n_k}$ of a matrix $A\in M_n$ with distinct eigenvalues $a_1,\ldots,a_k$, you can see that the Jordan blocks for the eigenvalue $a_j$ have to have sizes adding to $n_j$. The largest size of one of these blocks is the exponent of $(x-a_j)$ appearing in the minimal polynomial of $A$. In case $n_j=3$, the only sizes possible for the blocks are $1+1+1$, $2+1$, and $3$, so the highest size of a block (the exponent in the minimal polynomial) determines the decomposition for $a_j$. If $n_j=2$ you have $1+1$ and $2$ as possible Jordan structure, so again it is determined by the largest size of a block. But when $n_j>3$, there are always decompositions like $2+2+[n-4\text{ ones}]$ and $2+1+1+[n-4\text{ ones}]$ which have the same largest size block (same exponent in the minimal polynomial), but are different Jordan forms.
About your proof. The "only if" ($\Rightarrow$) direction is quite simple. The characteristic polynomial is (as you say) the product of the invariant factors, and the minimal polynomial is similarly the largest invariant factor; both then are determined by the rational canonical form (RCF). So your work for the minimal polynomial is not really needed; moreover it seems to go off in an completely wrong direction (what is the point of focussing on a single root $\lambda$ in $F$ of the characteristic polynomial, which you don't even know exists?), and I cannot follow much of it.
Your proof of the "if" direction is entirely wrong. The characteristic polynomial is certainly not the same as the RCF (they aren't even the same kind of thing), and matrices with the same characteristic polynomials can very well not be similar (for instance one could be diagonalisable but the other not), ever for the $3\times3$ case.
What you do know is that the characteristic polynomial is the product of the invariant factors, and the minimal polynomial is largest of them (which all the others divide). From this one cannot in general conclude that all invariant factors must correspond (so that the matrices will be similar), but now the $3\times3$ condition comes to the rescue. This means the characteristic polynomial$~\chi$ has degree$~3$, and this makes it impossible to obtain equal minimal polynomials yet distinct invariant factors. To be precise, if the common minimal polynomial$~\mu$ has degree at least$~2$, then any remaining invariant factors have as product the quotient $\chi/\mu$ which has degree $1$ at most; either (if $\deg \chi/\mu=0$) there are no other invariant factors, or (if $\deg \chi/\mu=1$) there is one remaining invariant equal to $\chi/\mu$. But this leaves only the case $\deg\mu=1$, in which case the remaining invariant factors must all be monic polynomials dividing$~\mu$, which forces them to be equal to$~\mu$.
A similar argument for the $4\times4$ or larger cases fails. For $n=4$, one could have $\deg\mu=2$ and then the remaining factor $\chi/\mu$ of degree $2$ could either itself be$~\mu$, or could split into two identical invariant factors of degree$~1$. For such a minimal counterexample one needs $\chi$ to be of the form $(X-\lambda)^4$ and $\mu=(X-\lambda)^2$; then the remaining invariant factors are either $(X-\lambda)^2$ or twice $X-\lambda$. You can see here an example where this happens (with $\lambda=0$).
Best Answer
For a matrix $A$ the invariant factors are determined by finding the Smith canonical form equivalent to $(xI - A)$. Let's say $$S(x) = \text{Dg}[1,\ldots,1,f_1(x),\ldots,f_k(x)]$$ is the Smith canonical form. As mentioned elsewhere $f_1(x),f_2(x),\ldots,f_k(x)$ are all monic and each lower index monic polynomial divides the following. These are the invariant factors. (Also note that $f_k(x)$ is the minimum polynomial)
Now, it is true that $A$ is similar to Dg$[C(f_1(x)),\ldots,C(f_k(x))]$ where $C(f_i(x))$ indicates the companion matrix associated with $f_i(x)$, but this is not the Rational Canonical Form, to the best of my knowledge, not according to my textbook anyway.
The rational canonical form is derived by finding the elementary divisors of $A$. Take any invariant factor $f_i(x)$, then we can write it as $p_1(x)^{ei1}p_2(x)^{ei2}\ldots p_t(x)^{eit}$ where the $p_i(x)$ are distinct, monic and irreducible. These are then the elementary divisors of $A$. The rational canonical form is constructed from these elementary divisors as $$\text{Dg}[\ldots,H(p_1(x)^{ei1}),H(p_2(x)^{ei2}),\ldots,H(p_t(x)^{eit}),\ldots]$$ where $$H(p(x)^e) = \begin{bmatrix} C(p(x)) & 0 & \cdots & 0 & 0 \\ N & C(p(x)) & \cdots & 0 & 0 \\ \vdots & & & & \vdots \\ 0 & 0 & \cdots & N & C(p(x)) \end{bmatrix}.$$ Here $N$ is a matrix that is all zero except for a 1 in the upper right hand corner, and the companion matrix $C(p(x))$ is repeated $e$ times. This is known as a hypercompanion matrix. Note that the rational canonical form reduces to Jordan canonical form when the field is algebraically closed.
Let's look at an example: suppose you have invariant factors $f_1(x) = (x^2 + 4)(x^2 - 3)$ and $f_2(x) = (x^2 + 4)^2(x^2 - 3)^2$, and suppose the field we are considering is $\mathbb{Q}$. Then the elementary divisors are $(x^2 + 4),(x^2 - 3),(x^2 + 4)^2$ and $(x^2 - 3)^2$ and so the rational canonical form is $$\text{Dg}\left [ \begin{bmatrix}0&-4\\1&0 \end{bmatrix}, \begin{bmatrix}0&3\\1&0 \end{bmatrix},\begin{bmatrix}0&-4&0&0\\1&0&0&0\\0&1&0&-4\\0&0&1&0 \end{bmatrix},\begin{bmatrix}0&3&0&0\\1&0&0&0\\0&1&0&3\\0&0&1&0 \end{bmatrix}\right ].$$
My source material for this theory: CG Cullen, Matrices and linear transformations (2nd edition), the chapter named: Similarity: Part II. There are more examples and in-depth discussion there...