vermaseren / form

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

PolyRatFun and Argument #345

Closed jodavies closed 3 years ago

jodavies commented 4 years ago

Hello,

We ran into some problems with code which makes some replacements inside arguments, when those symbols appear in an active polyratfun. A minimal example is included below. In principle there are two problematic bits.

At "PROBLEM 1", in the module with the argument environment, the output is correct but not properly normalized. In principle this is OK, but in the following module ("PROBLEM 2") we move another symbol into the polyratfun and the overall numerical factor in the improperly normalized denominator is lost completely, leading to an incorrect result.

Perhaps "PROBLEM 2" is simply due to code which assumes the input is normalized properly, and the bug is only that the argument environment does not flag the polyratfun for normalization.

#-
Off Statistics;
On Highfirst;

Symbol x,s,t,u,m1,m2;
Symbol q1q2,q1q3,q2q3,q3q3;
CFunction rat;

PolyRatFun rat;
Local test = x*rat( - 4*s^2,q1q2^2*q3q3 - 2*q1q2*q1q3*q2q3);
.sort

Argument;
    Identify q1q2 = s/2;
    Identify q1q3 = (t-m1^2)/2;
    Identify q2q3 = (-s-t+m1^2+m2^2)/2;
    Identify q3q3 = m1^2;
EndArgument;

* This works fine:
*Multiply replace_(q1q2,s/2);
*Multiply replace_(q1q3,(t-m1^2)/2);
*Multiply replace_(q2q3,(-s-t+m1^2+m2^2)/2);
*Multiply replace_(q3q3,m1^2);

* PROBLEM 1
* rat is not properly normalized at the end of this module, in the case of the Argument environment
Print +s;
.sort

* PROBLEM 2
* move some other symbol into the rat
* Now the overall factor of the denominator is lost completely
Identify x^s? = rat(x^s,1);
.sort

Print +s;
.end

This can be worked around by using replace_ statements instead.

Thanks, Josh.

vermaseren commented 4 years ago

I guess that the Argument environment never checks its sorting vs the polyratfun. The arguments of the polyratfun are sorted differently. Clearly this must have been forgotten. There are more workarounds like an extra id rat(x1?,x2?) = rat(x1,x2); which forces a normalization. I hope that a next update gets this right. Sometimes the normalization of the polyratfun is a pain in the neck, because you do not want to normalize it too often either. This is particularly the case in the file proces.c which caused no end of trouble, but at least that one has performed well over the past years.

Jos

On 30 Apr 2020, at 11:46, jodavies notifications@github.com wrote:

Hello,

We ran into some problems with code which makes some replacements inside arguments, when those symbols appear in an active polyratfun. A minimal example is included below. In principle there are two problematic bits.

At "PROBLEM 1", in the module with the argument environment, the output is correct but not properly normalized. In principle this is OK, but in the following module ("PROBLEM 2") we move another symbol into the polyratfun and the overall numerical factor in the improperly normalized denominator is lost completely, leading to an incorrect result.

Perhaps "PROBLEM 2" is simply due to code which assumes the input is normalized properly, and the bug is only that the argument environment does not flag the polyratfun for normalization.

-

Off Statistics; On Highfirst;

Symbol x,s,t,u,m1,m2; Symbol q1q2,q1q3,q2q3,q3q3; CFunction rat;

PolyRatFun rat; Local test = xrat( - 4s^2,q1q2^2q3q3 - 2q1q2q1q3q2q3); .sort

Argument; Identify q1q2 = s/2; Identify q1q3 = (t-m1^2)/2; Identify q2q3 = (-s-t+m1^2+m2^2)/2; Identify q3q3 = m1^2; EndArgument;

  • This works fine: Multiply replace_(q1q2,s/2); Multiply replace(q1q3,(t-m1^2)/2); *Multiply replace(q2q3,(-s-t+m1^2+m2^2)/2); *Multiply replace_(q3q3,m1^2);

  • PROBLEM 1

  • rat is not properly normalized at the end of this module, in the case of the Argument environment Print +s; .sort

  • PROBLEM 2

  • move some other symbol into the rat

  • Now the overall factor of the denominator is lost completely Identify x^s? = rat(x^s,1); .sort

Print +s; .end This can be worked around by using replace_ statements instead.

Thanks, Josh.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/vermaseren/form/issues/345, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJPCEUODMTFSHUN6KFJWF3RPFCJDANCNFSM4MVLK3NA.