On Tue, Apr 24, 2018 at 4:52 PM, Jean-Pierre Flori <jpfl...@gmail.com> 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.