All you need to know about the gamma matrices for this problem is that there are four of them, $\gamma_{\mu}$ with $\mu = 0, 1, 2, 3$, and that the trace of the product of n gamma matrices (n even) obeys the following recursive relation:
Here, $\widehat{\gamma}_{\nu_k}$ signifies absence of $\gamma_{\nu_k}$ and $g_{\nu_1,\nu_k}$ is a tensor with two indices.(BTW, when n is odd the result is zero). Here's my attempt at the code:
TrGamma[z__] :=
If[Length[z] == 2,
4*Subscript[g, z[[1]], z[[2]]] ,
(*Else*)
Module[ {x = 0, n = Length[z]},
For[i = 2, i <= n, i++,
Module[{y = Delete[z, {{1}, {i}}]},
x = x + (-1)^i*Subscript[g, z[[1]], z[[i]]]*TrGamma[y]]
];
x
]
]
This gives the correct answer for n=2 and n=4:
In[4]:= TrGamma[{Subscript[\[Nu], 1],Subscript[\[Nu], 2]}]
TrGamma[{Subscript[\[Nu], 1],Subscript[\[Nu], 2],Subscript[\[Nu],3],Subscript[\[Nu], 4]}]
Output:
However, when I try n = 6 or higher it just keeps running. I'm guess there's something about Module that I'm missing or have misunderstood. I've tried replacing Module with Block and the problem still persists.
Internal`DiracGammaMatrix[]:Table[Internal`DiracGammaMatrix[k], {k, 5}]. $\endgroup$