I don't frequent this community, so please give criticism if this is a poor question.
I am trying to make a tool which generates a small (say, $4\times 4$) matrix with integer entries, which has a "nice" Jordan normal form — i.e., one that can be computed by hand. The purpose is for manual practice.
Here is what I have:
A := RandomInteger[{-1, 1}, {4, 4}] (*This generates a random 4×4 matrix*)
Dynamic[MatrixForm[A]] (*This is the random matrix*)
Dynamic[MatrixForm[Part[JordanDecomposition[A], 2]]] (*Here is its Jordan Normal form*)
As it is, about $1$ in $10$ of these matrices has relatively nice Jordan Normal form, and that is with random entries of $-1,\,0$, and $1$. Complex eigenvalues are fine, but obviously eigenvalues like Root[#^4 - #^2 + 3 # + 2 &, 1]
are intractable.
The easiest solution here would be to somehow loop the random generator until the entries in the final output are rational complex numbers. I have tried and failed to use conditional statements to achieve this, so any help would be appreciated.
Root[#^4-#^2+3 #+2&, 1]
are intractable? They're perfectly good algebraic constants. TheRoot
representation has nice properties. For example, realRoot
constants don't grow parasitic imaginary parts when evaluated numerically. $\endgroup$