7.10. Variational derivatives

There is not yet a concept of integration in xTensor`. Instead of working with a variational derivative of a functional, we shall assume that such a functional is the integral of some integrand (or "Lagrangian") and that the integral is computed with respect to a volume form which vanishes under the action of some derivative (this is the derivative which will be "integrated by parts").

Let us fake the presence of a scalar density:

In[761]:=

DefTensor[s[], M3]

** DefTensor: Defining tensor s[] .

We need only these two properties:

In[762]:=

s/:VarD[metricg[a_, b_], PD][s[], rest_] := -rest/2metricg[-a, -b] s[]

In[763]:=

s/:PD[a_][s[]] := 1/2Module[{c, d}, s[] metricg[c, d] PD[a][metricg[-c, -d]]]

For instance, let us compute the RicciScalar field of our metric:

In[764]:=

rs = RicciScalarCD[]//RiemannToChristoffel//ChristoffelToGradMetric//Expand

Out[764]=

Working intensively with partial derivatives, it is interesting to set

In[765]:=

SetOptions[ToCanonical, UseMetricOnVBundle→None]

Out[765]=

{Verbose→False, Notation→Images, UseMetricOnVBundle→None, ExpandChristoffel→False, GivePerm→False}

Now we perform a direct variational derivative of the Einstein-Hilbert Lagrangian with respect to the inverse metric. It is a long computation, producing 501 terms:

In[766]:=

Length[result = Expand @ VarD[metricg[a, b], PD][s[] rs]]

Out[766]=

501

The expected result is the Einstein tensor:

In[767]:=

EinsteinCD[-a, -b]//EinsteinToRicci//RiemannToChristoffel//ChristoffelToGradMetric//ToCanonical

Out[767]=

In[768]:=

result - s[] %//ToCanonical

Out[768]=

0

Let us now define the electromagnetic fields:

In[769]:=

DefTensor[MaxwellA[-a], M3, PrintAs->"A"]

** DefTensor: Defining tensor MaxwellA[-a] .

In[770]:=

DefTensor[MaxwellF[-a, -b], M3, Antisymmetric[{1, 2}], PrintAs->"F"]

** DefTensor: Defining tensor MaxwellF[-a, -b] .

In[771]:=

MaxwellF[a_, b_] := PD[a][MaxwellA[b]] - PD[b][MaxwellA[a]]

This is the electromagnetic Lagrangian:

In[772]:=

metricg[a, b] metricg[c, d] MaxwellF[-a, -c] MaxwellF[-b, -d]/4

Out[772]=

1/4 g_  ^ab g_  ^cd (∂_a^ A_c^ - ∂_c^ A_a^ ) (∂_b^ A_d^ - ∂_d^ A_b^ )

and these are the Maxwell equations on a curved background:

In[773]:=

result = VarD[MaxwellA[a], PD][s[] %]

Out[773]=

In[774]:=

metricg[b, c] CD[-b][MaxwellF[-a, -c]]//ChangeCovD//ChristoffelToGradMetric//ToCanonical

Out[774]=

In[775]:=

result - s[] %//ToCanonical

Out[775]=

0

In[776]:=

UndefTensor/@{s, MaxwellA, MaxwellF} ;

** UndefTensor: Undefined tensor s

** UndefTensor: Undefined tensor MaxwellA

** UndefTensor: Undefined tensor MaxwellF

Restore standard options:

In[777]:=

SetOptions[ToCanonical, UseMetricOnVBundle→All]

Out[777]=

{Verbose→False, Notation→Images, UseMetricOnVBundle→All, ExpandChristoffel→False, GivePerm→False}


Created by Mathematica  (May 16, 2008) Valid XHTML 1.1!