Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Index notation

I am taking a course in general relativity, and I was planing to use sage for doing calculations.

I have

from sage.tensor.modules.tensor_with_indices import TensorWithIndices
M = FiniteRankFreeModule(QQ, 4, name='M')
e = M.basis('e')
a = M.tensor((2,0), name='a')
a[:] = [[2,0,1,-1], [1,0,3,2], [-1,1,0,0], [-2,1,1,-2]]
g = M.tensor((0,2), name='g')
g[:] = [[1,0,0,0], [0,1,0,0], [0,0,1,0],[0,0,0,1]]

I wanted to calculate $a^{^i,^j}$ Is there some way to tell Sage what is the metric, and do the index lowering automatically? I did it manually, but it's cumbersome for more complicated calculations. A=a['^ik']*g['_jk'];A[:]

Apart from that, I would like to know if there is a way to do this kind of computations with tensor fields and index notation, including derivatives, etc.

Index notation

I am taking a course in general relativity, and I was planing to use sage for doing calculations.

I have

from sage.tensor.modules.tensor_with_indices import TensorWithIndices
M = FiniteRankFreeModule(QQ, 4, name='M')
e = M.basis('e')
a = M.tensor((2,0), name='a')
a[:] = [[2,0,1,-1], [1,0,3,2], [-1,1,0,0], [-2,1,1,-2]]
g = M.tensor((0,2), name='g')
g[:] = [[1,0,0,0], [0,1,0,0], [0,0,1,0],[0,0,0,1]]
v=M.tensor((1,0), name='v')
v[:]=[-1,2,0,-2]

I wanted to calculate $a^{^i,^j}$ Is there some way to tell Sage what is the metric, and do the index lowering automatically? I did it manually, but it's cumbersome for more complicated calculations. calculations.

    A=a['^ik']*g['_jk'];A[:]A=a['^ik']*g['_jk'];A[:]

Also, I don't know how to compute $vĂ® v_i$, since

v['^i']*g['_ij']*v['i']

does not work.

Apart from that, I would like to know if there is a way to do this kind of computations with tensor fields and index notation, including derivatives, etc.