The original Sage code from the googlegroups/trac message you link to
doesn't seem to work in current sage any more. I couldn't find a
multivariable power series ring in the reference manual either, but
may not have been looking hard enough.

Doing these computations in Sage generically, seems to take forever.
Actually the raising to the power takes no time, but the inverse
doesn't seem to know what it's doing.

However Pari does them instantly, and we have Pari in Sage..... (But I
only checked the first benchmark in the list and that Pari gave the
right answer for it.)

I don't know if Pari does series reversion or not. I couldn't see it
in the help menu, though I also didn't look hard.

How do the timings for your code compare to Magma. I was confused
about the benchmarks you gave, and couldn't tell which ones were from
your code and which were from elsewhere. I see three columns of
timings. Which ones are yours? I think the first column is from an old
version of Sage as reported on Trac, right? But I didn't understand
the other columns.

I'm curious how you are getting good timings in Pure python? Is it a
new/clever algorithm? How does it fare for longer power series? Are
there even good algorithms that are asymptotically fast for these
sorts of problems? And can some of these be reduced to ordinary
multivariate polynomial computations?

Bill.

On 29 July, 15:26, mario <mario.pern...@gmail.com> wrote:
> 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 
> inhttp://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