On 6/23/23 12:28, Vitaly Magerya wrote:
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.
Right. Thanks for pointing this out!
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.
That's right. The implementation in pseries::power_const(p, deg) does not pay proper attention to loop boundaries. That should be reworked. This is also the cause why series((x+x^2)^2,x,42) returns an Order(x^42) term which it should not. If you want to take a look, go ahead. I don't know if I'll find the time soon.
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.
Hmmm. -richy. -- Richard B. Kreckel <https://in.terlu.de/~kreckel/>