Functional derivatives

537 views
Skip to first unread message

Eckhard

unread,
Dec 10, 2010, 6:24:37 AM12/10/10
to xAct Tensor Computer Algebra
Hi all,
I have a question about functional derivatives. I know there was a
discussion about this here and I tried to reply there but that was not
possible so I started a new one.
I want to calculate Poisson Brackets of tensors and would thus need a
functional derivative acting on tensors. In the old discussion Jose
wrote:
>There is a command VarD in
> xTensor which performs what you want, with notation VarD[ T ][ S ],
> meaning thederivativeof 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 firstderivativemust 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.
The trick does what I want and is perfectly working. Now I thought
about automatizing it and was totally lost. First I would need to
generate the arbitrary tensor with the right indices to contract it.
Then I would need a general step to get rid of it again after the
calculation. I am not experienced enough in Mathematica nor in xAct to
do any of those two steps.
Has anybody a idea how this could work?
Thanks!
Cheers
Eckhard

Eckhard

unread,
Dec 10, 2010, 6:30:22 PM12/10/10
to xAct Tensor Computer Algebra
Hi all,
so after a horrible afternoon during which I learned much about
Mathematic I think I've solved the problem. After all it was easier
than I tought.
For those of you who are interested here is my function:

VarDer[T_, S_] := Module[{x, R, i, in, Ri, uni},
in = IndicesOf[Free][T];
Ri = R @@ Table[ - in[[i]], {i, Length[in] } ] ;
DefTensor[Ri, HostsOf[T]]; uni = signUnique /@ in ;
x = VarD [S][Ri T] /.
R @@ Table[
ToExpression[StringJoin[ ToString[uni[[i]]] , "_" ] ], {i,
Length[in]}] ->
Fold[#1*delta[uni[[#2]], -in[[#2]] ] & 1, 1,
Range[Length[in]] ] ;
UndefTensor[R]; x ]
It uses the function:
signUnique[x_] :=
If[(Characters[ToString[x]][[1]] == "-"), -Unique[-x], Unique[x]]

This is the first time I ever tried to use Mathematica to do anything
more complicated than solving equations, and lots of the things I do
look quick and dirty (although it went not as quick as you might
think) to me, so I am pretty sure that it may look very akward to you.
Don't hesitate to tell me what you think of it as I'm eager to learn
this things.
I have not tested the funtion too thoroughly, so if you find bugs just
tell me.
Cheers,
Eckhard

Leo Stein

unread,
Dec 10, 2010, 8:15:05 PM12/10/10
to Eckhard, xAct Tensor Computer Algebra
Eckhard,

It sounds like you learned a lot today!

Here is how I would do it (I haven't thoroughly tested this, so it
probably has some bugs):

Define a tensor (which really ought to be private, this is the only
thing to use it for) which can take any indices and has no symmetries:

DefTensor[AnyT[AnyIndices@TangentMani], Mani]
SymmetryGroupOfTensor[AnyT[inds___]] ^:= StrongGenSet[{}, GenSet[]]

Then, make you VarDer look more like VarD, allowing it to take a
derivative (PD is the default):

VarDer[S_[inds___], der_: PD][expr_] :=
Module[{frees = IndicesOf[Free][expr], oinds, varn},
oinds = ChangeIndex /@ frees;
varn = VarD[S[inds], der][expr AnyT @@ oinds];
IndexCoefficient[varn, AnyT @@ oinds]]

AnyT is passed whatever the dual indices are in order to be an
appropriate "test tensor" against which expr may be integrated.
varn is the variation of the said expression, and then the function
IndexCoefficient is used to remove the test tensor.

There may be something wrong with the generality of the above code,
but it worked on some (overly) simple test cases I ran.

Cheers
Leo

PS In general it's recommended to stay away from using string
manipulation to do symbol manipulation.

Leo Stein

unread,
Dec 11, 2010, 9:08:52 AM12/11/10
to Eckhard, xAct Tensor Computer Algebra
Sorry, I just realized that both this and the function you proposed
only work for algebraic expressions. If you have a derivative acting
on the tensor that you're trying to differentiate with respect to,
you'll end up taking a derivative of the test function, which can't be
abstracted off with IndexCoefficient.

I don't know if this is relevant for you, but just making sure it's
out there and it doesn't surprise anyone.

Leo

Eckhard

unread,
Dec 13, 2010, 5:51:12 AM12/13/10
to xAct Tensor Computer Algebra
Hi Leo,
thanks. Your function looks a lot more elegant than mine.
> PS In general it's recommended to stay away from using string
> manipulation to do symbol manipulation.
That is what I meant with dirty. But I wasn't able to find a way of
converting x to x_ for the elements of the class and for signUnique I
was simply to lazy to thin about another way.

> I don't know if this is relevant for you, but just making sure it's
> out there and it doesn't surprise anyone.
It will be relevant so I will have to think about it.

Another problem I have is that I would have to implement something
like:
VarDer[p[a][x]][p[b][y]]=delta[-a,b]delta[x-y]
Were p[a][x] means that the vector p[a] is a function of x and the
second delta is a dirac-delta. As far as I know such a thing is not
yet possible.
The easiest way would be to give the x,y as new parameters to VarDer
and just add the dirac distribution by hand. However this would not
help with expresions like p[a][x]p[-a][y]. So I am pretty sure I would
need some new object, something like a tensor function which is
basically a tensor depending on x.
What do you think is there another easier possibility?
Cheers,
Eckhard

On Dec 11, 3:08 pm, Leo Stein <leo.st...@gmail.com> wrote:
> Sorry, I just realized that both this and the function you proposed
> only work for algebraic expressions. If you have a derivative acting
> on the tensor that you're trying to differentiate with respect to,
> you'll end up taking a derivative of the test function, which can't be
> abstracted off with IndexCoefficient.
>
> I don't know if this is relevant for you, but just making sure it's
> out there and it doesn't surprise anyone.
>
> Leo
>

Leo Stein

unread,
Dec 13, 2010, 5:18:51 PM12/13/10
to Eckhard, xAct Tensor Computer Algebra
Eckhard,
  There is no such thing as a Diract delta built in to xAct, as far as I know (anybody want to correct me?). All tensors are actually tensor *fields* on manifolds, so they indeed do have spatial dependence as you are trying to suggest with t[x].
  Asking for a Dirac delta scalar (what is the density?) field (actually a distribution) seems like a reasonable thing, but I don't know how it would act in xTensor. I'm going to put some thoughts in here, but I might just be embarrassing myself, maybe this stuff has already been thought about elsewhere, but I haven't looked into it.
  Anyway ... to define a Dirac delta function, you have to choose a special point on the manifold; as far as I know, there is no such thing in xTensor right now (except for the proposed AtPoint in xCoba, but that is a different story). You could fake it with the use of label indices, which can be used for any extra structure you want to add to quantities. For example, you could have a delta function at point "p" represented as Ddelta[-LI["p"]] (covariance and contravariance of the label index shouldn't mean anything here). But once you start defining a delta function, you would want quantities such as CD[-a]@Ddelta[-LI["p"]] to be meaningful -- the derivative of a delta function is also a fine distribution. But there are certain things you could now do that don't make sense, like products of distributions.
  So, to solve your problem within the scope of xAct, you could create tensor fields with extra structure, e.g. t[ -LI["p"], a ] -- VarD will be very happy to calculate:

VarD[ t[ -LI["q"], b] ][ t[ -LI["p"], a ] ]

delta[-b, a] delta[ LI["q"], -LI["p"] ]

That last object can act as a dirac delta function for your purposes, if you give it the right rules (except it might move through derivatives?).

Adding all of this to xTensor might be a challenge. You may want to implement your operator algebra without messing with xTensor, just as a parallel structure which may also operate on xTensor objects.

Cheers
Leo
Reply all
Reply to author
Forward
0 new messages