Gap: Determinant with Indeterminate()

gap

This is probably very easy but can't figure it out. How can I compute
the determininant of a matrix with indeterminate entries in it?

gap> a:=X(Rationals);
x_1
gap> m:=[[a,0],[0,a]];
[ [ x_1, 0 ], [ 0, x_1 ] ]
gap> DeterminantMat(m);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `DeterminantMat' on 1 arguments at /usr/src/gap-4.10.2/lib/methsel2.g:250 called from
<function "HANDLE_METHOD_NOT_FOUND">( <arguments> )
 called from read-eval loop at *stdin*:23
type 'quit;' to quit to outer loop
brk> 

I would have expected the answer to be
x_1^2.
Needless to say that DeterminantMat(m) works as expected when there are no indeterminates in m as does

gap> RootsOfPolynomial(a^2+2*a+1);
[ -1, -1 ]

Best Answer

Your problem is that the matrix m is not actually a matrix in the GAP sense, where it is required that all entries live in the same ring: but you are mixing integers with polynomials here. To fix this, you can replace the 0 entries by Zero(a); or just multiply the whole matrix with the 1 polynomial.

gap> a:=X(Rationals);
x_1
gap> m:=[[a,0],[0,a]];
[ [ x_1, 0 ], [ 0, x_1 ] ]
gap> IsMatrix(m);
false
gap> m:=[[a,0],[0,a]] * One(a);
[ [ x_1, 0 ], [ 0, x_1 ] ]
gap> IsMatrix(m);
true
gap> DeterminantMat(m);
x_1^2
Related Question