Float error by determinate of mulitvariate polynomial [closed]

asked 2016-07-02 14:37:46 +0200

Syko gravatar image

Hello, 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 is 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.

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by kcrisman
close date 2016-07-03 02:50:56.305112