I am very new to Mathematica, and am trying to use it to compute Christoffel symbols for a certain manifold. All this requires is taking some indexed sums of derivatives, but it builds up on several different things, and I am missing something in defining the indexed variables. This might be a little long, but I would really appreciate any help that I could get.
I started by defining the local coordinate function and finding its partial derivatives and then the elements of the metric tensor:
f[x1_, x2_] = {x1, x2, Sqrt[r^2 - x1^2 - x2^2};
fx = D[f[x1, x2], x1],
fy = D[f[x1, x2], x2]
g[1, 1, x1_, x2_] = fx.fx,
g[1, 2, x1_, x2_] = fx.fy
g[2, 1, x1_, x2_] = fx.fy
g[2, 2, x1_, x2_] = fy.fy
Running this code goes smoothly, giving me three functions of $x_1$ and $x_2$ that match what I computed by hand. I then want to calculate the inverse of the coordinate representation of the metric tensor, which is easily done:
Inverse[{{g[1, 1, x1_, x2_], g[1, 2, x1_, x2_]},
{g[2, 1, x1_, x2_], g[2, 2, x1_, x2_]}}]
Then defining the components of this matrix from what we get:
ginv[1, 1, x1_, x2_] = 1 - x1^2/r^2
ginv[2, 2, x1_, x2_] = 1 - x2^2/r^2
ginv[1, 2, x1_, x2_] = -((x1 * x2)/r^2)
ginv[2, 1, x1_, x2_] = -((x1 * x2)/r^2),
we have everything that we should need to get our Christoffel symbols. The equation for Christoffel symbols in local coordinates is
$\newcommand{\p}{\partial} \Gamma_{ij}^k = \frac{1}{2}\left(\frac{\p g_{j \ell}}{\p x^i} + \frac{\p g_{\ell i}}{\p x^j} - \frac{\p g_{ij}}{\p x^\ell}\right)g^{\ell k}$
I don't know anything about using Einstein notation in Mathematica (I am very new to it), so since our indices only range from one to two, I just wrote out the whole thing without using dummy indices at all. This is where I ran into problems. I know that my syntax is wrong, but I thought I'd try it anyway since I could find out how to do this correctly anywhere online at all. Here is what I tried to define the Christoffel symbol "function" (of $i, j, k$) as:
Gamma[i_, j_, k_, x1_, x2_] =
0.5*(D[g[j, 1, x1, x2], xi] + D[g[1, i, x1, x2], xj] -
D[g[i, j, x1, x2], x1])*ginv[1, k, x1, x2] +
0.5*(D[g[j, 2, x1, x2], xi] + D[g[2, i, x1, x2], xj] -
D[g[i, j, x1, x2], x2])*ginv[2, k, x1, x2]
I couldn't figure out any other way to make $x$ a function of an index $i$ without changing too much else and running into issues with taking partial derivatives by $x_i$ and other things like that. How do I fix this to accurately define a function of indices that can be differentiated etc. (I am trying to calculate components of the Riemannian curvature tensor using the Christoffel symbols)?
Any help would be wonderful!
f[x1_, x2_] = [x1, x2, Sqrt[r^2 - x1^2 - x2^2].
is not syntactically correct. Do you mean:f[x1_, x2_] = {x1, x2, Sqrt[r^2 - x1^2 - x2^2};
? $\endgroup$gamma[1, 1, 1, a, b] = 0.5*(D[g[j, 1, x1, x2], x1] + D[g[1, 1, x1, x2], x1] - D[g[1, 1, x1, x2], x1])*ginv[1, k, x1, x2] + 0.5*(D[g[1, 2, x1, x2], x1] + D[g[2, 1, x1, x2], x1] - D[g[1, 1, x1, x2], x2])*ginv[2, k, x1, x2]
$\endgroup$