1
$\begingroup$

After defining a commutator function

Commutator[X_, Y_] := X.Y - Y.X;

I would like to be able to simplify abstract matrix algebra expressions such as

Simplify[Commutator[A + B, Commutator[A + B, A - B]] - 
  Commutator[A - B, Commutator[A + B, A - B]]]

instead of just printing out

-(A - B).(-(A - B).(A + B) + (A + B).(A - B)) + (A + 
    B).(-(A - B).(A + B) + (A + B).(A - B)) + (-(A - B).(A + B) + (A +
        B).(A - B)).(A - 
    B) - (-(A - B).(A + B) + (A + B).(A - B)).(A + B)

Is there a way to do this without downloading a non-commutative algebra package?

$\endgroup$

1 Answer 1

4
$\begingroup$

Try TensorReduce

$Assumptions = {A ∈ Matrices[{n, n}], B ∈ Matrices[{n, n}]};
expr = Commutator[A + B, Commutator[A + B, A - B]] - 
  Commutator[A - B, Commutator[A + B, A - B]];
TensorReduce[expr]
(* 
A.MatrixPower[A - B, 2] + 2 A.MatrixPower[B, 2] + 
 A.MatrixPower[A + B, 2] + B.MatrixPower[A - B, 2] - 
 B.MatrixPower[A + B, 2] + 6 MatrixPower[B, 2].A - 6 B.A.B - 
 2 MatrixPower[A, 3] *)

I don't know why TensorExpand is not expanding MatrixPower, but you can distribute all the dot products first with:

distributeDot[expr_] := FixedPoint[MapAll[Distribute[#, Plus, Dot] &, #] &, expr]

After this it simplifies much further:

TensorReduce[distributeDot[expr]]
(* 4 A.MatrixPower[B, 2] + 4 MatrixPower[B, 2].A - 8 B.A.B *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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