Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Compute the determinant of a symbolic 5x5 matrix

why does the following script fail to compute the determinant of a 5x5 matrix (same problem appears with larger similar matrices 6x6 and 7x7 matrix too) ?

version();

var ('a,b,c,d,e,f,g,h');

A4 = matrix(SR,4,4,[a,b,c,d,a,a,b,c,a,a,a,b,h,a,a,a]);

A5 = matrix(SR,5,5,[a,b,c,d,e,a,a,b,c,d,a,a,a,b,c,a,a,a,a,b,h,a,a,a,a]);

A4; A4.determinant().expand().factor();

A5; A5.determinant();
A5.determinant().expand().factor();

a spurious "_e" appears in the determinant

'Sage Version 6.5, Release Date: 2015-02-17'
(a, b, c, d, e, f, g, h)
[a b c d]
[a a b c]
[a a a b]
[h a a a]
a^4 - 3*a^3*b + 3*a^2*b^2 - 2*a^2*b*c + a^2*c^2 + a^3*d - a^2*b*d - b^3*h + 2*a*b*c*h - a*c^2*h - a^2*d*h + a*b*d*h
[a b c d e]
[a a b c d]
[a a a b c]
[a a a a b]
[h a a a a]
_e*a^4 + a^5 - 2*_e*a^3*b - 4*a^4*b + _e*a^2*b^2 + 6*a^3*b^2 - 4*a^2*b^3 + 3*a^2*b^2*c - a^3*c^2 - 2*a^2*b*c^2 + a^2*c^3 - 2*a^3*b*d + 2*a^2*b^2*d + 2*a^3*c*d - 2*a^2*b*c*d - _e*a^3*h + 2*_e*a^2*b*h - _e*a*b^2*h + b^4*h - 3*a*b^2*c*h + a^2*c^2*h + 2*a*b*c^2*h - a*c^3*h + 2*a^2*b*d*h - 2*a*b^2*d*h - 2*a^2*c*d*h + 2*a*b*c*d*h
Error in lines 13-19
Traceback (most recent call last):
  File "/projects/cbc78de9-848d-4653-bf96-aa8a68749e86/.sagemathcloud/sage_server.py", line 879, in execute
    exec compile(block+'\n', '', 'single') in namespace, locals
  File "", line 1, in <module>
  File "sage/symbolic/expression.pyx", line 9266, in sage.symbolic.expression.Expression.factor (build/cythonized/sage/symbolic/expression.cpp:45045)
    f = self.polynomial(QQ)
  File "sage/symbolic/expression.pyx", line 5716, in sage.symbolic.expression.Expression.polynomial (build/cythonized/sage/symbolic/expression.cpp:31627)
    return polynomial(self, base_ring=base_ring, ring=ring)
  File "/usr/local/sage/sage-6.5/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 1163, in polynomial
    converter = PolynomialConverter(ex, base_ring=base_ring, ring=ring)
  File "/usr/local/sage/sage-6.5/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 999, in __init__
    self.ring = PolynomialRing(self.base_ring, names=vars)
  File "/usr/local/sage/sage-6.5/local/lib/python2.7/site-packages/sage/rings/polynomial/polynomial_ring_constructor.py", line 477, in PolynomialRing
    R = _multi_variate(base_ring, names, n, sparse, order, implementation)
  File "/usr/local/sage/sage-6.5/local/lib/python2.7/site-packages/sage/rings/polynomial/polynomial_ring_constructor.py", line 564, in _multi_variate
    names = normalize_names(n, names)
  File "sage/structure/parent_gens.pyx", line 207, in sage.structure.parent_gens.normalize_names (build/cythonized/sage/structure/parent_gens.c:2797)
    names = _certify_names(names)
  File "sage/structure/parent_gens.pyx", line 148, in sage.structure.parent_gens._certify_names (build/cythonized/sage/structure/parent_gens.c:2291)
    raise ValueError, "first letter of variable name must be a letter"
ValueError: first letter of variable name must be a letter