# Revision history [back]

Maybe using polynomial elements instead of symbolic variables might work. On sage.math.washington.edu, the polynomial computations are much faster:

sage: var(' '.join(['a%s'%str(i) for i in range(9)]))
(a0, a1, a2, a3, a4, a5, a6, a7, a8)
sage: R = PolynomialRing(QQ, ['x%s' % str(i) for i in range(9)])
sage: R.inject_variables()
Defining x0, x1, x2, x3, x4, x5, x6, x7, x8
sage: A = [a0, a1, a2, a3, a4, a5, a6, a7, a8]
sage: X = [x0, x1, x2, x3, x4, x5, x6, x7, x8]

sage: time d = matrix(6, 6, A + [a^2 for a in A] + [a^3 for a in A] + [a^4 for a in A]).det()
CPU times: user 26.97 s, sys: 0.00 s, total: 26.97 s
Wall time: 27.02 s
sage: time d = matrix(6, 6, X + [a^2 for a in X] + [a^3 for a in X] + [a^4 for a in X]).det()
CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
Wall time: 0.00 s


The 8x8 case takes about 12 seconds with polynomials, and I hesitate to even try it with symbolic variables.

Maybe using polynomial elements instead of symbolic variables might work. On sage.math.washington.edu, the polynomial computations are much faster:

sage: var(' '.join(['a%s'%str(i) for i in range(9)]))
(a0, a1, a2, a3, a4, a5, a6, a7, a8)
sage: R = PolynomialRing(QQ, ['x%s' % str(i) for i in range(9)])
sage: R.inject_variables()
Defining x0, x1, x2, x3, x4, x5, x6, x7, x8
sage: A = [a0, a1, a2, a3, a4, a5, a6, a7, a8]
sage: X = [x0, x1, x2, x3, x4, x5, x6, x7, x8]

sage: time d = matrix(6, 6, A + [a^2 for a in A] + [a^3 for a in A] + [a^4 for a in A]).det()
CPU times: user 26.97 s, sys: 0.00 s, total: 26.97 s
Wall time: 27.02 s
sage: time d = matrix(6, 6, X + [a^2 for a in X] + [a^3 for a in X] + [a^4 for a in X]).det()
CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
Wall time: 0.00 s
sage: timeit('matrix(6, 6, X + [a^2 for a in X] + [a^3 for a in X] + [a^4 for a in X]).det()')
625 loops, best of 3: 1.27 ms per loop


The 8x8 case takes about 12 seconds with polynomials, and I hesitate to even try it with symbolic variables.