2-point tensors, functional derivatives

637 views
Skip to first unread message

Jörg Frauendiener

unread,
Jan 25, 2010, 4:11:55 AM1/25/10
to xAct Tensor Computer Algebra
Hi All,

is it possible in xTensor to define 2-point tensors? The prototypical example for this is the derivative of a map f:M->N between two manifolds M and N. The derivative is then a map from the tangent bundle TM to TN and it can be denoted by Tf^A_a, if we denote tensors on TM (TN) with lowercase (uppercase) letters.

Another question: Is it possible to compute the derivative of tensorial expressions with respect to a tensor? I am thinking of something like e.g.:
define rho = A_{ab}A_{cd}h^{bc}h^{ad}, then d rho/d h^{pq} = A_{pb}A_{cq}h^{bc} + A_{ap}A_{qd}h^{ad} and d^2rho/d h^{rs} d h^{pq} = A_{pr}A_{sq} + A_{rp}A_{qs} .

I thought that I had seen that somewhere in the documentation but I can't find it anymore.

Thanks,
Jörg


--
Jorg Frauendiener         | Tel.: +64-3-479-7770
Mathematics & Statistics  | Fax:  +64-3-479-8427
University of Otago       | joe...@maths.otago.ac.nz
P.O. Box 56               | jorg.fra...@otago.ac.nz
Dunedin 9010              | http://www.maths.otago.ac.nz
Skype: frauendiener

JMM

unread,
Jan 25, 2010, 9:37:57 AM1/25/10
to xAct Tensor Computer Algebra
Hi Jörg,

Let me first address your second point. There is a command VarD in
xTensor which performs what you want, with notation VarD[ T ][ S ],
meaning the derivative of the scalar S with respect to the tensor T.
The tensor T can have free indices, but S must be a scalar. That
introduces a slight twist in your example with second derivatives,
because the result of the first derivative must be multiplied with an
arbitrary tensor to make it scalar, and then that tensor must be
removed at the end. I have uploaded an example notebook in the Files
area of the xAct group. I can easily automatize the use of this trick
if you need it repeatedly.

Your first point is something that reaches the current boundaries of
xTensor. It is certainly possible to have tensors with indices on
several vector bundles having the same base manifold, and it is also
possible to have objects with several manifold dependencies, and then
indices on different vector bundles on those manifolds. We use this a
lot in gauge theories, spinor calculus or symmetry reductions, for
example, and works well. Alfonso Garcia-Parrado helped me designing
this part, a few years ago. It is also simple to define bitensors, by
having duplicates of all geometric structures. But there is not yet a
concept of mapping between two manifolds in xTensor, and hence there
is no natural way of definining the tangent mapping. It is perfectly
possible to construct directly the tensor Tf[A,-a] in xTensor, but it
is not so clear how to store the manifold dependencies of this tensor,
or in other words, how to handle its derivatives within the current
structure of xTensor. The key commands to think about are
SlotsOfTensor and DependenciesOfTensor.

Cheers,
Jose.

On Jan 25, 10:11 am, Jörg Frauendiener <joerg.frauendie...@gmail.com>
wrote:

> P.O. Box 56               | jorg.frauendie...@otago.ac.nz

Jörg Frauendiener

unread,
Jan 25, 2010, 6:04:03 PM1/25/10
to JMM, xAct Tensor Computer Algebra
Hi Jose,

thanks very much for your quick answer.

> Let me first address your second point. There is a command VarD in
> xTensor which performs what you want, with notation VarD[ T ][ S ],
> meaning the derivative of the scalar S with respect to the tensor T.
> The tensor T can have free indices, but S must be a scalar. That
> introduces a slight twist in your example with second derivatives,
> because the result of the first derivative must be multiplied with an
> arbitrary tensor to make it scalar, and then that tensor must be
> removed at the end. I have uploaded an example notebook in the Files
> area of the xAct group. I can easily automatize the use of this trick
> if you need it repeatedly.

So it was VarD! I was not sure about that. Now comes the next level of
complication: Let's say I have n=A_{ab} H^{ab} and rho=f(n) for some
unknown function f. I would like to get d rho/d h^{ab} = f'(n) A_{ab}.
How would I implement that? I tried it the very simplistic way but
VarD just returns unevaluated.


> Your first point is something that reaches the current boundaries of
> xTensor. It is certainly possible to have tensors with indices on
> several vector bundles having the same base manifold, and it is also
> possible to have objects with several manifold dependencies, and then
> indices on different vector bundles on those manifolds. We use this a
> lot in gauge theories, spinor calculus or symmetry reductions, for
> example, and works well. Alfonso Garcia-Parrado helped me designing
> this part, a few years ago. It is also simple to define bitensors, by
> having duplicates of all geometric structures. But there is not yet a
> concept of mapping between two manifolds in xTensor, and hence there
> is no natural way of definining the tangent mapping. It is perfectly
> possible to construct directly the tensor Tf[A,-a] in xTensor, but it
> is not so clear how to store the manifold dependencies of this tensor,
> or in other words, how to handle its derivatives within the current
> structure of xTensor. The key commands to think about are
> SlotsOfTensor and DependenciesOfTensor.

Thanks for that explanation. Actually, the map character is not really
that essential. It is what I am really dealing with but for
calculations it does not really play a role. How do I define bitensors
then? I have seen product manifolds but I guess that's not what you
refer to.

Sorry for being obtuse.

Cheers, Jörg


--
Jorg Frauendiener | Tel.: +64-3-479-7770
Mathematics & Statistics | Fax: +64-3-479-8427
University of Otago | joe...@maths.otago.ac.nz

P.O. Box 56 | jorg.fra...@otago.ac.nz

Leo Stein

unread,
Jan 25, 2010, 6:20:30 PM1/25/10
to Jörg Frauendiener, xAct Tensor Computer Algebra
Jörg,
I find that VarD does the right thing as long as you define your function use DefScalarFunction. For example,
DefScalarFunction[f]
DefTensor[H[a,b],M]
DefTensor[A[a,b],M]
VarD[ H[c,d] ][ f[ H[a,b]A[-a,-b] ] ]
should return
A[-c,-d] f'[ Scalar[ H[a,b]A[-a,-b] ] ]
as expected.
I have found an issue, though, when the same indices are used in the first and second arguments of VarD. For example,
VarD[ H[a,b] ][ f[ H[a,b]A[-a,-b] ] ]
incorrectly gives
16 A[-a,-b] f'[ Scalar[ H[c,d]A[-c,-d] ] ] .

I defer to more knowledgeable veterans for your second question!
Cheers
Leo

JMM

unread,
Jan 25, 2010, 7:19:32 PM1/25/10
to xAct Tensor Computer Algebra

Hi again Jörg!

> Now comes the next level of  
> complication: Let's say I have n=A_{ab} H^{ab} and rho=f(n) for some  
> unknown function f. I would like to get d rho/d h^{ab} = f'(n) A_{ab}.  
> How would I implement that? I tried it the very simplistic way but  
> VarD just returns unevaluated.

Yes. You have to declare a scalar-function, using DefScalarFunction
[ f ]. That tells xTensor that f must be treated as a scalar function
of a number (any number) of scalar arguments. Then you can do VarD[ h
[a,b] ][ F[ Scalar[ A[-a,-b]H[a,b] ] ] ]. Here the Scalar head is not
compulsory, but helps in preventing dummy collisions. If you are going
to take variational derivatives with respect to the metric, you must
be careful to introduce tensors with indices in their correct heights,
because metric factors might be overlooked. The command SeparateMetric
[g][ expr ] helps in moving all indices to their original position,
adding the necessary metric factors.

Two more comments on variational derivatives: First, this is an area
of xTensor which has not been intensively tested, so do as many checks
as you can. Second, if you need to perform variational derivatives
with respect to the metric, it is possible to link to the package
xPert, which knows everything about perturbations of the curvature
tensors, and hence it is much faster to perform say the variational
derivative of the Riemann tensor with respect to the metric.

> Thanks for that explanation. Actually, the map character is not really  
> that essential. It is what I am really dealing with but for  
> calculations it does not really play a role. How do I define bitensors  
> then? I have seen product manifolds but I guess that's not what you  
> refer to.

In xTensor there is no concept of point. The basic entity is the
tensor field, manipulated algebraically, and not tensors at points
from which you construct the field. But xTensor allows you to have a
tensor which depends simultaneously on several manifolds,
independently. For instance you can do:

DefManifold[ M1, dim, {a1,b1,c1,d1,...} ]
DefManifold[ M2, dim, {a2,b2,c2,d2,...} ]

Now you can have a tensor

DefTensor[ T[ a1, b2 ], { M1, M2 } ]

which is simultaneously a vector field of the bundle TangentM1 and a
vector field of the bundle TangentM2. Now you can have derivatives PD
[ -a1 ][ ... ] and derivatives PD[ -a2 ][ ... ] acting independently
on those two manifolds, etc. Hence this simulates a bitensor at two
different points of the same manifold M. The key issue, however, is
that these two manifold dependencies are assumed unrelated in xTensor.
Hence, I'm not sure this can be directly used to construct the tangent
mapping. To me the tangent mapping is not what I understand as a
bitensor (in which the two points play the same role); it is more the
concept of "tensor field along a map", and that is something that
xTensor does not handle yet, though I'd really like to have it in the
future.

Cheers,
Jose.

JMM

unread,
Jan 25, 2010, 7:33:09 PM1/25/10
to xAct Tensor Computer Algebra
Thanks Leo! Indeed, that is the sort of thing that can be prevented by
using the Scalar head. But it is better to fix it, anyway: go to lines
7235 and 7237 of xAct/xTensor.m and change the first "expr" by
"ReplaceDummies[expr]". That is, change in both lines

VarD[tensor,der][expr , ... ]

by

VarD[tensor,der][ReplaceDummies[expr], ... ]

That should solve the issue.

Thanks again,
Jose.

On Jan 26, 12:20 am, Leo Stein <leo.st...@gmail.com> wrote:
> Jörg,
> I find that VarD does the right thing as long as you define your function
> use DefScalarFunction. For example,
> DefScalarFunction[f]
> DefTensor[H[a,b],M]
> DefTensor[A[a,b],M]
> VarD[ H[c,d] ][ f[ H[a,b]A[-a,-b] ] ]
> should return
> A[-c,-d] f'[ Scalar[ H[a,b]A[-a,-b] ] ]
> as expected.
> I have found an issue, though, when the same indices are used in the first
> and second arguments of VarD. For example,
> VarD[ H[a,b] ][ f[ H[a,b]A[-a,-b] ] ]
> incorrectly gives
> 16 A[-a,-b] f'[ Scalar[ H[c,d]A[-c,-d] ] ] .
>
> I defer to more knowledgeable veterans for your second question!
> Cheers
> Leo
>
> On Mon, Jan 25, 2010 at 6:04 PM, Jörg Frauendiener <
>

> > P.O. Box 56               | jorg.frauendie...@otago.ac.nz

Jörg Frauendiener

unread,
Jan 25, 2010, 7:41:24 PM1/25/10
to xAct Tensor Computer Algebra
Hi Leo, Jose

thanks for the very helpful comments. I'll see how things work out
with VarD now. It is not metric perturbations I am looking at (at
least not immediately). One further question: I realise that the idea
of VarD is to compute the variations of a (obviously scalar)
Lagrangian density, i.e., a functional which is thought of as being
integrated over all space(time). That's why VarD performs the partial
integration automatically. But what if one is not really interested in
that? In my case, I want to compute the linearisation of a certain
operator with respect to a basic tensor field. Or, for that matter,
what if you do not have vanishing boundary terms in a variational
problem? One could (or could one?) also include the boundary term in
the result as a total divergence or so?


>
> In xTensor there is no concept of point. The basic entity is the
> tensor field, manipulated algebraically, and not tensors at points
> from which you construct the field. But xTensor allows you to have a
> tensor which depends simultaneously on several manifolds,
> independently. For instance you can do:
>
> DefManifold[ M1, dim, {a1,b1,c1,d1,...} ]
> DefManifold[ M2, dim, {a2,b2,c2,d2,...} ]
>
> Now you can have a tensor
>
> DefTensor[ T[ a1, b2 ], { M1, M2 } ]
>
> which is simultaneously a vector field of the bundle TangentM1 and a
> vector field of the bundle TangentM2. Now you can have derivatives PD
> [ -a1 ][ ... ] and derivatives PD[ -a2 ][ ... ] acting independently
> on those two manifolds, etc. Hence this simulates a bitensor at two
> different points of the same manifold M. The key issue, however, is
> that these two manifold dependencies are assumed unrelated in xTensor.
> Hence, I'm not sure this can be directly used to construct the tangent
> mapping. To me the tangent mapping is not what I understand as a
> bitensor (in which the two points play the same role); it is more the
> concept of "tensor field along a map", and that is something that
> xTensor does not handle yet, though I'd really like to have it in the
> future.

I see what you are saying. In my case I do have a map and I am dealing
with its derivatives. But I think I can cope with what's available in
xTensor because the map is rather simple and I might just use scalar
functions for its components. I thought of a more general case.

Thanks again,
Jörg


Leo Stein

unread,
Jan 25, 2010, 9:44:11 PM1/25/10
to xAct Tensor Computer Algebra
Jose and experts,

There are still some things I don't understand about VarD. One is the second part of the head, the derivative operator with which to integrate by parts. This shows my lack of understanding of differential geometry.

I know the Stokes theorem, in regular integration, allows the integral of a derivative to be evaluated as a boundary term, which in the case of VarD vanishes by assumption. In this case, the derivative in question is a partial derivative. There is also the generalized theorem which makes a statement for integrals on curved manifolds which might have a different natural volume element than just dx^dy^dz etc. In this case, if one is integrating against the natural volume element, a covariant derivative (really an exterior derivative, but for us the same as a covariant divergence of a vector field) turns into a boundary term which by assumption vanishes.

How is it that one can then choose what derivative operator to use for integration by parts? If the integrand is of the form
  CD[-a][ S[] ] v[a]
and the natural volume element is _implied_, then one can integrate by parts using CD and get the right answer. But if the integrand is
  Sqrt[ -Detg[] ] CD[-a][ S[] ] v[a]
with the volume element _explicit_, then one must integrate by parts using PD -- which results in some connection coefficients, which disappear if you use ChangeCovD. The result is the same as before, but multiplied by the volume element.

It seems to me that there is only one correct choice in each of those instances. VarD with a different derivative operator shouldn't make sense. Please let me know what I am not understanding, as I am just a lowly physicist with inadequate mathematics background.

The inclusion or exclusion of the volume element is important if one is varying with respect to the metric, as the volume element contributes a variation. Here is another point I don't understand: it seems to me that 
  VarD[g[a,b], der][ Detg[], rest ]
should not depend on the derivative operator der, since no integration by parts is needed to evaluate the variation. However, when Detg[] is defined, only
  VarD[g[a,b], PD][ Detg[], rest ]
is defined. This means that VarD[g[a,b], CD][ Detg[] ] vanishes, whereas I feel that it should produce the same result. Is this wrong? (Per my above reasoning, one wouldn't actually want to use CD if Detg[] was explicit, but that's not the point)

As a side note, at first I was confused about how VarD[g[a,b]][Detg[]] was evaluated, since xAct`xTensor`Private`ImplicitTensorDepQ[Detg, g] evaluates to False.

Cheers
Leo

joergf

unread,
Jan 25, 2010, 11:17:15 PM1/25/10
to xAct Tensor Computer Algebra
Hi Jose,

> Thanks Leo! Indeed, that is the sort of thing that can be prevented by
> using the Scalar head. But it is better to fix it, anyway: go to lines
> 7235 and 7237 of xAct/xTensor.m and change the first "expr" by
> "ReplaceDummies[expr]". That is, change in both lines
>
> VarD[tensor,der][expr , ... ]
>
> by
>
> VarD[tensor,der][ReplaceDummies[expr], ... ]
>
> That should solve the issue.

Just a remark: I tried to change this as you indicated. However, in my
file xTensor.m the line numbers that you specify are not correct. They
refer to code in the section on `Bracket'.
Also, I downloaded the latest version and found that I could not link
to the executable anymore. I am on Mac OSX 10.6 and I suspect that the
issue comes from the fact that the executable is for the i386
architecture, whereas I am running the x86_64 architecture. After
recompiling the xperm.c (following the post by Barry Wardell) this
was fixed.

Cheers, Jörg

RR

unread,
Jan 26, 2010, 4:47:10 AM1/26/10
to xAct Tensor Computer Algebra
Hi all!
@ Leo: Thanks for the hint about the problem with same indices.
Luckily this didn't change our expressions...
Concerning the CovD's in VarD Jose ones told me about this book:
Bryce DeWitt "The global approach to QFT"
(chap 15 p 253)
There is a concept of variational derivatives that indeed involves
covariant instead of partial derivatives. I'm not familiar with that
either, but I think this is the point where one can start to read.

@ Joerg, Jose: I think it must be lines 7325, 7327

Ronny

JMM

unread,
Jan 26, 2010, 9:29:52 AM1/26/10
to xAct Tensor Computer Algebra
Hi again,

I'll try to answer all recent emails here.

1) Ronny is right: the lines to change are 7325 and 7327, in the last
version of xTensor.m (of {2010,1,10}). I copied the wrong numbers.

2) Jörg, The executable provided in the xAct bundle was compiled with
10.5, and this might also explain why you had to recompile. In any
case, this is a frequent issue with Mac.

VarD is still a simple command (a few dozens lines of code only), and
indeed assumes that there are no boundary terms. This can be modified,
because only one line in the code makes that assumption. It is line
7360, which says

VarD[ tensor_, covd_ ][ covd_Symbol?CovDQ[ ind_ ][ expr_ ], rest_ ] :=
- VarD[ tensor, covd ][ expr, covd[ ind ][ rest ] ] ;

Something should be added on the right hand side, but I'm not sure
what would be the best notation, to keep index consistency. I have the
impression that if what is needed is linearization, the xPert package
could be a better tool. All terms are kept there, and xPert knows
everything about perturbing curvature tensors, at any order of
perturbation and always in covariant form.

3) Now Leo's questions: VarD does not have the syntax it should. I
mean, We should take derivatives of integrated objects, say something
of the form Integration[ scalar, volumeform ], and not directly of
their integrands. But that would require designing a language for
integration in xTensor, and even worse, designing a language for
differential forms, which is not very natural in such an index-
manipulator as xTensor is. Those are plans for the future. Hence, I
decided to simplify the notation, not storing the volume form, but
just the derivative to be used to perform integration by parts. I
think the link is that a volume form omega defines a divergence
operator div, using that for any vector field X we have Lie_X omega
= (div X) omega . I agree that for a given integrand it is not
possible to use any derivative you want, but I don't think that by
having the integrand you know which derivative you have to use
(essentially, how do you separate the Lagrangian from the volume form?
Some kind of arbitrary normalization seems to be required). I don't
see any simple notion of your "_implied_", and hence we have to
specify somewhere which volume form or derivative we use. I simply
assume that the user will know what is going on.

Concerning metrics, they are handled using special code, and that is
why they do not follow the rules of ImplicitTensorDepQ.

I think nobody has ever tested VarD using derivatives other than the
default PD, and so this part might be buggy. Unfortunately I don't
have the time to rethink all of this now, sorry. My main objective in
allowing derivatives other than PD-type derivatives was to construct a
VarD operator which, starting from a Lagrangian given in terms of
geometric objects (no PD, Christoffels, densities, etc), was able to
return a geometric result as well. Working with PD has a tendency to
give an answer full of PD derivatives of the metric, and to do it
slowly. I stopped pushing in this direction because linking to xPert
already provides these nice results, and fast.

Cheers,
Jose.

JMM

unread,
Jan 28, 2010, 5:59:20 AM1/28/10
to xAct Tensor Computer Algebra
On Jan 26, 1:41 am, Jörg Frauendiener <joerg.frauendie...@gmail.com>
wrote:

> In my case I do have a map and I am dealing  


> with its derivatives. But I think I can cope with what's available in  
> xTensor because the map is rather simple and I might just use scalar  
> functions for its components.

OK. There is then a special detail you should be aware of. If you
define a tensor with indices in a vector bundle VB, xTensor
automatically adds the base manifold of VB in the list of dependencies
of the tensor (DependenciesOfTensor). This is a "safety feature" I
added from the very beginning, but which could be an obstacle in your
computations, because perhaps you want to define the tangent mapping
of F as a tensor dF[ A, -b ] but with dependencies on only one of the
manifolds. This can be easily fixed by removing the second argument of
Union in the following lines (inside the code of DefTensor, around
line 3828 of the last version of xTensor.m)

alldependencies=
Union[
baseifbundle/@Flatten[{dependencies}] ,
BaseOfVBundle/@DeleteCases[VBundleOfIndex/@{indices},Labels]
];

Cheers,
Jose.

Jörg Frauendiener

unread,
Jan 28, 2010, 5:49:44 PM1/28/10
to JMM, xAct Tensor Computer Algebra
Hi all,

@Jose: Thanks for letting me know. So far my calculations went quite
smoothly. But it will get more complicated soon.

@Leo: The question with the derivative operators is a nuisance but not
really a problem. The point is that an action should best be
considered as an integral over a n-form (usually 4-form). Then the
derivative operator is naturally the exterior derivative and this does
not need any knowledge about metrics or coordinates.

The problems come in because we tend to write the Lagrangian not as a
n-form but as a scalar times a preferred n-form. This could be the
metric volume form (if there is a metric floating around) or simply
the coordinate n-form dx1^dx2^...^dxn. In both cases there is then a
preferred choice of derivative operator: in the first case it is the
Levi-Civita connection for the metric, in the other case it is the
partial derivative with respect to the coordinates. In both cases the
derivative of the chosen n-form vanishes so one only has to deal with
the derivative of the (scalar) Lagrangian.
A complication arises when one tries to use a derivative operator
which is not compatible with the chosen n-form, such as the partial
derivatives and the metric n-form. Then one needs to deal with the
factors \sqrt{g}.
But in principle one could use any derivative operator (even ones with
torsion) and any n-form to compute the boundary terms. One needs to
know how the derivative acts on the n-form in order to work things out.
I hope this helps a bit.

Cheers, Jörg

Jörg Frauendiener

unread,
Feb 1, 2010, 6:29:32 PM2/1/10
to xAct Tensor Computer Algebra
Hi all,

in connection to the variational derivative I have the following
question.

I would like to take the derivative with respect to a symmetric tensor
H_{AB} of its inverse, lets say K^{AB}. These are 3d-tensors so in
principle I can write down a formula for K in terms of H but this
becomes quite awkward. So I would like to define something like

VarD[H[-P_,- Q_], PD_][K[A_, B_], x_] := -x (K[A, P] K
[Q, B] + K[A, Q] [P, B])

For some reason which evades my limited Mathematica knowledge this
does not work. I get
VarD[ H[-C,-D] ] [K[A,B] L[-A,-B]] = 0, and similar results.

I can define the result when VarD acts on a given scalar, as in

VarD[H[-P_, -Q_], PD_][n, x_] := -1/2 x n K[P, Q]

Anyone knows how to define what I want appropriately?

Cheers, Jörg

RR

unread,
Feb 2, 2010, 3:37:50 AM2/2/10
to xAct Tensor Computer Algebra
Hi Joerg,

> I would like to take the derivative with respect to a symmetric tensor  
> H_{AB} of its inverse, lets say K^{AB}. These are 3d-tensors so in  
> principle I can write down a formula for K in terms of H but this  
> becomes quite awkward. So I would like to define something like
>
>                  VarD[H[-P_,- Q_], PD_][K[A_, B_], x_] := -x (K[A, P] K
> [Q, B] + K[A, Q] [P, B])
>
> For some reason which evades my limited Mathematica knowledge this  
> does not work. I get
> VarD[ H[-C,-D] ] [K[A,B] L[-A,-B]]  = 0, and similar results.

I'm not sure, but I think by default VarD assumes that K does not
implicitly depend on H. So, it returns 0. It seems that Mathematica
prioritizes earlier definitions, in particular those definitions of
VarD that are made in xTensor.m. One solution is maybe to make K
implicitly H dependent:

xAct`xTensor`Private`ImplicitTensorDepQ[K,H] := True;

What is definitely working for me as an abbreviation for the curvature
is the following

RicciD3 /: VarD[metrich[i_, j_], PD ][ RicciD3[-k_, -l_], rest_] :=
Module[{m,m1},VarD[metrich[i, j], PD ][ RiemannD3[m, -k, -m1, -l],
delta[-m, m1] rest]];

So, I don't define this for VarD, but for RicciD3. I think you could
use this line

K /: VarD[H[-P_,- Q_], PD_][K[A_, B_], x_] := -x (K[A, P] K[Q, B] + K


[A, Q] [P, B])

Ronny

Reply all
Reply to author
Forward
0 new messages