I'm trying to create a function which receives as inputs a coordinate system $x^\mu$, metric tensor $g_{\mu\nu}$, a general tensor $T$ of rank $n$, and a list $I$ of length $n$ that looks like this:
$$I=(c_1,c_2,\dots,c_n)\quad\quad \forall i\in[1,n]_{\mathbb N}: c_i\in\{\mathrm{u},\mathrm{d}\}$$
which describes the location of the indices of the tensor ($\mathrm{u}$ for up, $\mathrm{d}$ for down). For example - if $T=T^{\mu\ \ \sigma}_{\ \ \nu\rho}$, then $I=(\mathrm{u},\mathrm{d},\mathrm{d},\mathrm{u})$ and $n=4$.
The output of the function should be the covariant derivative of the tensor in the given coordinate system, defined as the following:
$$\nabla_iv^j=\partial_iv^j+\Gamma^j_{\ ik}v^k \\\nabla_iv_j=\partial_iv_j-\Gamma^k_{\ ij}v_k$$
where $\partial_i\equiv{\partial}/{\partial x_i}$, and $\Gamma^i_{\ ij}$ are the Christoffel symbols. The main difficulty here for me is differentiating between the up and down indices. Also, it's not very clear how the ""matrix"" multiplication should be made.
• I did create a function which computes the Christoffel symbols given a metric $g$ and returns them as a tensor of degree 3 (essentially, it returns a matrix of column vectors), but I don't calculating them in a different way which will make the implementation of the covariant derivative function easier.
• I did search for such implementations, but I didn't find any implementations which differ between contravectors and covectors (up and down indices).
Thanks!
my answer here
. The computation of the Christoffel is for one index up and two down. I think that the logic is clear, but please, feel free to ask any questions $\endgroup$