# Compute rational canonical form of a given matrix

I feel like I am going around in circles in trying to find out HOW to compute the rational canonical form. Everywhere I look has gaps in explanation, making it impossible to follow. I am working out of Dummit & Foote:

RCF is defined as the matrix with the companion matrices of each invariant factor going down the diagonal blocks. So, I look up what invariant factors are defined as.

Definition The invariant factors of an $n \times n$ matrix over a field $F$ are the invariant factors of its rational canonical form.

I hope you can see my confusion/frustration from this, and I was hoping someone could help explain how to compute rational canonical form, or at least how to compute the invariant factors.

Finding the rational form is the same as finding the invariant factors. This is done by taking the matrix $xI-A$ and preforming a series of row and column operations to reduce it to Smith normal form, the invariant factors are then the diagonal entries.