[GiNaC-list] series((x+x^2)^2,x,0) is broken

Richard B. Kreckel kreckel at in.terlu.de
Thu Jun 22 21:19:57 CEST 2023


Dear Vitaly,

On 6/13/23 17:55, Vitaly Magerya wrote:
> Hi, all. I'm trying to expand expressions into series, and I've
> run into a case which looks broken (with the latest GiNaC):
> 
>      ginsh> series((x+x^2)^2,x,0);
>      (Order(1)^2)*x^(-2)+Order(1)
> 
> What I expect is Order(1) here, because the expression starts
> at O(x^2).
> 
> Same problem with e.g. (x+sin(x))^2, and lots of other expressions.
> It seems that any non-trivial expression that starts at O(x)
> or higher to a power expands into this sort of an unhelpful
> result.
> 
> Note that trying to remove the Order() parts does not work:
> 
>      ginsh> series_to_poly(series((x+x^2)^2,x,0));
>      x^(-2)*Order(1)^2
> 
> What I expect here is "0" instead.
> 
> Any ideas on what's going on and how to fix it?

For one thing, I suppose that the Order(x) function is missing a power 
evaluation of the kind Order(x)^e -> Order(x^e). Does this sound right?

The attached patch adds this. It solves some of your problems but not 
all. It doesn't seem to introduce regressions. Can you test this, please?

But there's something else fishy going on in pseries::power_const(p, deg).

All my best,
   -richy.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: add_Order_power_func.patch
Type: text/x-patch
Size: 908 bytes
Desc: not available
URL: <http://www.ginac.de/pipermail/ginac-list/attachments/20230622/2410f429/attachment.bin>


More information about the GiNaC-list mailing list