2

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 ]
diffset
  • 465

1 Answers1

5

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
Max Horn
  • 1,832
  • Thanks. I thought of something like that. But then I changed a:=X(Rationals) to a:=X(Integers) to no avail. Why doesn't that work or, to put it differently, over what ring would a matrix like [[1,0],[0,1]] be? – diffset Mar 19 '20 at 13:10
  • That's over the ring of integers. But in GAP, the integers $\mathbb{Z}$ are not a subset of the polynomial ring $\mathbb{Z}[x]$. Incidentally, they are not in my undergrad course, either: a constant polynomial is not the same as a constant polynomial function is not the same as its constant value (I even point out that the embedding of $\mathbb{Z}$ into $\mathbb{Q}$ strictly speaking is artificial, albeit convenient). – Max Horn Mar 19 '20 at 13:34
  • Makes sense. I hadn't thought of x_1 as a polynomial although you clearly said so in your answer. I had the notion of it being a variable. So is it then the right way to state the problem of a parameter dependent determinant of a matrix? – diffset Mar 19 '20 at 13:47
  • DeterminantMatDivFree works for X(Integers) - there is a suggestion about it in the manual entry for DeterminantMat - enter ?DeterminantMat in GAP to see it. – Olexandr Konovalov Mar 19 '20 at 17:00
  • No, it does not (I actually had DeterminantMatDivFree in the first version of my answer that I never submitted). Also, X(Integers) is identical to X(Rationals). – Max Horn Mar 19 '20 at 17:02
  • DeterminantMatDivFree does work for X(Integers) in the example above. But thanks for pointing out that X(Integers) is identical to X(Rationals) - that explains why it actually works. – Olexandr Konovalov Mar 19 '20 at 17:13
  • @AlexanderKonovalov DeterminantMatDivFree does not work for X(Integers) here… a:=X(Integers);; m:=[[a,0],[0,a]];;DeterminantMatDivFree(m); results in the same error as above.
    
    
    – diffset Mar 20 '20 at 07:13
  • @diffset sorry, was imprecise - I meant that it works in @Max's example, i.e. after One(a); - but then DeterminantMat works too, so it does not make a difference... – Olexandr Konovalov Mar 20 '20 at 08:17