This question comes up with trying to construct Lie subalgebras of (large) Lie algebras that are invariant under a finite group $H$. I have two isomorphic $H$-invariant nilpotent subalgebras and am interested in the Jordan normal forms of matrices in diagonal subalgebras of these algebras.
I have two commuting nilpotent matrices $A$ and $B$, (dimension 1596, so cannot be just looked at), defined over the field $\mathbb{F}_9$. They both cube to zero, and so $A+\lambda B$ cubes to zero for any $\lambda\in\overline{\mathbb{F}_3}$. I'm interested in the Jordan normal form of the matrix $A+\lambda B$, where $\lambda$ is a parameter.
In all the examples I have so far, if $A$ and $B$ have the same normal form (in the particular case I have in front of me, blocks $3^{285},1^{741}$) then for all but finitely many values of $\lambda$ the blocks of the sum are the same. Furthermore, the number of exceptions to this statement is small, say around $2$.
This could be because my matrices, coming from Lie algebras, are very special. What I really want to know if the following:
Is it true that $A+\lambda B$ has Jordan normal form independent of $\lambda$ for cofinitely many $\lambda$?
Is there a bound on the number of exceptions, say in characteristic $3$ with cube zero matrices?
If $A$ and $B$ are defined over $\mathbb{F}_q$ then do the exceptions lie in a fixed overfield, say $\mathbb{F}_{q^6}$? (I am thinking $6$ because then all quadratics and cubics in $\lambda$ split. I know that one needs at least $\mathbb{F}_{q^2}$ by examples.)
I really want to know that the JNF of $A+\lambda B$ is what I think it should be for most elements of the algebraic closure, leaving only a finite number to check with a computer. I can do finitely many checks, but not infinitely many! Or is there an algorithm that allows us to understand such problems?
I have since found a way to do this, at least in Magma. (Sage should also be able to do it.) Without Ben Grossmann's way of looking at things I definitely would not have thought of doing this, so I thank him. (This is crucial for my research, so I'm very happy!)
Your pencil looks like $A+xB$ for $x$ a variable. Magma (and Sage) is happy to take echelon forms of matrices over a univariate polynomial ring, so let's do that. I've found it might be better to take a Jordan normal form for $B$ first (and of course conjugate $A$) so as to reduce the number of $x$s in the matrix $A+xB$.
Construct the echelon form of $A+xB$. (For $1596 \times 1596$ matrices over $\mathbb{F}_9$, this takes about a minute for my examples). Then take transposes and take echelon form again.
We now have a matrix with zero off the leading diagonal. Take the multiset of diagonal entries. First, the generic rank of $A+xB$, i.e., the rank for almost all values of $x$, is the number of non-zero entries. Second, the points where this is not the rank are given by the zeroes of the polynomials in the set.
If one needs the full Jordan normal form, one now takes $(A+xB)^2$ and so on, uses the recipe above to compute the rank, check that the exceptional set should be a subset of the exceptional set for $A+xB$, and continue taking powers until you obtain the zero matrix.
Sage, but not Magma, is happy to compute multivariate echelon forms, which is now my next case. Can this be done with non-linear pencils? The set of exceptions is now a variety, one assumes, and things will get significantly more complicated.