Code : Tout sélectionner
from giacpy import giac, gbasis
from time import clock, time
#katsura n, change n as pleased..
n=9
x=[]
ideal=[]
for i in xrange(n+1):
s= "x" + str(i)
x.append(giac(s))
# x_0 + 2\sum_{i=1}^n x_i = 1
f=x[0]
for i in xrange(1,n+1):
f += 2*x[i]
ideal.append(f-1)
# \sum_{j=-n}^{n-i} x_{|j|}x_{|j+i|} = x_{i} \qquad i=0,\dots,n-1
for i in xrange(n):
f=-x[i]
for j in xrange(-n,n-i+1):
f += x[abs(j)]*x[abs(j+i)]
ideal.append(f.regroup())
print ideal
"""
For katsura 9, ideal =
[x0+2*x1+2*x2+2*x3+2*x4+2*x5+2*x6+2*x7+2*x8+2*x9-1, x0**2+2*x1**2+2*x2**2+2*x3**2+2*x4**2+2*x5**2+2*x6**2+2*x7**2+2*x8**2+2*x9**2-x0, 2*x0*x1+2*x1*x2+2*x2*x3+2*x3*x4+2*x4*x5+2*x5*x6+2*x6*x7+2*x7*x8+2*x8*x9-x1, x1**2+2*x0*x2+2*x1*x3+2*x2*x4+2*x3*x5+2*x4*x6+2*x5*x7+2*x6*x8+2*x7*x9-x2, 2*x0*x3+2*x1*x2+2*x1*x4+2*x2*x5+2*x3*x6+2*x4*x7+2*x5*x8+2*x6*x9-x3, x2**2+2*x0*x4+2*x1*x3+2*x1*x5+2*x2*x6+2*x3*x7+2*x4*x8+2*x5*x9-x4, 2*x0*x5+2*x1*x4+2*x1*x6+2*x2*x3+2*x2*x7+2*x3*x8+2*x4*x9-x5, x3**2+2*x0*x6+2*x1*x5+2*x1*x7+2*x2*x4+2*x2*x8+2*x3*x9-x6, 2*x0*x7+2*x1*x6+2*x1*x8+2*x2*x5+2*x2*x9+2*x3*x4-x7, x4**2+2*x0*x8+2*x1*x7+2*x1*x9+2*x2*x6+2*x3*x5-x8]
"""
#start = clock() #for windows
start = time() # for linux
gbasis(ideal,x)
#print clock()-start, "seconds used"
print time()-start, "seconds used"
Code : Tout sélectionner
Running a probabilistic check for the reconstructed Groebner basis. If successfull, error probability is less than 1e-15 and is estimated to be less than 10^-147. Use proba_epsilon:=0 to certify (this takes more time).
// Groebner basis computation time 9.77126 Memory 122.604M
Evaluation time: 9.91
3.29461288452 seconds used
It does help to understand this, because I am trying to make a modern Benchmark for Groebner basis with different computer algebra systems and I am very confident that giac has one of the top Groebner engine (at least for Katsura 9).
Jose