Hello,
I started rmpoly (http://code.google.com/p/rmpoly/),
a pure Python library for multivariate polynomials and power series on
QQ.

I tried the benchmarks on series truncated with the total degree in
http://www.mail-archive.com/sage-t...@googlegroups.com/msg42090.html
MPowerSeriesRing (MSR) with Intel(R) Xeon(R) CPU  X7460  @ 2.66GHz
rmpoly with Intel Core2 Quad Q8200  2.33GHz
  Python2.7, gmpy.mpq (left), Sage 4.0.1, Rational (right)

  seconds
MSR   rmpoly      expression
3.18  0.58  1.24  (1 + 2*a + 3*b + 4*d + L(0).O(16))^-5
0.02  0.01  0.01  (1 + a^3 + b^3 + c^4 + d^4 + L(0).O(15))^-20
0.16  0.07  0.12  (-1/6*b^6*d^14 - 1/9*a^4*b^10*c^4*d^12 +...+
L(0).O(50))^20
12.7  0.57  1.21  (1 + 1/2*a + 3*b + 4*a*b + ... + Z(0).O(30))^-20
0.05  0.001 0.002 (1+a^14*b^9+8/3*a^22*b^11-...+Z(0).O(51))^-20
1.9   0.4   1.03  (1 + a + b + a*b + a^2 + b^2 + Z(0).O(30))^-20
2.78  0.42  1.09  (1 + a + 2*b - a*b + 3*a^2 - b^2 + Z(0).O(30))^-20
3.14  0.42  1.10  (1+a+12*b-10*a*b+13*a^2-7*b^2+Z(0).O(30))^-20

I do not know how to get and run the code multi_power_series from
trac,
so I put the times for MPowerSeriesRing from the link above.

The Sage version of rmpoly is obtained essentially replacing int with
Integer in the Python version. Here is the code for the first
benchmark

load "rmpoly.sage"
rp = RPoly(['d','c','b','a'], 10,Rational,'grlex')
d,c,b,a = rp.gens()

# (1 + 2*a + 3*b + 4*d + L(0).O(16))^-5
p = 1 + 2*a + 3*b + 4*d
n = 16
# n grlex order the variable _t carries the total degree
p = p.series_inversion('_t',n)
p = p.pow_trunc(5,'_t',n)
print p

Notice that the Python version of rmpoly is faster than its Sage
version.
I guess that cythonizing rmpoly.sage it would become roughly as
fast as the Python version.

rmpoly deals also with series with O(a^na*b*nb*c^nc*d^nd)
e.g. with p.pow_trunc(k,['a','b','c','d'],[na,nb,nc,nd])
It has multivariate series reversion: here is an example

rp = RPoly(['w','z','y','x'],10,Rational)
w,z,y,x = rp.gens()
p = x*(2 + y^2 + z) + x^2*(1+y+z^6) + x^6*(5+y^6+z)
n = nx=ny=nz=7
p1 = p.series_reversion2('x',nx,['y','z'],[ny,nz],'w')

# check that p in x=p1 is equal to w + O(w^nx*y^ny*z^nz)
sb = Subs(rp,rp,{'x':p1})
p2 = sb.subs_trunc(p,['w','y','z'],[nx,ny,nz])
assert p2 == w

The reversion takes 0.7s

I would like to know if there is an interest in including
rmpoly.sage in Sage as a possible way of computing with power series

Mario

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to