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.