Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question
2

R_{ab} = T_{ba} and so on

asked 2 years ago

solidsnake gravatar image

How can I permute indices in tensor fields on manifolds? I would like to define the following (0,4) tensor

Rabcd=ga[cgd]b

but I can't find an "easy" way (apart from assigning all the components bruteforce with some for loop, I guess). I presume there should be an "ovious" way of doing that but I cannot find it. Thanks.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 2 years ago

eric_g gravatar image

Permutations of indices are not implemented yet, except for special cases. For Rab=Tba, you can write something like:

R[:] = T.comp().swap_adjacent_indices(0,1,2)[:]

but this is not very handy. Here is some example:

sage: X.<x,y> = M.chart()
sage: T = M.tensor_field(0, 2, [[x, y], [x^2, y^2]])
sage: R = M.tensor_field(0, 2)
sage: R[:] = T.comp().swap_adjacent_indices(0,1,2)[:]
sage: T[:]
[  x   y]
[x^2 y^2]
sage: R[:]
[  x x^2]
[  y y^2]

For Rabcd=ga[cgd]b, only the tensor product and the antisymmetrization can be achieved without any loop on the components:

sage: g = M.metric('g')
sage: g[0,0], g[1,1] = 1/(1 + y^2), 1/(1 + x^2)
sage: S = (g*g).antisymmetrize(1,2)

An equivalent writing of the last line is

sage: S = (g*g)['_a[bc]d']

At this stage, one has Sabcd=ga[bgc]d. To get Rabcd=ga[cgd]b, one has to do

sage: R = M.tensor_field(0, 4, antisym=(2,3))
sage: for a in M.irange():
....:     for b in M.irange():
....:         for c in M.irange():
....:             for d in M.irange(start=c+1):
....:                 R[a,b,c,d] = S[a,c,d,b]
....:

Some check:

sage: R[0, 1, 0, 1]
1/2/((x^2 + 1)*y^2 + x^2 + 1)
sage: R[0, 1, 0, 1] == 1/2*(g[0,0]*g[1,1] - g[0,1]*g[0,1])
True
Preview: (hide)
link

Comments

1

Thank you very much. Indeed for the permutation itself (last step) I ended up with the following snippet

def permute(l,t):
    return [l[i-1] for i in t]

p = (1,3,4,2)
for ind in M.index_generator(4):
    R[ind] = S[permute(ind, p)]

which is slightly more compact than your excellent answer.

solidsnake gravatar imagesolidsnake ( 2 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2 years ago

Seen: 292 times

Last updated: Jun 16 '22