To generalize Mark's answer, you can use Outer
to construct the matrix.
Surprisingly, I don't think you actually want to use the built-in KroneckerDelta
because in Einstein summation notation, KroneckerDelta[a,a]
should evaluate to the dimension of the space a
labels, but in Mma it's automatically 1. If not, you can always define δ=KroneckerDelta
.
kδ[upper_,lower_]/;Length[upper]==Length[lower]:=Det[Outer[δ,upper,lower]]
Then kδ[{a,b,c,d},{α,β,γ,ζ}]
evaluates to
δ[a, ζ] δ[b, γ] δ[c, β] δ[d, α]
- δ[a, γ] δ[b, ζ] δ[c, β] δ[d, α]
- δ[a, ζ] δ[b, β] δ[c, γ] δ[d, α]
+ δ[a, β] δ[b, ζ] δ[c, γ] δ[d, α]
+ δ[a, γ] δ[b, β] δ[c, ζ] δ[d, α]
- δ[a, β] δ[b, γ] δ[c, ζ] δ[d, α]
- δ[a, ζ] δ[b, γ] δ[c, α] δ[d, β]
+ δ[a, γ] δ[b, ζ] δ[c, α] δ[d, β]
+ δ[a, ζ] δ[b, α] δ[c, γ] δ[d, β]
- δ[a, α] δ[b, ζ] δ[c, γ] δ[d, β]
- δ[a, γ] δ[b, α] δ[c, ζ] δ[d, β]
+ δ[a, α] δ[b, γ] δ[c, ζ] δ[d, β]
+ δ[a, ζ] δ[b, β] δ[c, α] δ[d, γ]
- δ[a, β] δ[b, ζ] δ[c, α] δ[d, γ]
- δ[a, ζ] δ[b, α] δ[c, β] δ[d, γ]
+ δ[a, α] δ[b, ζ] δ[c, β] δ[d, γ]
+ δ[a, β] δ[b, α] δ[c, ζ] δ[d, γ]
- δ[a, α] δ[b, β] δ[c, ζ] δ[d, γ]
- δ[a, γ] δ[b, β] δ[c, α] δ[d, ζ]
+ δ[a, β] δ[b, γ] δ[c, α] δ[d, ζ]
+ δ[a, γ] δ[b, α] δ[c, β] δ[d, ζ]
- δ[a, α] δ[b, γ] δ[c, β] δ[d, ζ]
- δ[a, β] δ[b, α] δ[c, γ] δ[d, ζ]
+ δ[a, α] δ[b, β] δ[c, γ] δ[d, ζ]
You may also want something like einsteinSum
,
Clear[einsteinSum];
einsteinSum[Plus[a_,addends__]]:=einsteinSum[a]+einsteinSum[Plus[addends]];
einsteinSum[Times[factors___,δ[a_,a_]]]:=δ[a,a]einsteinSum[Times[factors]];
einsteinSum[Times[factors___,δ[a_,b_]]]/;Not[FreeQ[Times[factors],a]]:=einsteinSum[Times[factors]//.a->b];
einsteinSum[Times[factors___,δ[a_,b_]]]/;Not[FreeQ[Times[factors],b]]:=einsteinSum[Times[factors]//.b->a];
einsteinSum[Times[factors__]]:=einsteinSum[Distribute[Times[factors]]]
einsteinSum[f_]:=f;
and which you can specialize further (order matters in defining the patterns!). It takes a very long time to do something as complex as your example of four four-index generalized Kroneckers (and it doesn't give it in some pretty compact form, which may exist, and which might be discoverable with patterns).