7
$\begingroup$

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?

$\endgroup$
  • $\begingroup$ Did you mean to rewrite as F[p1, p2] (a[p1] ** b[p2] - a[p2] ** b[p1])? If so, Factor will do that. $\endgroup$ – Daniel Lichtblau May 20 '18 at 13:18
1
$\begingroup$

Check out NCAlgebra. NCCollect will do what you want.

$\endgroup$
0
$\begingroup$

Try this:

F[p1, p2] a[p1] ** 
    b[p2] - ((F[p1, p2] a[p2] ** b[p1] /. {p1 -> q1, 
       p2 -> q2}) /. {q1 -> p2, q2 -> p1}) // Simplify

Have fun!

$\endgroup$
  • $\begingroup$ My problem is that I want to convert an arbitrary sum of monomials of a's and b's of arbitrary order. Your solution only applies to the particular simplified example I posted (sum of two terms of order two) $\endgroup$ – chubecca Oct 11 '17 at 14:50
  • 4
    $\begingroup$ @chubecca One cannot guess of what you have in mind. Post a complete problem with a sum you need. $\endgroup$ – Alexei Boulbitch Oct 12 '17 at 7:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.