vermaseren / form

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

Honour brackets when doing #Optimize #362

Open benruijl opened 4 years ago

benruijl commented 4 years ago

In order to optimize multiple polynomials at the same time, one could bracket in the variables that should be kept outside. This (undocumented!) feature seems to kind of work when the number of variables in each bracket is large. However, when there are only a few variables, you will find cases where the bracketed symbols end up inside the intermediate expressions.

For example:

#-
Off statistics;
S x,y,z,x1,x2;
L F = x1*(y+y^2+z) + x2*(z+z^2);

B x1,x2;
.sort
Format O1;
#Optimize F

#write "%O"
Print +s;
.end

expected outcome:

Z1_=1 + z;
Z1_=z*Z1_;
Z2_=1 + y;
Z2_=y*Z2_;

      F=x2*Z1_ + x1*Z2_;

actual outcome:

Z1_=1 + z;
Z1_=z*Z1_;
Z2_=1 + y;
Z2_=y*Z2_;

      Z1_=x2*Z1_;
      Z2_=x1*Z2_;
      F=Z1_ + Z2_;

When bracketing in a variable x that appears as x*A+x^2*B it is clear that the brackets are definitely not honoured.