Last active
March 14, 2023 14:02
-
-
Save gapolinario/b4b4120ad3032c43dddfcae08dd311b8 to your computer and use it in GitHub Desktop.
Contraction of repeated indices, Mathematica
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dim = 3; | |
SetAttributes[KD, Orderless] | |
KD[i_, i_] := dim | |
ContractDeltas[delta_] := | |
With[{rule = {KD[x_, y_] f_[w___, x_, z___] -> f[w, y, z], | |
Power[KD[x_, y_], 2] -> dim}}, Expand[delta] //. rule] | |
(* A basic example *) | |
del2 = KD[i, j] KD[i, l] + KD[k, j] KD[i, k] KD[j, f] + KD[i, i] KD[g, f] KD[f, s] + KD[u, v] KD[w, v] KD[w, u]; | |
ContractDeltas[del2] // TraditionalForm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment