I would like to calculate various contractions of the Levi-Civita symbol using SageMath. As far as i know, there is no direct implementation of the ordinary symbol, so I followed another post and just used the Euclidean space:
E = EuclideanSpace(2, start_index=0)
g = E.metric()
eps = g.volume_form()
eps_dual = g.volume_form(2)
I tested some generic contractions which all seemed to work fine, however, once I started to change the contraction order, things became odd. While
res = eps['_ij']*eps_dual['^ij']
res.disp()
correctly returns E^2 --> R \n
(x, y) |--> 2
, for
res = eps['_ij']*eps_dual['^ji']
res.disp()
(2nd ij
swapped ) I would expect to get E^2 --> R \n
(x, y) |--> -2
, but sage tells me its +2
again.
The same happens if I use res = eps.contract(0, 1, eps_dual, 1, 0)
instead of the explicit index notation.
I don't know if this is some kind of convention I'm not aware of, however
res = (eps['_ij']*eps_dual['^jk']).trace()
or
res = (eps['_ij']*eps_dual['^jk'])['^n_n']
works just fine. Why does it seem like Sage does not care about the order if I contract all indices at once but does if I do it one after another?