Some time ago, I wrote a package to calculate the tensor in General Relativity. To make it accessible to others, it should be slightly modified.
There are functions, for example, Christoffel for calculating the Christoffel symbol:
Christoffel[g_, xx_] := Block[{ig, res, n}, n = 4; ig = Simplify[Inverse[g]]; res = Table[(1/2)*Sum[ig[[i,s]]*(-D[g[[j,k]], xx[[s]]] + D[g[[j,s]], xx[[k]]] + D[g[[s,k]], xx[[j]]]), {s, 1, n}], {i, 1, n}, {j, 1, n}, {k, 1, n}]; res ]
where g and xx are the metric tensor and coordinates, respectively, which I determine in the Mathematica session after loading the package in a simple way, for example, for the anzatz for static spherically symmetric space-time:
This way is associated with disadvantages, since the ranges of indices are {1, 2, 3, 4} , while the usual practice in relativistic physics suggests putting {0, 1, 2, 3} , where 0 denotes the time coordinate, and {1, 2, 3} denote space-like ones. To talk about the problem, define a table where indexes start at 0, i.e.
V = Table[i - j, {i, 0, 3}, {j, 0, 3}] {{0, -1, -2, -3}, {1, 0, -1, -2}, {2, 1, 0, -1}, {3, 2, 1, 0}}
but when I evaluate V[[0, 0]] I get Symbol - chapter V,
and for V[[1, 2]] I get -1 , as it should be.
My questions:
- How can I override V so that I can evaluate the component "table"
[0, 0] ? - What would be the most convenient way to introduce the matrix g with its indices starting at 0?
- Since I have to refuse to use
Part to access the components of the tensor 0,0 how to introduce freedom of choice into the range of index ranges of other objects, such as Christoffel (for example, the default index is {0, 1, 2, 3} or if one prefers - {1, 2, 3, 4} )?
Although these questions seem trivial at a glance, any comprehensive answers are welcome. Anyone who uses the package should not be bothered by its subtleties of mathematica.