Ask Your Question

Wrong determinant of matrix based on multivariate polynomial ring

asked 2016-07-02 07:46:33 -0500

Syko gravatar image

Hello everybody,

I have a problem with determinants of matrices based on multivariate polynomial rings. I have tried tor reduce the problem to the follwing small code snippet. When I input the following code:

n = 6
U = Matrix(RDF, n, n)
for i in range(0, n):
    for j in range(0, n):
        U[i,j]= sqrt(2)/sqrt(n+1)* sin((i+1)*(j+1)*pi/(n+1))
X = Matrix(RDF, n, n) 
for i in range(0, n):
    X[i,i] = cos((i+1)*pi/(n+1))
X = U*X*U
R.<x,y> = PolynomialRing(RDF)
print p

The result is

x^6 - 2.2044751821*x^4 - 1.68101310152*x^3 - 1.49183182734e+14*x^2 - 3.3692293675e+15*x - 3.0080295919e+29

This is completely wrong. The matrix X contains small flouting point precision error, which however should not prodcue the above result. Due to my original problem I used a polynomial ring with two variables, which seems to be the source of the problem.

For example, when in the above code I use R.<x> = PolynomialRing(RDF), i.e. a polynomial ring with only one variable, the result is

x^6 - 6.138786581930816e-16*x^5 - 1.2499999999999987*x^4 + 4.1216962026573156e-16*x^3 + 0.37499999999999956*x^2 - 4.226292066148934e-17*x - 0.015624999999999944

which is the correct result (up to precision errors).

By the way, the correct result without precision errors is

1.0*x^6 - 1.25*x^4 + 0.375*x^2 - 0.015625

Anybody knows what is going wrong? Thank you in advance.

By the way, I am using the Standard Windows Sage 7.0 Binary: "sage-7.0.ova".

edit retag flag offensive close merge delete


If I change the ring RDF to RR, the result is

2.25179981368525e15*x^3 + 1.01412048018259e31*x^2 + 4.56719261665908e46*x + 2.05688069665151e62

which is also wrong (and interestingly differently wrong).

To me it seems that there is a bug in Sage. Should a "bug ticket" posted in another forum?

Syko gravatar imageSyko ( 2016-07-04 11:17:02 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2016-07-03 22:13:26 -0500

calc314 gravatar image

updated 2016-07-04 19:30:14 -0500

I'm not sure what's going on, but using RDF is causing Sage on Sage Math Cloud to crash.

If I use RR, the result is correct up to precision errors.

Here is the error with RDF. This happens after the polynomial ring is declared.

Error in lines 3-3
Traceback (most recent call last):
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/smc_sagews/", line 905, in execute
    exec compile(block+'\n', '', 'single') in namespace, locals
  File "", line 1, in <module>
  File "sage/matrix/matrix_mpolynomial_dense.pyx", line 552, in sage.matrix.matrix_mpolynomial_dense.Matrix_mpolynomial_dense.determinant (/projects/sage/sage-6.10/src/build/cythonized/sage/matrix/matrix_mpolynomial_dense.cpp:6979)
    d = R(self._singular_().det())
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/interfaces/", line 632, in __call__
    return self._obj.parent().function_call(self._name, [self._obj] + list(args), kwds)
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/interfaces/", line 533, in function_call
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/interfaces/", line 308, in new
    return self(code)
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/interfaces/", line 788, in __call__
    return SingularElement(self, type, x, False)
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/interfaces/", line 1266, in __init__
    raise_(TypeError, x, sys.exc_info()[2])
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/interfaces/", line 1261, in __init__
    self._name = parent._create( value, type)
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/interfaces/", line 749, in _create
    self.set(type, name, value)
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/interfaces/", line 692, in set
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/interfaces/", line 650, in eval
    raise SingularError('Singular error:\n%s'%s)
TypeError: Singular error:
Singular : signal 11 (v: 3170):
current line:>><<
Segment fault/Bus error occurred at 7f7b2025d3b0 because of 10206 (r:296942099)
please inform the authors
trying to restart...

The code actually works fine if you avoid declaring the polynomial ring.

edit flag offensive delete link more


Interesting, what is the error message ?

tmonteil gravatar imagetmonteil ( 2016-07-04 04:32:28 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-07-02 07:40:12 -0500

Seen: 68 times

Last updated: Jul 04 '16