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

Vitaly Magerya vmagerya at gmail.com
Fri Jun 23 12:28:54 CEST 2023


> 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?

Thanks for looking into this.

The substitution above is not correct if e<0. For example:

    x = Order(1/A) => |x| <= Const * 1/A

but

    x = 1/Order(A) => |x| >= 1 / (Const * A)

so

    Order(1/A) =/= 1/Order(A)

It is correct for non-negative integer e though.

> 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?

I guess

    ginsh> series((x+x^2)^2,x,0);
    Order(x^(-2))

is preferable to

    (Order(1)^2)*x^(-2)+Order(1)

but it is still incorrect and not that helpful: I'm asking for
the expansion up to x^0, not x^-2.

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

Seems so.

* * *

On a bit of a tangential topic: I think the fact that Order(x^0)
is simplified to Order(1) is a bad design choice, because the
variable in which the expansion was made is lost. This leads to
all kinds of special cases if one wants to work with series;
e.g.

    Order(x^n)*x can be simplified to Order(x^(n+1)),

but

    Order(1)*x can no longer be Order(x).

Similarly,

    Order(x) + Order(x^2) = Order(x),

but

    Order(1) + Order(x) =/= Order(1),

because Order(1) could have been Order(othervar^0).

I'd much rather have Order() to have the variable and the exponent
separately, i.e. Order(x, 0) instead of Order(1). This is a
separate question though.


More information about the GiNaC-list mailing list