Bill Allombert on Sun, 15 Jan 2023 10:20:41 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: The companion matrix of a polynomial.


On Sun, Jan 15, 2023 at 09:12:07AM +0800, Hongyi Zhao wrote:
> On Sat, Jan 14, 2023 at 9:58 PM Charles Greathouse
> <crgreathouse@gmail.com> wrote:
> >
> > I'm not at all sure what you're doing here. The GAP source
> > https://github.com/gap-system/gap/blob/3d47e2bc40869ea1b232a0a658d47b1897880fec/lib/upolyirr.gi#L82
> > seems to require that the input to CompanionMat be a polynomial or a list of coefficients of a polynomial. It doesn't seem like it can do anything meaningful to a matrix.
> 
> I want to get the companion matrix of matrix A in GP, which can be
> generated in GAP, as shown below:

> gap> A:=[[-1,3,-1,0,-2,0,0,-2],
> > [-1,-1,1,1,-2,-1,0,-1],
> > [-2,-6,4,3,-8,-4,-2,1],
> > [-1,8,-3,-1,5,2,3,-3],
> > [0,0,0,0,0,0,0,1],
> > [0,0,0,0,-1,0,0,0],
> > [1,0,0,0,2,0,0,0],
> > [0,0,0,0,4,0,1,0]];;
> gap> P:=RationalCanonicalFormTransform(A);;
> gap> C:=A^P;
> [ [ 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 1, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0,
> 0, 0, 0, 0, -1 ], [ 0, 0, 1, 0, 0, 0, 0, -4 ],
>   [ 0, 0, 0, 1, 0, 0, 0, -4 ], [ 0, 0, 0, 0, 1, 0, 0, 2 ], [ 0, 0, 0,
> 0, 0, 1, 0, 4 ], [ 0, 0, 0, 0, 0, 0, 1, 0 ] ]

This is the rational canonical form (aka the Frobenius form), not the companion matrix.
In GP, it is matfrobenius. There is a flag to the the transform. Read the doc.

Cheers,
Bill.