I have the following expression
F[p1, p2] a[p1] ** b[p2] - F[p1, p2] a[p2] ** b[p1]
** is the non-commutative multiplication operation in Mathematica.
p2 are dummy variables that are integrated or summed over in my example.
Ideally, I'd like Mathematica to simplify that expression to
(F[p1, p2] - F[p1, p2]) a[p1] ** b[p2]
So that the variables in the string
a[pi] ** b[pj] are sorted according to some rule. In principle I would like to generalize that to monomials of
b of arbitrary order.
What I tried to do was a symbolic sum:
sum[F[p1, p2] a[p1] ** b[p2] - F[p1, p2] a[p2] ** b[p1], p1, p2]
but it doesn't simplify the result. Is there a way to do pattern matching so that the dummy variables in my expression are relabeled according to my rule?