Cayley-Hamilton in Macaulay2

95 Views Asked by At

The question arose in a more complicated situation - but this simple example will illustrate my difficulty. Suppose I want to use Macaulay2 to check the Cayley-Hamilton theorem for matrices of some fixed size, say $2\times 2$. The following is straightforward enough:

R=QQ[a_{1,1}..a_{2,2}, x];

A=matrix{{a_{1,1}, a_{1,2}}, {a_{2,1},a_{2,2}}};

I=matrix{{1_R,0},{0,1_R}};

det(x*I-A)

giving the char poly. Now I can do

ch = z-> det(z*I-A);

and can evaluate the characteristic polynomial at any element of R. Macaulay2 even accepts

ch A

and returns zero. However, at this point I believe macaulay2 performs the "fresh(wo)man's mistake" proof of Cayley-Hamilton: it computes det(A-A) instead of ch A as a matrix, evidenced by the fact that it returns a value not a matrix (this can also be checked by introducing another matrix).

How could I use Macaulay2 to set up a function ch on $2\times 2$ matrices, such that ch A returns the $2\times 2$ zero matrix, and more generally ch B for an arbitrary 2x2 matrix returns the $2\times 2$ matrix which is the result of evaluation on B of the char poly of A?