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?
On Tue, 13 Jun 2023 15:55:55 +0000, Vitaly Magerya <vmagerya@gmail.com> said:
VM> Hi, all. I'm trying to expand expressions into series, and I've VM> run into a case which looks broken (with the latest GiNaC): ginsh> series((x+x^2)^2,x,0); VM> (Order(1)^2)*x^(-2)+Order(1) VM> What I expect is Order(1) here, because the expression starts at VM> O(x^2). Note, you will get the expected Order(1) if the expression (x+x^2)^2 would be expended before the series evaluation. Yet we still may consider it as a bug rather tan feature... -- Vladimir V. Kisil http://www1.maths.leeds.ac.uk/~kisilv/ Book: Geometry of Mobius Maps https://doi.org/10.1142/p835 Soft: Geometry of cycles http://moebinv.sourceforge.net/ Jupyter notebooks: https://github.com/vvkisil?tab=repositories
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.
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.
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/>
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.
Wait. Consider a series which terminates in Order(x^n). We don't make any statement about the magnitude or the sign of the constant in front of the Order(x^n) term. Likewise for Order(x)^n. Hence, I think the transformation Order(x)^n -> Order(x^n) is correct, even if n<0. Comments or objections? -richard.
On 24/06/2023, Richard B. Kreckel <kreckel@in.terlu.de> wrote:
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.
Wait.
Consider a series which terminates in Order(x^n). We don't make any statement about the magnitude or the sign of the constant in front of the Order(x^n) term. Likewise for Order(x)^n. Hence, I think the transformation Order(x)^n -> Order(x^n) is correct, even if n<0.
Comments or objections?
If a series A starts with x^n, then the series 1/A *ends*, not starts, with 1/x^n.
If a series A starts with x^n, then the series 1/A *ends*, not starts, with 1/x^n.
OK, sorry, that's not corect. Let me say it differently: series(sin(x)-x, x, 2) == Order(x^2) This does not mean 1/series(sin(x)-x, x, 2) == Order(x^-2), because series(1/(sin(x)-x), x, -2) == -6/x^3 + Order(x^-2)
On 6/24/23 18:15, Vitaly Magerya wrote:
If a series A starts with x^n, then the series 1/A *ends*, not starts, with 1/x^n.
OK, sorry, that's not corect. Let me say it differently:
series(sin(x)-x, x, 2) == Order(x^2)
This does not mean
1/series(sin(x)-x, x, 2) == Order(x^-2),
because
series(1/(sin(x)-x), x, -2) == -6/x^3 + Order(x^-2)
But sin(x)-x starts with (-1/6)*x^3 which is of Order(x^3). -richy.
On 24/06/2023, Richard B. Kreckel <kreckel@in.terlu.de> wrote:
OK, sorry, that's not corect. Let me say it differently:
series(sin(x)-x, x, 2) == Order(x^2)
This does not mean
1/series(sin(x)-x, x, 2) == Order(x^-2),
because
series(1/(sin(x)-x), x, -2) == -6/x^3 + Order(x^-2)
But sin(x)-x starts with (-1/6)*x^3 which is of Order(x^3).
Yes, but series(sin(x)-x,x,2) reports Order(x^2), it does not try figure out the actual first non-zero term. If we take Order(...) to be equivalent to the big-O notation, this makes perfect sense, because f(x)=O(g(x)) only means that f(x) is asymptotically bounded from above by g(x), not necceserily from below, so x^3 is both O(x^3) and O(x^2). In general it would not be practical to require Order(x^n) to mean the big-Omega (i.e. bounded from above and from below), because after the truncation of the series happened, it is no longer possible to figure out if the next term is zero or not without looking at the original expression, so for example while (x + bigO(x^2)) + x^2 = x + bigO(x^2) the same can not be said about big-Omega, (x + bigOmega(x^2)) + x^2 =/= x + bigOmega(x^2) because if the original series that generated "x + bigOmega(x^2)" was actually "x - x^2 + x^7 + ...", then (x + bigOmega(x^2)) + x^2 = x + bigOmega(x^7), but that's not possible to know just by looking at "x + bigOmega(x^2)". So, Order(x^n) must be bigO(x^n), and it should not mean the next non-zero term in the series is x^n, it can be x^(n+1), or higher. This is why 1/(Order(x^n)) is not Order(x^-n), it can be Order(x^(-n-1)), or lower. On 24/06/2023, Richard B. Kreckel <kreckel@in.terlu.de> wrote:
On 6/24/23 18:15, Vitaly Magerya wrote:
If a series A starts with x^n, then the series 1/A *ends*, not starts, with 1/x^n.
OK, sorry, that's not corect. Let me say it differently:
series(sin(x)-x, x, 2) == Order(x^2)
This does not mean
1/series(sin(x)-x, x, 2) == Order(x^-2),
because
series(1/(sin(x)-x), x, -2) == -6/x^3 + Order(x^-2)
But sin(x)-x starts with (-1/6)*x^3 which is of Order(x^3).
-richy.
_______________________________________________ GiNaC-list mailing list GiNaC-list@ginac.de https://www.ginac.de/mailman/listinfo/ginac-list
Dear Vitaly, Thanks for your excellent treatise on the subject! On 6/24/23 19:28, Vitaly Magerya wrote:
This is why
1/(Order(x^n))
is not
Order(x^-n),
it can be
Order(x^(-n-1)),
or lower.
Okay. What would be the correct code for Order_power(x,e), then? What about non-integers? -richy.
On Sat, 24 Jun 2023 20:17:27 +0200, "Richard B. Kreckel" <kreckel@in.terlu.de> said:
RK> Dear Vitaly, Thanks for your excellent treatise on the subject! RK> On 6/24/23 19:28, Vitaly Magerya wrote: >> This is why 1/(Order(x^n)) is not Order(x^-n), it can be >> Order(x^(-n-1)), or lower. RK> Okay. What would be the correct code for Order_power(x,e), RK> then? What about non-integers? I may be missing something, but I do not believe there is a meaningful connection between orders of f(x) and 1/f(x) as big-O. For example, Order(x^k*sin(1/x))=Order(k) at x=0 but Order(x^{-1}/sin(1/x)) is not finite. -- Vladimir V. Kisil http://www1.maths.leeds.ac.uk/~kisilv/ Book: Geometry of Mobius Maps https://doi.org/10.1142/p835 Soft: Geometry of cycles http://moebinv.sourceforge.net/ Jupyter notebooks: https://github.com/vvkisil?tab=repositories
On 6/25/23 19:34, Vladimir V. Kisil wrote:
On Sat, 24 Jun 2023 20:17:27 +0200, "Richard B. Kreckel" <kreckel@in.terlu.de> said:
RK> Dear Vitaly, Thanks for your excellent treatise on the subject!
RK> On 6/24/23 19:28, Vitaly Magerya wrote: >> This is why 1/(Order(x^n)) is not Order(x^-n), it can be >> Order(x^(-n-1)), or lower.
RK> Okay. What would be the correct code for Order_power(x,e), RK> then? What about non-integers?
I may be missing something, but I do not believe there is a meaningful connection between orders of f(x) and 1/f(x) as big-O. For example, Order(x^k*sin(1/x))=Order(k) at x=0 but Order(x^{-1}/sin(1/x)) is not finite.
Now, I may be missing something: Isn't Order(x^k*sin(1/x))==Order(x^k) at x==0? And isn't Order(x^-1)==Order(x)^-1 not finite either but still fine in a Laurent series? -richy. -- Richard B. Kreckel <https://in.terlu.de/~kreckel/>
On Mon, 26 Jun 2023 10:26:55 +0200, "Richard B. Kreckel" <kreckel@in.terlu.de> said: RK> Now, I may be missing something: Isn't RK> Order(x^k*sin(1/x))==Order(x^k) at x==0? And isn't RK> Order(x^-1)==Order(x)^-1 not finite either but still fine in a RK> Laurent series?
I think a lot of confusion is coming because our function Order is not clearly defined. First of all, if we speak on Order(x^4) do we mean the asymptotic behaviour for x→0 or x→∞? For simple cases like series(sin(x),x==0,4) = x-1/6*x^3+Order(x^4) both orders are the same, but this is not true in general. Ginsh answer series(sin(x)+x^10,x==0,4) = 1*x+(-1/6)*x^3+Order(x^4) suggests that we are speaking for x→0 only. Next, either GiNaC::Order() is only meaningful in the context of series expansions of analytic functions or it is a sort of big-O concept? For the latter take f(x) = x^k * ( sin(1/x) +1) +x^m with k > m. Then for x→0 we have f(x) = O(x^k) but 1/f(x) = O(x^{-m}). Finally, if we only consider power expansion of analytic functions then having a zero of an integer order n for f(x) at some point implies that 1/f(x) has a pole of the same order n there. But I am not sure that it will be safe to translate this into some properties of GiNaC::Order(). Currently we have:
series(x^(100),x==0,4); Order(x^4) series(x^(-100),x==0,4); 1*x^(-100)
The root of the issue is that things like Order() are not about identities, they are merely about inequalities—which are not implemented very much in GiNaC presently.. -- Vladimir V. Kisil http://www1.maths.leeds.ac.uk/~kisilv/ Book: Geometry of Mobius Maps https://doi.org/10.1142/p835 Soft: Geometry of cycles http://moebinv.sourceforge.net/ Jupyter notebooks: https://github.com/vvkisil?tab=repositories
Hello, On 6/26/23 11:52, Vladimir V. Kisil wrote:
On Mon, 26 Jun 2023 10:26:55 +0200, "Richard B. Kreckel" <kreckel@in.terlu.de> said: RK> Now, I may be missing something: Isn't RK> Order(x^k*sin(1/x))==Order(x^k) at x==0? And isn't RK> Order(x^-1)==Order(x)^-1 not finite either but still fine in a RK> Laurent series?
I think a lot of confusion is coming because our function Order is not clearly defined. First of all, if we speak on Order(x^4) do we mean the asymptotic behaviour for x→0 or x→∞? For simple cases like series(sin(x),x==0,4) = x-1/6*x^3+Order(x^4) both orders are the same, but this is not true in general. Ginsh answer series(sin(x)+x^10,x==0,4) = 1*x+(-1/6)*x^3+Order(x^4) suggests that we are speaking for x→0 only.
We are speaking about small x, not large. As when we say that e^x is 1+x+O(x^2).
Next, either GiNaC::Order() is only meaningful in the context of series expansions of analytic functions or it is a sort of big-O concept? For the latter take f(x) = x^k * ( sin(1/x) +1) +x^m with k > m. Then for x→0 we have f(x) = O(x^k) but 1/f(x) = O(x^{-m}).
It is intended to be meaningful in the context of dimensional regularization in practical QFT use, i.e. Laurent series expansions.
Finally, if we only consider power expansion of analytic functions then having a zero of an integer order n for f(x) at some point implies that 1/f(x) has a pole of the same order n there. But I am not sure that it will be safe to translate this into some properties of GiNaC::Order(). Currently we have:
series(x^(100),x==0,4); Order(x^4) series(x^(-100),x==0,4); 1*x^(-100)
Which makes sense if we interpret series() as "compute the terms of orders smaller than the x^N term, don't bother about higher orders, but tell so me if you think there are any", no?
The root of the issue is that things like Order() are not about identities, they are merely about inequalities—which are not implemented very much in GiNaC presently..
Well, Vitaly had me convinced that Order(x)^k -> Order(x^k) is useful and safe for integer k > 0. Is it? All my best, -richy. -- Richard B. Kreckel <https://in.terlu.de/~kreckel/>
On Mon, 26 Jun 2023 18:16:19 +0200, "Richard B. Kreckel" <kreckel@in.terlu.de> said:
RK> Well, Vitaly had me convinced that Order(x)^k -> Order(x^k) is RK> useful and safe for integer k > 0. Is it? That seems to be fine for me. -- Vladimir V. Kisil http://www1.maths.leeds.ac.uk/~kisilv/ Book: Geometry of Mobius Maps https://doi.org/10.1142/p835 Soft: Geometry of cycles http://moebinv.sourceforge.net/ Jupyter notebooks: https://github.com/vvkisil?tab=repositories
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?
Please try commit 9435d80ac3. (The evaluation Order(x)^e -> Order(x^e) for positive integer exponents wasn't necessary but we may apply it anyways.) -richy.
On 8/15/23 11:34, Vitaly Magerya wrote:
On 06/08/2023, Richard B. Kreckel <kreckel@in.terlu.de> wrote:
Please try commit 9435d80ac3.
Yup, seems to work now. Thanks a lot!
Hmmm, this stuff is hairy:
series((1+x)^7,x,-2); Order(x^(-14))
-richy. -- Richard B. Kreckel <https://in.terlu.de/~kreckel/>
participants (3)
-
Richard B. Kreckel
-
Vitaly Magerya
-
Vladimir V. Kisil