vermaseren / form

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

Sum over two initially different indices #432

Closed fetchinson closed 1 year ago

fetchinson commented 1 year ago

This will be a very simple question but somehow I couldn't find the answer in the documentation. Let's assume I have a complicated expression with 2 indices, m1, m2. The final result is given by FORM generally, so the answer contains both m1 and m2. Now I'd like to sum over this pair of indices so would like to substitute m2 = m1. For example, after a long computation FORM gives me W(m1,m2) which involves all sorts of objects, then I'm interested in W(m1,m1).

If I try the following it won't work:

CFunction W;
Index m1, m2;

Local expr = W(m1,m2);
id m2 = m1;

.sort
P +s;
.end

This still gives me W(m1,m2). So how would I force m2=m1?

It looks like indices can't be used for the "id" statement and I can't find a workaround.

jodavies commented 1 year ago

The id statement is not acting inside your function arguments. You can try, eg, multiply replace_(m2,m1);.

fetchinson commented 1 year ago

Great, thank you!

tueda commented 1 year ago

FYI: if the indices are not within nested functions, multiplying d_ also works:

CFunction W;
Index m1,m2;

Local expr = W(m1,m2);

multiply d_(m2,m1);

Print;
.end

The result is

   expr =
      W(m1,m1);

though it is not so clear whether this should give W(m1,m1) or W(m2,m2).