# Calculating the Laplacian operator using xCoba

I would like to attempt to calculate the laplacian operator using index notation and shoow that it gives the usually expected laplacian in spherical coordinates. I am able to do most of the steps however, I cannot get xCoba to reduce the final form out of index notation. Consider the following minimal example:

Assuming the metric has the form of:

$$\text{d} s^2 = \text{d}r^2 + r^2 \text{d}\Omega^2$$

and that the laplacian may be calculated using:

$$\Delta Y(r,\theta,\phi) = g^{mn}(\partial_m\partial_n - \Gamma^l_{\ mn} \partial_l) Y$$

Clear["Global*"]
<< xActxCoba
DefManifold[M, 3, {a, b, c, d, e, f}]
DefChart[coords, M, {0, 1, 2}, {r[], \[Theta][], \[Phi][]}]

metric = {{1, 0, 0}, {0, r[]^2, 0}, {0, 0, Sin[\[Theta[]]]^2*r[]^2}}
g = CTensor[metric, {-coords, -coords}]
SetCMetric[g, coords, SignatureOfMetric -> {3, 0, 0}]
CD = CovDOfMetric[g]

DefTensor[Chs[a, -b, -c], M]
DefScalarFunction[{Y}]

IndexSet[ChS[c_, -a_, -b_],
ChristoffelFromMetric[g[-d, -e], coords][c, -a, -b]];

laplacianY =
g[a, b][PDcoords[-a][PDcoords[-b][Y[r[], \[Theta][], \[Phi][]]]] -
ChS[c, -a, -b][PDcoords[-c][Y[r[], \[Theta][], \[Phi][] ]]]]


At this point as far as I can tell laplacianY has the correct form in index notation, but I cannot find the required xCoba function that expands all of the indexes. I've tried: ToCanonical, ContractBasis,TraceDummy but all of these either throw an error or return the same function. I can't currently see any other function in the xCoba package that sounds like it would reduce index notation.

Any help is greatly appreciated.

• Ah, so the error here is a pretty simple mistake. I'll answer fully later but I've confsed operators and numerical values. $g$ is not an operator here as $g^{ab}$ is just a value. Likewise, $\Gamma$ with its indices are just values and not operators. Fixing these allows for ContractBasis to work as expected. Oct 21, 2021 at 19:28
• akozi, you might considering answering your own question to clarify this error. It would be useful to future users to see how you fixed the problem beyond just the statement of this comment. Oct 22, 2021 at 0:57
• Is there a reason you wouldn't simply do CD[-a][CD[a][Y]], or something like that? Oct 22, 2021 at 1:40
• @CATrevillian yes that's a good idea. I think I shall do this later tonight or tomorrow. Oct 23, 2021 at 20:11
• @MichaelSeifert actually I had done it in that form and it was fine. I was mostly just wanting to compare the two as a sanity check. (new to Mathematica and xAct) Oct 23, 2021 at 20:12

## Remember what is an Operator and what is a Value

Although $$g$$ and $$\Gamma$$ are sometimes displayed as matrices, when we use index notation $$g^{\mu\nu}$$ and $$\Gamma^{\mu}_{\ \nu\alpha}$$ are explicit values of the matrices if you want to think of them that way.

## Connection to Mathematica

In Mathematica, to my knowledge, at least square brackets, [], denote operators parameters. So when I wrote a term like:

g[a, b][...]

I was implying to Mathematica that $$g^{ab}$$ was an operator and not a value. I did the same for the Christoffel symbols. Switching these cases to the proper numerical multiplication g[a,b](...) solves the issue.

## Solution

We re-write the minimal example as:

Clear["Global*"]
<< xActxCoba
DefManifold[M, 3, {a, b, c, d, e, f}]
DefChart[coords, M, {0, 1, 2}, {r[], \[Theta][], \[Phi][]}]

metric = {{1, 0, 0}, {0, r[]^2, 0}, {0, 0, Sin[\[Theta][]]^2*r[]^2}}
g = CTensor[metric, {-coords, -coords}]
SetCMetric[g, coords, SignatureOfMetric -> {3, 0, 0}]
CD = CovDOfMetric[g]

DefTensor[Chs[a, -b, -c], M]
DefScalarFunction[{Y}]

IndexSet[ChS[c_, -a_, -b_],
ChristoffelFromMetric[g[-d, -e], coords][c, -a, -b]];

laplacianY =
g[a, b] (PDcoords[-a][PDcoords[-b][Y[r[], \[Theta][], \[Phi][]]]] -
ChS[c, -a, -b] (PDcoords[-c][Y[r[], \[Theta][], \[Phi][]]]) )
ContractBasis[laplacianY]


The output of ContractBasis now gives: As desired.