vermaseren / form

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

Rational arithmetic giving pi_ #128

Closed tueda closed 7 years ago

tueda commented 7 years ago

Based on a post by Alexander Hasselhuhn in the forum (http://www.nikhef.nl/~form/forum/viewtopic.php?f=3&t=194). The following example gives a corrupt result for an expression GG, containing coeff_ and pi_, while a mathematically equivalent expression FF gives the correct result:

CF rat;
PolyRatFun rat;
S cw,sw,e;
*S MZ,sp12;  * <- This fixes the problem.
S sp12,MZ;

L F =     cw * sw * e * rat(- MZ, 2 * sp12 - 1 * MZ);
L G = 2 * cw * sw * e * rat(- MZ, 4 * sp12 - 2 * MZ);
.sort
L FF = F^2;
L GG = G^2;
P +s;
.end

Output:

FORM 4.1 (Sep 21 2016, v4.1-20131025-245-g104d5d8) 64-bits  Run: Sat Oct  1 14:21:33 2016

   F =
       + cw*sw*e*rat( - MZ,2*sp12 - MZ)
      ;

   G =
       + cw*sw*e*rat(MZ, - 2*sp12 + MZ)
      ;

   FF =
       + cw^2*sw^2*e^2*rat(MZ^2,4*sp12^2 - 4*sp12*MZ + MZ^2)
      ;

   GG =
       + cw^2*coeff_*pi_*rat(MZ^2,4*sp12^2 - 4*sp12*MZ + MZ^2)
      ;

Note that F and G are equivalent but have different representations. Sounds like it's related to the normalization of rat functions, which somehow gives an incorrect memory overwriting. So inserting the following code in an adequate place would be a workaround:

.sort
PolyRatFun rat;  * redeclared; renormalize rat forcely
.sort

It seems that this bug was introduced by ffabb37261.

tueda commented 7 years ago

Fixed by f74b7b5.