Hi. As you know, this now works fine in Sage-2.9.1, since Mike Hanson
and Robert Bradshaw wrote a special symbolic matrix class:
sage: var('a b c d e f g')
sage: V=[a,b,c,d,e,f,g]
sage: M=matrix(SR,7,7,[[z^i for i in range(7)] for z in V])
sage: time w=det(M)
Time: CPU 6.57 s, Wall: 9.87 s
However, it's very interesting to note that you can do exactly the
same calculation _vastly_ more quickly using the specialized
"multivariate polynomial ring over the rational numbers" functionality
in Sage (which partly comes from Singular, by the way):
sage: R.<a,b,c,d,e,f,g> = QQ[]
sage: V=[a,b,c,d,e,f,g]
sage: M=matrix(R,7,7,[[z^i for i in range(7)] for z in V])
sage: time w=det(M)
Time: CPU 0.02 s, Wall: 0.02 s
sage: str(w)[:50]
'-a^6*b^5*c^4*d^3*e^2*f + a^5*b^6*c^4*d^3*e^2*f + a'
William
> However, it's very interesting to note that you can do exactly the
> same calculation _vastly_ more quickly using the specialized
> "multivariate polynomial ring over the rational numbers" functionality
> in Sage (which partly comes from Singular, by the way):
>
> sage: R.<a,b,c,d,e,f,g> = QQ[]
> sage: V=[a,b,c,d,e,f,g]
> sage: M=matrix(R,7,7,[[z^i for i in range(7)] for z in V])
> sage: time w=det(M)
> Time: CPU 0.02 s, Wall: 0.02 s
> sage: str(w)[:50]
> '-a^6*b^5*c^4*d^3*e^2*f + a^5*b^6*c^4*d^3*e^2*f + a'
>
sage: time p = M.permanent()
CPU times: user 4.56 s, sys: 0.40 s, total: 4.96 s
Wall time: 5.01
sage: str(p)[:46]
'a^6*b^5*c^4*d^3*e^2*f + a^5*b^6*c^4*d^3*e^2*f '
Notice the difference :)
When I change QQ in ZZ it goes *boom*! Memory usage to 99% and more.
Why?
Jaap
Sage has very optimized multivariate polynomial arithmetic over QQ.
It has very very slow arithmetic over ZZ. This is temporary, and
has been temporary
for about 6 months now, which is why I think we should just do some hack to
make polys over ZZ actually use polys over QQ as their underlying
implementation,
at least until libsingular supports ZZ.
-- William