I have the following expression
F[p1, p2] a[p1] ** b[p2] - F[p1, p2] a[p2] ** b[p1]
where **
is the non-commutative multiplication operation in Mathematica.
p1
, 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 a
and 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?
F[p1, p2] (a[p1] ** b[p2] - a[p2] ** b[p1])
? If so,Factor
will do that. $\endgroup$