vermaseren / form

The FORM project for symbolic manipulation of very big expressions
GNU General Public License v3.0
982 stars 118 forks source link

Calling argument on polyratfun changes its ordering #410

Closed benruijl closed 1 year ago

benruijl commented 1 year ago

Using argument rat on an active polyratfun rat, causes its default ordering from large to small to change to small to large. This has disastrous effects if the polyratfun is added to other polyratfuns, as it yields incorrect results.

#-
S x, ep;
CF rat;
Polyratfun rat;

L F =  + rat(4*ep^4 + 52*ep^3 + 95*ep^2 - 13*ep - 24,486)
       + x*rat(8*ep^4 + 104*ep^3 + 190*ep^2 - 26*ep - 48,243*ep - 486);
.sort

* this changes the ordering from large to small from small to large
argument rat;
endargument;

Print "%r";
Print +s;
.sort

* difference in order causes polyratfun addition errors
id x = 1;

Print +s;
.end

At the end of the argument environment FORM should restore the original ordering.

jodavies commented 1 year ago

See also #336 and #345 . These days I never use polyratfun without On highfirst;... there are simply too many ways to end up with bad orderings.

benruijl commented 1 year ago

This bug was actually fixed I see. I was running on an older version of FORM. Time to get that new release out!

jodavies commented 1 year ago

Right, in this case, but https://github.com/vermaseren/form/issues/336#issuecomment-558996395 worries me still. In particular since the result was silently incorrect in #345 .