I am trying to learn how to use FeynCalc to handle commutators in Mathematica, but I can't seem to figure out how to take the commutator of two matrices with entries made up of products non-commuting variables. Does anybody know how this is done?

  • $\begingroup$ Not with FeynCalc, just program it directly in Mathematica. Add more details for the specific calculation you are interested in. $\endgroup$
    – QuantumDot
    May 6, 2021 at 18:50
  • $\begingroup$ You can do a little bit of general commutator algebra with FeynCalc, see, e.g. Commutator $\endgroup$ May 7, 2021 at 18:21

1 Answer 1


If I understand the question correctly, what you need is Inner[Dot, x, y]

Here is an example of working with Dirac matrices by representing them as 2x2 matrices containing Pauli matrices. From here on you should be able to cook up the code you need for your problem.

gamma[0] = {{1, 0}, {0, -1}}
gamma[i_] := {{0, CSI[i]}, {-CSI[i], 0}}

blockMatrixProduct[x_] := x;
blockMatrixProduct[x_, y_] := Inner[Dot, x, y];
blockMatrixProduct[x_, y_, z__] := 
blockMatrixProduct[x, blockMatrixProduct[y, z]];

blockMatrixProduct[gamma[i], gamma[j], gamma[i]]

$$ \left( \begin{array}{cc} 0.\left(\overline{\sigma }^j.\left(-\overline{\sigma }^i\right)+0.0\right)+\overline{\sigma }^i.\left(0.\left(-\overline{\sigma }^i\right)+\left(-\overline{\sigma }^j\right).0\right) & 0.\left(0.\overline{\sigma }^i+\overline{\sigma }^j.0\right)+\overline{\sigma }^i.\left(\left(-\overline{\sigma }^j\right).\overline{\sigma }^i+0.0\right) \\ 0.\left(0.\left(-\overline{\sigma }^i\right)+\left(-\overline{\sigma }^j\right).0\right)+\left(-\overline{\sigma }^i\right).\left(\overline{\sigma }^j.\left(-\overline{\sigma }^i\right)+0.0\right) & 0.\left(\left(-\overline{\sigma }^j\right).\overline{\sigma }^i+0.0\right)+\left(-\overline{\sigma }^i\right).\left(0.\overline{\sigma }^i+\overline{\sigma }^j.0\right) \\ \end{array} \right) $$

$$ \left( \begin{array}{cc} 0 & -\overline{\sigma }^i.\overline{\sigma }^j.\overline{\sigma }^i \\ \overline{\sigma }^i.\overline{\sigma }^j.\overline{\sigma }^i & 0 \\ \end{array} \right) $$


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.