Bill Allombert on Mon, 24 Feb 2003 17:23:36 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Fast substitutions in Pari


On Sun, Feb 23, 2003 at 12:33:15PM +0100, Franck MICHEL wrote:
> Hi,
> 
> Assume u is a polynomial in x of degree n, and phi is a rational fraction
> in t.
> I would like to transform u to a truncated series in t, i.e:
> - replace x by phi in u; 
> - and expand in t (to the degree n).
> 
> I set seriesprecision to n and use:
> taylor(subst(u,x,phi),t);
> 
> It is very simple; but is it the best way to do it?

Normaly you should rather do
subst(u,x,taylor(phi,t))
If it is slower, then this is probably a inefficiency problem in PARI.


> I've tried to first expand phi in t; and to substitute the series in t into
> the polynomial in x. But it is slower, even if we add an O(t^p) to the
> series in t, with p chosen in function of x^k. Perhaps this kind of
> manipulation is already done by Pari with taylor(subst(u,x,phi),t) and
> there is no need to search to improve it (?)
> 
> Thanks in advance for your advices.

What kind of coefficients phi have ? (integers, rationals, reals ?)

If the coefficients are rationals, try to reduce everything to a common
denominator. The way PARI handle polynomials and formal series with rationals
coefficients is sub-optimal. In fact even if phi has integral coefficients,
the power series development will not, so this may explain the problem.

Cheers, 
Bill.