Covariant derivative of a tensor density

583 views
Skip to first unread message

cmp0xff

unread,
Jul 24, 2018, 1:11:35 PM7/24/18
to xAct Tensor Computer Algebra
Hi,

I am using xTensor to calculate expressions with tensor densities involved, and found a potential problem with covariant derivatives. Evaluating the following code

<< xAct`xTensor`
DefManifold[S3, 3, {i, j, k, l, m, n}]
DefMetric[1, hh[-i, -j], CD3,  SymbolOfCovD -> {"|", "D"}]
DefTensor[vv[i], S3, WeightOfTensor -> 1 AIndex]
ChangeCovD@CD3[-i][vv[i]]

gives a results with one Christoffel symbol; however there should be none according to definition (see Wikipedia, for example).

What is happening here?

Jose

unread,
Aug 6, 2018, 7:54:39 AM8/6/18
to xAct Tensor Computer Algebra
Hi,

In xTensor you need to tell the system in advance that the derivative will add density terms for tensor densities in a given basis. In most standard texts it is assumed that you work with tensors expressed in a single basis, so they do not need to specify which basis determines the densities, but in xAct we don't assume that, so you need to be specific. Therefore change your DefMetric line to

DefMetric[1, hh[-i, -j], CD3, SymbolOfCovD -> {"|", "D"}, WeightedWithBasis -> AIndex]

which passes the WeightedWithBasis option to DefCovD[CD3[-i], ...] and now CD3 will pay attention to the presence of AIndex in the tensor weights.

Once you have done that, your ChangeCovD command returns a result with a partial derivative of vv and two Christoffel terms: one is the standard Christoffel term of going from a covariant derivative to the partial derivative, and the other one is the density term. Because the connection is symmetric you can then use ToCanonical to cancel those two Christoffel terms in this case, as you expected.

Cheers,
Jose.

Yi-Fan

unread,
Aug 9, 2018, 11:43:12 AM8/9/18
to xAct Tensor Computer Algebra
Hi,

Thank you very much for your answer, Jose! In addition to your explanation, I have also been learning from the Prague lectures by Alfonso García-Parrado, and things about the abstract index become much clearer now.

I am not sure about the culture here. Should I reply to finish the discussion and express my appreciation?

Cheers,
Yi-Fan

Flavio Mercati

unread,
Jan 16, 2020, 9:52:05 AM1/16/20
to xAct Tensor Computer Algebra
Hi all,

I seem to have a further problem with tensor densities. Look at this example:

<< xAct`xCoba`;

DefManifold[\[CapitalSigma], 3, {i, j, k, l, m, n}];

DefMetric[1, g[-i, -j], CD, SymbolOfCovD -> {";", "\[Del]"}, WeightedWithBasis -> AIndex];

DefChart[coords, \[CapitalSigma], {1, 2,
3}, {\[Alpha][], \[Beta][], \[Gamma][]}];

$PrePrint = ScreenDollarIndices;

DefTensor[v[i], \[CapitalSigma], WeightOfTensor -> 1 AIndex];


If I calculate the 4-divergence of the vector density v[i] through CovDtoChristoffel it gives the right expression:

In[7]:= CovDToChristoffel[CD[-i][v[i]]]

Out[7]= - ChristoffelCD[j, -i, -j]  v[i] +  ChristoffelCD[i, -i, -j]   v[j] + xAct`xTensor`PD[-i][
v[i]]

And indeed, in canonical form I get no Christoffel symbols:

In[8]:= ToCanonical[%]

Out[8]= PD[-i][v[i]]

But if I put the indices into a coordinate basis:

In[10]:= ToBasis[coords][CD[-i][v[i]]]

** DefTensor: Defining tensor ChristoffelCDPDcoords[i,-j,-k]. 

** DefTensor: Defining weight +2 density Detgcoords[]. Determinant.

Out[10]= ChristoffelCDPDcoords[{i, coords}, {-i, -coords}, {-j, -coords}]   
  v[{j, coords}] + CD[{-i, -coords}][
v[{i, coords}]]

I get the trace of the Christoffel symbol associated to the covariant derivative of a density, plus the covariant derivative of v again!

If I give definite values to the vector and the metric, and call for example

ToValues[TraceBasisDummy[ToBasis[coords][CD[-i][v[i]]]]]

I get the wrong answer - something that differs from the correct answer precisely by the term  ChristoffelCDPDcoords[i,-i,-j] v[j].

What did I do wrong?

Thanks a lot,
Flavio

Jose

unread,
Jan 17, 2020, 5:24:26 AM1/17/20
to xAct Tensor Computer Algebra
Hi Flavio,

This is correct, though I agree it is not obvious immediately. The problem comes from the difference between the covariant derivative of a component of a tensor and the component of the covariant derivative of a tensor. The output notations for those two things are very similar in xAct.

Take your tensor density v[i]. In the coords basis we have the components v[{i, coords}]. Then CD[-j][ v[{i, coords}] ] are derivatives of components, not components of the derivative. The latter would be CD[-j][ v[k] ] Basis[-k, {i, coords}].

Another possible way to handle components of the derivative is to use the TensorDerivative notation. In your case:

In[11]:= ToBasis[coords][CD[-i][v[i]]] // ToTensorDerivative
Out[11]= TensorDerivative[v, CD][{i, coords}, {-i, -coords}]

which is what you have in mind, without the added Christoffel term.

Note how in Out[11] we have the abstract tensor TensorDerivative[v, CD]. With abstract indices, TensorDerivative[v, CD][i, -j] is identical to CD[-j][ v[i] ]. But with basis indices, these two objects are different in general:

   TensorDerivative[v, CD][{i, coords}, {-j, coords}]

   CD[{-j, coords}][ v[{i, coords}] ]

In the first case only v is differentiated. In the second case the Basis[-k, {i, coords}] vector is also differentiated, producing an additional Christoffel term.

Cheers,
Jose.

Flavio Mercati

unread,
Jan 18, 2020, 8:50:59 AM1/18/20
to xAct Tensor Computer Algebra
Thank you so much Jose, you're so awesome for still supporting xAct so keenly!

Your answer made me wonder whether I've been using xCoba right... I usually first attribute values to tensor components in a certain basis, then write a tensorial expression I want to calculate, then set all the indices to that basis, apply tracebasisdummy to expand the contracted indices, apply componentarray if there are uncontracted indices, and ToValues will usually finally give me the answer.

But have I been doing this right? It looks like I might have only been calculating covariant derivatives of tensor components, instead of components of covariant derivatives!

Let me write here a minimal working example: spherical coordinates in 3D

<< xAct`xCoba`;
DefManifold[\[CapitalSigma], 3, {i, j, k, l, m, n, s, t, u, v}];
DefMetric[1, g[-i, -j], CD, SymbolOfCovD -> {";", "\[Del]"}, WeightedWithBasis -> AIndex];
DefChart[Spher, \[CapitalSigma], {1, 2, 3}, {r[], \[Theta][], \[Phi][]}];
$PrePrint = ScreenDollarIndices;

MetricInBasis[g, -Spher, {{1, 0, 0}, {0, r[]^2, 0}, {0, 0, 
    r[]^2 Sin[\[Theta][]]^2}}];

MetricCompute[g, Spher, All];

so I have the flat Euclidean metric in spherical coordinates. Now I define a vector which, in Cartesian coordinates, would have constant components X Y and Z, but in spherical coordinates has nonconstant components:

DefConstantSymbol[X];
DefConstantSymbol[Y];
DefConstantSymbol[Z];

DefTensor[V[i], \[CapitalSigma]];

AllComponentValues[
 V[{i, Spher}], {Z Cos[\[Theta][]] + Sin[\[Theta][]] (X Cos[\[Phi][]] + Y Sin[\[Phi][]]), ( X Cos[\[Theta][]] Cos[\[Phi][]] - Z Sin[\[Theta][]] + Y Cos[\[Theta][]] Sin[\[Phi][]])/r[], ( Csc[\[Theta][]] (Y Cos[\[Phi][]] - X Sin[\[Phi][]]))/r[]}]

This guy has to have zero covariant derivatives. Calculating all the components of the covariant derivative in my way I get:

In[34]:= ToBasis[Spher][CD[-j][V[i]]]
 
Out[34]= xAct`xTensor`Basis[-k, {i, Spher}]  CD[{-j, -Spher}][V[k]]

here it projected the k component of V, who is inside CD, onto the i-th component of the Spher coordinate system. The component of CD is already in the Spher coordinate system. Now let's make a matrix with the choices of components i and j:

In[35]:= ComponentArray[%]

Out[35]= {{xAct`xTensor`Basis[-i, {1, Spher}] CD[{1, -Spher}][V[i]], xAct`xTensor`Basis[-i, {1, Spher}]  CD[{2, -Spher}][V[i]], xAct`xTensor`Basis[-i, {1, Spher}]  CD[{3, -Spher}][V[i]]}, {xAct`xTensor`Basis[-i, {2, Spher}]  CD[{1, -Spher}][V[i]], xAct`xTensor`Basis[-i, {2, Spher}]  CD[{2, -Spher}][V[i]], xAct`xTensor`Basis[-i, {2, Spher}]  CD[{3, -Spher}][V[i]]}, {xAct`xTensor`Basis[-i, {3, Spher}]  CD[{1, -Spher}][V[i]], xAct`xTensor`Basis[-i, {3, Spher}]  CD[{2, -Spher}][V[i]], xAct`xTensor`Basis[-i, {3, Spher}]  CD[{3, -Spher}][V[i]]}}

(sorry for the long expression). Now, running ToValues now does nothing, because there is still a saturated abstract index i which is not in any particular coordinate system. So I put it in the basis Spher (and this might be a misstep, I suppose?):

1/18/20 12:37:28 In[36]:= ToBasis[Spher][%]

1/18/20 12:37:28 Out[36]= {{xAct`xTensor`Basis[{-i, -Spher}, {1, Spher}]  ChristoffelCDPDSpher[{i, Spher}, {1, -Spher}, {-j, -Spher}]  V[{j, Spher}] + xAct`xTensor`Basis[{-i, -Spher}, {1, Spher}]  CD[{1, -Spher}][V[{i, Spher}]] , ETC...

so you see what I get? It's a Christoffell symbol saturated with V, plus a CD of V. The above expression would be correct if there was a partial derivative instead of CD. Now I expand the saturated indices, and apply ToValues:
 
In[37]:= TraceBasisDummy[%]

Out[37]= {{ChristoffelCDPDSpher[{1, Spher}, {1, -Spher}, {1, -Spher}] V[{1, Spher}] +  ChristoffelCDPDSpher[{1, Spher}, {1, -Spher}, {2, -Spher}] V[{2, Spher}] + ChristoffelCDPDSpher[{1, Spher}, {1, -Spher}, {3, -Spher}] V[{3, Spher}] + CD[{1, -Spher}][V[{1, Spher}]], ETC...

In[39]:= ToValues[%] // Simplify

Out[39]= {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}

The result is correct! I don't understand what's going on... If I ToValues separately one of the Christhoffel terms and the corresponding CD term I get: 

In[41]:= ToValues[ ChristoffelCDPDSpher[{1, Spher}, {3, -Spher}, {1, -Spher}] V[{1, Spher}] + ChristoffelCDPDSpher[{1, Spher}, {3, -Spher}, {2, -Spher}] V[{2, Spher}] + ChristoffelCDPDSpher[{1, Spher}, {3, -Spher}, {3, -Spher}] V[{3, Spher}]]
 
ToValues[CD[{3, -Spher}][V[{1, Spher}]]]
 
Out[41]= -Sin[\[Theta][]] (Y Cos[\[Phi][]] - X Sin[\[Phi][]])

Out[42]= Sin[\[Theta][]] (Y Cos[\[Phi][]] - X Sin[\[Phi][]])

I get equal and opposite nonzero values, as it should be if the derivative was PD and not CD.

I'm clearly missing something basic here... can you help?

Thanks again and all the best,
Flavio

Jose

unread,
Jan 22, 2020, 12:48:15 AM1/22/20
to xAct Tensor Computer Algebra
Hi again,

Comments inlined.


On Saturday, January 18, 2020 at 7:50:59 AM UTC-6, Flavio Mercati wrote:
Thank you so much Jose, you're so awesome for still supporting xAct so keenly!

Thank you for your words, and for your interest in xAct.
 

Your answer made me wonder whether I've been using xCoba right... I usually first attribute values to tensor components in a certain basis, then write a tensorial expression I want to calculate, then set all the indices to that basis, apply tracebasisdummy to expand the contracted indices, apply componentarray if there are uncontracted indices, and ToValues will usually finally give me the answer.

But have I been doing this right? It looks like I might have only been calculating covariant derivatives of tensor components, instead of components of covariant derivatives!

Let me write here a minimal working example: spherical coordinates in 3D

<< xAct`xCoba`;
DefManifold[\[CapitalSigma], 3, {i, j, k, l, m, n, s, t, u, v}];
DefMetric[1, g[-i, -j], CD, SymbolOfCovD -> {";", "\[Del]"}, WeightedWithBasis -> AIndex];
DefChart[Spher, \[CapitalSigma], {1, 2, 3}, {r[], \[Theta][], \[Phi][]}];
$PrePrint = ScreenDollarIndices;

MetricInBasis[g, -Spher, {{1, 0, 0}, {0, r[]^2, 0}, {0, 0, 
    r[]^2 Sin[\[Theta][]]^2}}];

MetricCompute[g, Spher, All];

so I have the flat Euclidean metric in spherical coordinates. Now I define a vector which, in Cartesian coordinates, would have constant components X Y and Z, but in spherical coordinates has nonconstant components:

DefConstantSymbol[X];
DefConstantSymbol[Y];
DefConstantSymbol[Z];

DefTensor[V[i], \[CapitalSigma]];

AllComponentValues[
 V[{i, Spher}], {Z Cos[\[Theta][]] + Sin[\[Theta][]] (X Cos[\[Phi][]] + Y Sin[\[Phi][]]), ( X Cos[\[Theta][]] Cos[\[Phi][]] - Z Sin[\[Theta][]] + Y Cos[\[Theta][]] Sin[\[Phi][]])/r[], ( Csc[\[Theta][]] (Y Cos[\[Phi][]] - X Sin[\[Phi][]]))/r[]}]

This guy has to have zero covariant derivatives. Calculating all the components of the covariant derivative in my way I get:

In[34]:= ToBasis[Spher][CD[-j][V[i]]]
 
Out[34]= xAct`xTensor`Basis[-k, {i, Spher}]  CD[{-j, -Spher}][V[k]]

here it projected the k component of V, who is inside CD, onto the i-th component of the Spher coordinate system. The component of CD is already in the Spher coordinate system.

Yes. What happened is that the free indices i and -j where converted into basis indices {i, Spher} and {-j, Spher}. This is immediate for the -j index, but not for the i index, which is inside the derivative. New indices will be introduced in abstract form, and you'll need additional use of ToBasis, as you do further down.
 
Now let's make a matrix with the choices of components i and j:

In[35]:= ComponentArray[%]

Out[35]= {{xAct`xTensor`Basis[-i, {1, Spher}] CD[{1, -Spher}][V[i]], xAct`xTensor`Basis[-i, {1, Spher}]  CD[{2, -Spher}][V[i]], xAct`xTensor`Basis[-i, {1, Spher}]  CD[{3, -Spher}][V[i]]}, {xAct`xTensor`Basis[-i, {2, Spher}]  CD[{1, -Spher}][V[i]], xAct`xTensor`Basis[-i, {2, Spher}]  CD[{2, -Spher}][V[i]], xAct`xTensor`Basis[-i, {2, Spher}]  CD[{3, -Spher}][V[i]]}, {xAct`xTensor`Basis[-i, {3, Spher}]  CD[{1, -Spher}][V[i]], xAct`xTensor`Basis[-i, {3, Spher}]  CD[{2, -Spher}][V[i]], xAct`xTensor`Basis[-i, {3, Spher}]  CD[{3, -Spher}][V[i]]}}

(sorry for the long expression). Now, running ToValues now does nothing, because there is still a saturated abstract index i which is not in any particular coordinate system. So I put it in the basis Spher (and this might be a misstep, I suppose?):

Everything looks fine to me so far.
 

1/18/20 12:37:28 In[36]:= ToBasis[Spher][%]

1/18/20 12:37:28 Out[36]= {{xAct`xTensor`Basis[{-i, -Spher}, {1, Spher}]  ChristoffelCDPDSpher[{i, Spher}, {1, -Spher}, {-j, -Spher}]  V[{j, Spher}] + xAct`xTensor`Basis[{-i, -Spher}, {1, Spher}]  CD[{1, -Spher}][V[{i, Spher}]] , ETC...

so you see what I get? It's a Christoffell symbol saturated with V, plus a CD of V. The above expression would be correct if there was a partial derivative instead of CD.

I see your confusion. We have CD[{1, -Spher}] of V[{i, Spher}]. The latter is a scalar. V[i] is a vector, a full abstract vector, but V[{i, Spher}] is the i-th component of the vector V[i] in the basis Spher, so it is a scalar. All covariant derivatives coincide on scalars, so it does not matter if you use CD or PD or any other derivative. xAct does not convert CD into PD automatically because you might want later expand scalars into products of tensors, etc, for which the distinction between CD and PD would be fundamental.
 
Now I expand the saturated indices, and apply ToValues:
 
In[37]:= TraceBasisDummy[%]

Out[37]= {{ChristoffelCDPDSpher[{1, Spher}, {1, -Spher}, {1, -Spher}] V[{1, Spher}] +  ChristoffelCDPDSpher[{1, Spher}, {1, -Spher}, {2, -Spher}] V[{2, Spher}] + ChristoffelCDPDSpher[{1, Spher}, {1, -Spher}, {3, -Spher}] V[{3, Spher}] + CD[{1, -Spher}][V[{1, Spher}]], ETC...

In[39]:= ToValues[%] // Simplify

Out[39]= {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}

The result is correct! I don't understand what's going on...

You started with an abstract expression (the covariant derivative), computed its components in the basis Scher and finally introduced values, so you got the correct results: all components of the derivative are zero, so the derivative itself is zero.
 
If I ToValues separately one of the Christhoffel terms and the corresponding CD term I get: 

In[41]:= ToValues[ ChristoffelCDPDSpher[{1, Spher}, {3, -Spher}, {1, -Spher}] V[{1, Spher}] + ChristoffelCDPDSpher[{1, Spher}, {3, -Spher}, {2, -Spher}] V[{2, Spher}] + ChristoffelCDPDSpher[{1, Spher}, {3, -Spher}, {3, -Spher}] V[{3, Spher}]]
 
ToValues[CD[{3, -Spher}][V[{1, Spher}]]]
 
Out[41]= -Sin[\[Theta][]] (Y Cos[\[Phi][]] - X Sin[\[Phi][]])

Out[42]= Sin[\[Theta][]] (Y Cos[\[Phi][]] - X Sin[\[Phi][]])

I get equal and opposite nonzero values, as it should be if the derivative was PD and not CD.

Now you know the answer: PD and CD coincide on scalars.
 

I'm clearly missing something basic here... can you help?

Finally, let me point out the xCoba has a better way of doing these computations: the CTensor framework. See the attached notebook.

Cheers,
Jose.
ComponentsOfDerivative.nb
Reply all
Reply to author
Forward
0 new messages