I have taken note of a similar post related to modifying function parameters. I tried to adapt Kuba's solution to this post but I can't get it to work. I will illustrate my problem using a similar notation used in the other post.
I have a function, $f$, that has an arbitrary, but even number of arguments; i.e. $f(A,B,C,D,E,F)$. The parameters $A,B,C,D,E,F$ actually represent variables which I integrate over. Now two different variables may be switched, but the evaluation of the integration of such a function will not change since all we have done is switch the 'dummy' variable.
So I have a function that generates a lot of these such functions and I want Mathematica to use this to simplify the output. For example, if I have as the output of my function:
expr1 = f[2, 2, 1, 3, 3, 1] + f[2, 2, 3, 1, 1, 3] + f[3, 3, 1, 2, 2, 1] + f[1, 1, 2, 3, 3, 2];
I want mathematica to generate the output:
Since the integration of all of these functions will be the same. Of course, more than 1 switch of variables can be made. The number of arguments can increase to an arbitrary even number. Additionally, any pair of arguments can be switched EXCEPT the last pair. i.e.
expr2 = f[1, 3, 2, 2, 3, 1] + f[2, 2, 1, 3, 3, 1] + f[2, 2, 3, 1, 1, 3]
2f(2,2,1,3,3,1) + f(2,2,3,1,1,3)
Since the first two functions are the same but the third is not - since the last pair in the third function has been switched by the second pair (compared to the second pair). So any pair can be switched BUT not the last pair of arguments.
Writing a function that acknowledges that these functions are the same enables a reduced number of integration evaluation - important when each integration takes long to evaluate.
Thanks very much for your help.