You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
strange behavior of result of order of vector definitions #376
if I change the order of lines in definition section - put four line to the first place
v vq1,vq2,vq3,vq4;
v k,k1,q,p,p1,p2,p3,p4,p5,p6,q1,q2,q3,q4,l;
v v1,v2,v3,v4,v5,v6;
v e1,e2,ep1,ep2;
v t1,XX;
result again becomes correct. Please find attached files in TstJp.zip - TstJp1.frm - correct result, TstJp2.frm - incorrect result, TstJp2a.frm - two lines interchanged in TstJp2.frm and correct result TstJp.zip
To understand the problem, let's consider the following small example:
V p1,p2,v1,v2,t;
CF f;
L F = p1.t^2 * p2.t;
id v1?.t^2 * v2?.t = f(v1,v2);
P;
.end
which gives
F =
f(p1,p2);
because the term in the expression F matches with the pattern given as the left-hand side of the id statement.
Now, if I change the pattern a bit,
V p1,p2,v1,v2,t;
CF f;
L F = p1.t^2 * p2.t;
id v1?.t * v2?.t^2 = f(v1,v2); * <-- LHS changed
P;
.end
then the term doesn't match with the pattern, so leads to
F =
p1.t^2*p2.t;
You may think v1?.t^2 * v2?.t and v1?.t * v2?.t^2 are the same (up to the exchange of the wildcards v1 and v2). That should be true, but unfortunately FORM doesn't work with the latter in this case.
Note that the declaration order of vectors affects how terms (even with wildcards) are normalized (effectively, v1?.t^2 * v2?.t or v1?.t * v2?.t^2).
A workaround is to put elements that possibley match into function arguments:
V p1,p2,v1,v2,t;
CF f;
CF tmp(symmetric);
L F = p1.t^2 * p2.t;
id p1?.p2? = tmp(p1,p2);
id tmp(v1?,t) * tmp(v2?,t)^2 = f(v1,v2);
P;
.end
because a backtracking algorithm in pattern matching for products of functions is implemented in FORM. ToTensor may also be useful to put vectors into functions.
Activity
tueda commentedon Feb 20, 2021
I think the root of the problem is a known issue of pattern matching. See also, for example,
To understand the problem, let's consider the following small example:
which gives
because the term in the expression
Fmatches with the pattern given as the left-hand side of theidstatement.Now, if I change the pattern a bit,
then the term doesn't match with the pattern, so leads to
You may think
v1?.t^2 * v2?.tandv1?.t * v2?.t^2are the same (up to the exchange of the wildcardsv1andv2). That should be true, but unfortunately FORM doesn't work with the latter in this case.Note that the declaration order of vectors affects how terms (even with wildcards) are normalized (effectively,
v1?.t^2 * v2?.torv1?.t * v2?.t^2).A workaround is to put elements that possibley match into function arguments:
because a backtracking algorithm in pattern matching for products of functions is implemented in FORM.
ToTensormay also be useful to put vectors into functions.Aradzh commentedon Feb 24, 2021
Thanks for description and workaround.