Re: [sage-devel] Re: Product of two expressions that causes hang
BTW, that "magic" commit also fixes #25252. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Re: Product of two expressions that causes hang
On Thursday, April 26, 2018 at 2:55:49 PM UTC+2, Erik Bray wrote: > > Thanks for checking! Wow, I would not have guessed that. Do you have > any idea if problem is fixed in general, or just in that one case? > I have no idea what the general problem is (except that mul::eval is prone to loops). -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Re: Product of two expressions that causes hang
Thanks for checking! Wow, I would not have guessed that. Do you have any idea if problem is fixed in general, or just in that one case? It's not immediately obvious to me how this fixes it. I'll open a ticket either way. On Wed, Apr 25, 2018 at 2:51 PM, Ralf Stephan wrote: > By bisection I find the issue is fixed with the commit > https://github.com/pynac/pynac/commit/c4b2a4a42c6f01f0db6c3d54d493a049806e > which fixes a power problem and apparently prevents the extraction of 2 > mentioned earlier. > > Anyway please open a ticket for the doctest. > > Regards, > > -- > You received this message because you are subscribed to the Google Groups > "sage-devel" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sage-devel+unsubscr...@googlegroups.com. > To post to this group, send email to sage-devel@googlegroups.com. > Visit this group at https://groups.google.com/group/sage-devel. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] Re: Product of two expressions that causes hang
By bisection I find the issue is fixed with the commit https://github.com/pynac/pynac/commit/c4b2a4a42c6f01f0db6c3d54d493a049806e which fixes a power problem and apparently prevents the extraction of 2 mentioned earlier. Anyway please open a ticket for the doctest. Regards, -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Re: Product of two expressions that causes hang
On Wed, Apr 25, 2018 at 10:45 AM, Ralf Stephan wrote: > On Tuesday, April 24, 2018 at 5:15:17 PM UTC+2, Erik Bray wrote: >> >> sqrt(2) * ((I - 1)*sqrt(2) - 2) >> >> Then for some reason it decides there's an overall coeffecient of -2!, > > > That is probably what should be fixed. > >> and rewrites the expression as: >> >> -2*sqrt(2)*(-(1/2*I - 1/2)*sqrt(2) + 1) >> >> when it passes that back through ex::construct_from_basic, it goes >> back into mul::eval again (because technically it's a new >> expression?) > > > A new one is created, yes, but still not marked as evaluated because things > could be further simplified. > > Another complication is that here the crash is sensitive to unrelated code > changes. One other thing I should note is that in stepping through this it seems that the term it's picking as the "variable" is the (i - 1). I mean in theory something like that could be useful, but in this case it's obviously not a useful simplification. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] Re: Product of two expressions that causes hang
Note also that the master branch of Pynac on github is not the same code as the Pynac in Sage, although mul.cpp has not changed since. But there may have been distant changes with side effects. For example 0.7.19 as in #24838 with rc3 does not crash. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Re: Product of two expressions that causes hang
On Tuesday, April 24, 2018 at 5:15:17 PM UTC+2, Erik Bray wrote: > > sqrt(2) * ((I - 1)*sqrt(2) - 2) > > Then for some reason it decides there's an overall coeffecient of -2!, > That is probably what should be fixed. and rewrites the expression as: > > -2*sqrt(2)*(-(1/2*I - 1/2)*sqrt(2) + 1) > > when it passes that back through ex::construct_from_basic, it goes > back into mul::eval again (because technically it's a new > expression?) A new one is created, yes, but still not marked as evaluated because things could be further simplified. Another complication is that here the crash is sensitive to unrelated code changes. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Re: Product of two expressions that causes hang
On Tue, Apr 24, 2018 at 5:23 PM, Jean-Pierre Flori wrote: > It might be an issue with the "printing" order which is used to sort stuff > in pynac internally (but not in orignal ginac) and we already had issues > with in the past. Yes, there is a comment in there (the first part added by rws): 716 // The following comment is no longer true for pynac. 717 // We use the print order to determine the main variable 718 // This order is not random. 719 // XXX: The main variable is chosen in a random way, so this code 720 // does NOT transform the term into the canonical form (thus, in some 721 // very unlucky event it can even loop forever). Hopefully the main 722 // variable will be the same for all terms in *this However, the part about "in some very unlucky event it can even loop forever" appears to be true :( That hardly seems ideal. There should be a fix to prevent that from happening. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Re: Product of two expressions that causes hang
It might be an issue with the "printing" order which is used to sort stuff in pynac internally (but not in orignal ginac) and we already had issues with in the past. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
Re: [sage-devel] Re: Product of two expressions that causes hang
On Tue, Apr 24, 2018 at 4:52 PM, Jean-Pierre Flori wrote: > Ok I finally ended up in pynac code. > It seems there is a bad recursion happening, with the following reversed > backtrace: > (Sage.)Expression._mul_ > Ginac::* > Ginac::exmul > Ginac::ex::ex > Ginac::ex::construct_from_basic > Ginac::mul::eval > Ginac::ex::ex > Ginac::ex::construct_from_basic > Ginac::mul::eval > ... > Ginac::ex::ex > Ginac::ex::construct_from_basic > Ginac::mul::eval > Ginac::ex::integer_content > which calls sage code > which calls pynac code > ... > > The latter sage/pynac back and forth movement involves the numeric class in > pynac which uses sage... I think this is due to the following. In mul::eval there's some code that attempts to do simplifications like: (-x + a)*(3*x - 3*a) => -3*(x - a)^2 That code begins here: https://github.com/pynac/pynac/blob/master/ginac/mul.cpp#L700 In fact, when I try exactly that example in Sage it works as documented. However, with (sqrt(2)*I - sqrt(2) - 2) * sqrt(2), first of all it gets simplified to: sqrt(2) * ((I - 1)*sqrt(2) - 2) Then for some reason it decides there's an overall coeffecient of -2!, and rewrites the expression as: -2*sqrt(2)*(-(1/2*I - 1/2)*sqrt(2) + 1) when it passes that back through ex::construct_from_basic, it goes back into mul::eval again (because technically it's a new expression?), and then in there it gets resimplified back to the original expression, sqrt(2) * ((I - 1)*sqrt(2) - 2), but then tries again to pull out an overall coefficient of -2, and so on... What the heck? -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] Re: Product of two expressions that causes hang
Ok I finally ended up in pynac code. It seems there is a bad recursion happening, with the following reversed backtrace: (Sage.)Expression._mul_ Ginac::* Ginac::exmul Ginac::ex::ex Ginac::ex::construct_from_basic Ginac::mul::eval Ginac::ex::ex Ginac::ex::construct_from_basic Ginac::mul::eval ... Ginac::ex::ex Ginac::ex::construct_from_basic Ginac::mul::eval Ginac::ex::integer_content which calls sage code which calls pynac code ... The latter sage/pynac back and forth movement involves the numeric class in pynac which uses sage... -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] Re: Product of two expressions that causes hang
Kind of strange, running sage -gdb I never end up in Expression._mul_ but at random places in Python code. On Tuesday, April 24, 2018 at 2:40:50 PM UTC+2, Frédéric Chapoton wrote: > > Amusing.. Also hangs on > > sage: (1/e1)/e2 > 1/2*sqrt(2)/((I - 1)*sqrt(2) - 2) > sage: 1/_ > > > Le mardi 24 avril 2018 14:10:04 UTC+2, Erik Bray a écrit : >> >> Hi all, >> >> In working on an unrelated topic I encountered an indefinite hang, >> which I narrowed down to the following exact operation (I haven't >> found a way to simplify it further): >> >> sage: e1 = sqrt(2)*I - sqrt(2) - 2 >> sage: e2 = sqrt(2) >> >> simple enough, right? >> >> But then it appears to hang forever in pynac when I do: >> >> sage: e1 * e2 >> >> When I hit Ctrl-C, cysignals just returns to the sig_on() in the >> beginning of Expression._mul_. >> >> Any ideas? >> > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] Re: Product of two expressions that causes hang
Amusing.. Also hangs on sage: (1/e1)/e2 1/2*sqrt(2)/((I - 1)*sqrt(2) - 2) sage: 1/_ Le mardi 24 avril 2018 14:10:04 UTC+2, Erik Bray a écrit : > > Hi all, > > In working on an unrelated topic I encountered an indefinite hang, > which I narrowed down to the following exact operation (I haven't > found a way to simplify it further): > > sage: e1 = sqrt(2)*I - sqrt(2) - 2 > sage: e2 = sqrt(2) > > simple enough, right? > > But then it appears to hang forever in pynac when I do: > > sage: e1 * e2 > > When I hit Ctrl-C, cysignals just returns to the sig_on() in the > beginning of Expression._mul_. > > Any ideas? > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.