GAP runs out of memory when factorizing a large determinant?

96 Views Asked by At

I was trying to compute and factorize an 8x8 determinant in 14 variables using the following GAP code:

(after defining the 14 variables x1,..., x14):

N:=[[x1,x2,x3,x6,x7,x8,x11,x12],[x3,x1,x2,x8,x6,x7,x11,x12],[x3,x2,x1,x8,x7,x6,x12,x11],[x2,x3,x1,x7,x8,x6,x11,x12],[x1,x3,x2,x6,x8,x7,x12,x11],[x2,x1,x3,x7,x6,x8,x12,x11],[x4,x4,x4,x9,x9,x9,x13,x13],[x5,x5,x5,x10,x10,x10,x14,x14]];

f:=Determinant(N);

Factors(f);

However at the last step GAP runs out of memory. Is there a way to overcome this and compute the factorization in GAP?

Is there a computer algebra system better suited for this job, maybe MAGMA or SAGE?

Thank you!

2

There are 2 best solutions below

2
On

In Mathematica code

  mat = {{x1, x2, x3, x6, x7, x8, x11, x12}, {x3, x1, x2, x8, x6, 
  x7, x11, x12}, {x3, x2, x1, x8, x7, x6, x12, x11}, {x2, x3, x1, 
  x7, x8,x6, x11, x12}, {x1, x3, x2, x6, x8, x7, x12, x11}, {x2, 
  x1, x3, x7, x6, x8, x12, x11}, {x4, x4, x4, x9, x9, x9, x13, 
  x13}, {x5, x5,x5, x10, x10, x10, x14, x14}};

  res = Det[mat];

  Factor[res]

The resulting expression is

$$-9 \left(x_2 x_6-x_3 x_6-x_1 x_7+x_3 x_7+x_1 x_8-x_2 x_8\right){}^2 \left(x_{11}-x_{12}\right) \left(-3 x_5 x_9 x_{11}+3 x_4 x_{10} x_{11}-3 x_5 x_9 x_{12}+3 x_4 x_{10} x_{12}+2 x_5 x_6 x_{13}+2 x_5 x_7 x_{13}+2 x_5 x_8 x_{13}-2 x_1 x_{10} x_{13}-2 x_2 x_{10} x_{13}-2 x_3 x_{10} x_{13}-2 x_4 x_6 x_{14}-2 x_4 x_7 x_{14}-2 x_4 x_8 x_{14}+2 x_1 x_9 x_{14}+2 x_2 x_9 x_{14}+2 x_3 x_9 x_{14}\right)$$

In GAP, what happens if you change all variable names to single letters?

0
On

In Python code:

from sympy import *

var('x1:15')
N = Matrix([[x1,x2,x3,x6,x7,x8,x11,x12],[x3,x1,x2,x8,x6,x7,x11,x12],[x3,x2,x1,x8,x7,x6,x12,x11],[x2,x3,x1,x7,x8,x6,x11,x12],[x1,x3,x2,x6,x8,x7,x12,x11],[x2,x1,x3,x7,x6,x8,x12,x11],[x4,x4,x4,x9,x9,x9,x13,x13],[x5,x5,x5,x10,x10,x10,x14,x14]])
print('N =', N)
print('det N =', factor(N.det(method='domain-ge')))

The result looks same as Moo's:

N = Matrix([[x1, x2, x3, x6, x7, x8, x11, x12], [x3, x1, x2, x8, x6, x7, x11, x1
2], [x3, x2, x1, x8, x7, x6, x12, x11], [x2, x3, x1, x7, x8, x6, x11, x12], [x1,
 x3, x2, x6, x8, x7, x12, x11], [x2, x1, x3, x7, x6, x8, x12, x11], [x4, x4, x4,
 x9, x9, x9, x13, x13], [x5, x5, x5, x10, x10, x10, x14, x14]])
det N = -9*(x11 - x12)*(x1*x7 - x1*x8 - x2*x6 + x2*x8 + x3*x6 - x3*x7)**2*(-2*x1
*x10*x13 + 2*x1*x14*x9 + 3*x10*x11*x4 + 3*x10*x12*x4 - 2*x10*x13*x2 - 2*x10*x13*
x3 - 3*x11*x5*x9 - 3*x12*x5*x9 + 2*x13*x5*x6 + 2*x13*x5*x7 + 2*x13*x5*x8 + 2*x14
*x2*x9 + 2*x14*x3*x9 - 2*x14*x4*x6 - 2*x14*x4*x7 - 2*x14*x4*x8)

The speed may be dependent on method, e.g. domain-ge is okay but default bareiss doesn't look to work.

See here for details.

Which method does GAP use by default?