# Contraction of Levi-Civita Symbols

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?

edit retag close merge delete

1

Sort by » oldest newest most voted

Thanks for your report! This is indeed a bug: the current implementation of contractions on multiple indices yield wrong results when the index positions in each of the two tensors do not have the same order and the outcome is a scalar field (when the outcome is a tensor field of nonzero valence, there is no issue). I've opened the Trac ticket #32355 for a fix.

EDIT (14 Sept. 2021): the fix proposed in #32355 has been merged in SageMath 9.5.beta1; so SageMath 9.5 will be free of this bug.

more

Thanks for opening the ticket. Indeed, for tensor fields it does seem to work which explains why taking the trace returns the correct result. For now, I just contract all but two indices and apply the trace in the end as workaround.