The variational derivative

Theoretical summary

Let an action S=(∫_Ω)ℒ η be given (Ω⊆(ℝ^n), η volume n-form). If the Lagrangian density ℒ depends on a set of fields (Subscript[φ, 1]),⃛,(Subscript[φ, k]) and their covariant derivatives with respect to a connection (Subscript[D, a]) compatible with the volume form η , then, the standard computation using the integration by parts yields the variation of the action  

	δ S=(∑_j)(∫_Ω)(((δℒ)/(Subscript[δφ, i])))(Subscript[δφ, i])η+(∫_Ω)((Subscript[D, a])(J^a))η.
	
The quantity ((δ ℒ)/(δ (Subscript[φ, i]))) is the variational derivative of the Lagrangian density with respect to the field (Subscript[φ, i]) and (J^a) is linear in the field variations (Subscript[δφ, i]). Since (Subscript[D, a]) is compatible with the volume form then we can use the Gauß theorem to transform the last integral (∫_Ω)((Subscript[D, a])(J^a))η into a boundary term

	(∫_Ω)((Subscript[D, a])(J^a))η=(∫_(∂Ω))⟨n,(OverVector[J])⟩(Subscript[i, (OverVector[n])])η,
	
where n is the normal 1-form to the boundary, chosen in such a way that the n-1 form (Subscript[i, (OverVector[n])])η  is non-degenerate. As is well-known, when the boundary term is zero, the dynamical equations of the theory described by the Lagrangian density ℒ are given by

	((δ ℒ)/(δ (Subscript[φ, i])))=0.

It is to be stressed that in this framework the definition of the variational derivative requires a choice of a connection compatible with the volume n-form. This means that the variational derivative is defined with respect to such a connection.

Let us make a perturbative expansion of the fields (Subscript[φ, 1]),⃛,(Subscript[φ, k]): 

	(Subscript[φ, i])=(Subscript[φ, i]^((0)))+(Subscript[φ, i]^((1)))+⋯
	
This leads to a perturbative expansion of the Lagrangian density:

	ℒ=(ℒ^((0)))+(ℒ^((1)))+⋯ ,

where (ℒ^((1))) is the linearization of ℒ around (Subscript[φ, i]^((0))). One has that 

	(Subscript[(((δ ℒ)/(δ (Subscript[φ, i])))), (Subscript[φ, i])=(φ^((0)))])=(Subscript[(((δ (ℒ^((1))))/(δ (Subscript[φ, i]^((1)))))), (Subscript[φ, i]^((1)))=(φ^((0)))]) 

(recall that (ℒ^((1)))=(ℒ^((1)))((Subscript[φ, 1]^((0))),… ,(Subscript[φ, k]^((0))),(Subscript[φ, 1]^((1))),… ,(Subscript[φ, k]^((1))))  and it is linear in the first order perturbations (Subscript[φ, 1]^((1))),… ,(Subscript[φ, k]^((1))) ). Therefore if (ℒ^((1))) is known, it can be used to compute the variational derivative, instead of ℒ.

Start a new xTensor session.

<<xAct`xTensor`

$PrePrint=ScreenDollarIndices;

$DefInfoQ=False;

DefConstantSymbol[dim,PrintAs->"d"]

DefManifold[M,dim,{a,b,c,d,f,g,h}]

DefMetric[-1,metricg[-a,-b],CD,PrintAs->"g"]

Implementation of the variational derivative in xTensor:

?VarD

We define the real Klein-Gordon scalar field & action:

DefTensor[φ[],M]

LagrangianDensity=Sqrt[-Detmetricg[]]metricg[a,b]PD[-a]@φ[]PD[-b]@φ[]

For this Lagrangian density we can take the covariant derivative PD as the derivative compatible with the volume n-form:

VarD[φ[],PD][LagrangianDensity]

ChangeCovD[%,PD,CD]

ToCanonical@ContractMetric@%

ContractMetric[%,AllowUpperDerivatives->True]

Let us now define the electromagnetic vector potential & electromagnetic field:

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

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

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

MaxwellF[-a,-b]

This is the electromagnetic Lagrangian density with no charges:

LagrangianDensity=Sqrt[-Detmetricg[]]metricg[a,b]metricg[c,d]MaxwellF[-a,-c]MaxwellF[-b,-d]/4

Again we can take the covariant derivative PD as the derivative compatible with the volume n-form:

VarD[MaxwellA[a],PD][LagrangianDensity]

ChangeCovD[%,PD,CD]

ToCanonical@ContractMetric[%,AllowUpperDerivatives->True]

Simplify@%

Faster procedure using the Levi-Civita covariant derivative CD to compute the variational derivative:

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

MaxwellF[-a,-b]

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

VarD[MaxwellA[a],CD][LagrangianDensity]

ToCanonical@ContractMetric[%,AllowUpperDerivatives->True]

Application: variational formulation of the Einstein’s equations

We introduce some preliminaries:

ApplyRule[expr_]:=MakeRule[Evaluate[List@@expr],MetricOn->All,ContractMetrics->True]

Express the partial derivatives of the Christoffel tensors in terms of the Ricci tensor:

RiemannCD[-a,-b,-c,d]==ChangeCurvature[RiemannCD[-a,-b,-c,d],CD]

%/.d->b

ScreenDollarIndices@%

(Solve[%,PD[-b]@ChristoffelCD[b,-a,-c]]//Flatten//First)/.Rule->Equal

CovDivChristoffel=%;

The Palatini formulation

In the Palatini formulation one does not make the initial assumption that the covariant derivative is compatible with the metric:

DefCovD[cd[-a],SymbolOfCovD->{";","(OverTilde[∇])"}]

First of all, we find the relation between the derivative of the Christoffel symbols and the curvature:

Riemanncd[-a,-b,-c,d]==ChangeCurvature[Riemanncd[-a,-b,-c,d],cd]

%/.d->b

ScreenDollarIndices@%

(Solve[%,PD[-b]@Christoffelcd[b,-a,-c]]//Flatten//First)/.Rule->Equal

CovDivChristoffelcd=%;

Next, we compute the variational derivative of the Einstein-Hilbert action:

Sqrt[Detmetricg[]]metricg[a,b]Riccicd[-a,-b]

Express the action in terms of the independent variation variables:

theAction=ChangeCurvature[%,cd]

The variation can be made with respect to the connection and with respect to the metric. We start by computing the variational derivative with respect to the metric:

VarD[metricg[-a,-b],PD][theAction]

%/.ApplyRule@CovDivChristoffelcd

ToCanonical@%

Simplify@%

This is the first dynamical equation:

Last@%

EinsteinEq=%;

Now, we compute the variational derivative with respect to the other independent field:

VarD[Christoffelcd[a,-b,-c],PD][theAction]

Express the partial derivatives of the metric in terms of the Levi-Civitta connection:

GradMetricToChristoffel[%]

ToCanonical@ContractMetric@%

Simplify@%

FullSimplify@%

If we assume that the matter part is independent from the connection, then we have:

Last@%==0

This is the second dynamical equation:

%/.c->-c

expr=%;

This equation can be simplified, as shown next:

expr/.b->a

ToCanonical@ContractMetric@%

ScreenDollarIndices@%

Solve[%,Christoffelcd[-c,a,-a]]//Flatten

Equal@@First@%

expr/.ApplyRule@%

ToCanonical@%

expr=%;

expr/.b->c

ToCanonical@%

ScreenDollarIndices@%

Solve[%,Christoffelcd[c,-a,-c]]//Flatten

Equal@@First@%

connectiontrace=%;

expr/.ApplyRule@%

ToCanonical@%

Times[#,-1/2]&/@%

Expand/@%

expr=%;

expr/.MakeRule[{ChristoffelCD[a,-b,-c],ChristoffelCD[a,-b,-c]},MetricOn->All,ContractMetrics->False]

%/.MakeRule[{Christoffelcd[a,-b,-c],Christoffelcd[a,-b,-c]},MetricOn->All,ContractMetrics->False]

ScreenDollarIndices/@%

Simplify/@%

ChristoffelToGradMetric@%

ToCanonical[%,UseMetricOnVBundle->None]

%/.b->-b

ContractMetric@%

Use the classical argument to find ({{Γ[(OverTilde[∇])], ({{ ,  ,  }, {b, a, c}})}}):

part1=%;

ReplaceIndex[Evaluate@part1,{-b->-a,-a->-c,-c->-b}]

ReplaceIndex[Evaluate@%,{-b->-a,-a->-c,-c->-b}]

First@part1+First@%%-First@%==0

ToCanonical@%

Solve[%,Christoffelcd[-b,-a,-c]]//Flatten

Equal@@First@%

Hence the connection cd is just the Levi-Civitta connection CD . Use this information in the Einstein equation:

EinsteinEq/.ApplyRule@connectiontrace

%//ChristoffelToGradMetric

ToCanonical@%

%/.Riccicd->RicciCD

%//RicciToEinstein

ToCanonical@%

We recover the known result that the variation of the Einstein-Hilbert Lagrangian yields the compatibility of the metric with the connection + Einstein tensor.

Variation of Lagrangians using perturbation theory

Adapted from 
https://github.com/xAct-contrib/examples/blob/master/Lagrangian-variation-xPert-VarD.nb

As already explained, the linearization of the Lagrangian density with respect to the perturbations of the fields can enable us to compute the variational derivative and the equations of motion. The xAct suite has a package for doing perturbation expansions (the package xPert) and can therefore be used for this purpose.

Needs["xAct`xPert`"]

$CovDFormat="Prefix";

Example: General Relativity

The package xPert is able to compute the metric perturbations of any geometric quantity. This is going to be most useful when computing variational derivatives of Lagrangian densities defined in terms of Riemann tensor scalars.

Define the metric perturbation:

?DefMetricPerturbation

DefMetricPerturbation[metricg,δg]

Here’s the Lagrangian density for GR:

LGR=Sqrt[-Detmetricg[]]RicciScalarCD[]

Linearize the Lagrangian density and take the relevant part:

LGRpert=ExpandPerturbation@Perturbation@LGR//ContractMetric//Simplification

Last@%/2

We are ready to compute the variational derivative:

VarD[δg[LI[1],a,b],CD]@%

%/.delta[-LI[1],LI[1]]->1//Expand

%//RicciToEinstein

ToCanonical@ContractMetric@%

Example: f(R) theory

Construct the corresponding Lagrangian density and compute its linearization:

DefScalarFunction[F]

LFR=Sqrt[-Detmetricg[]]F[RicciScalarCD[]]

LFRpert=ExpandPerturbation@Perturbation@LFR//ContractMetric//Simplification

Compute the variational derivative:

1/2Last@%

VarD[δg[LI[1],a,b],CD]@%

%/.delta[-LI[1],LI[1]]->1//Expand

ToCanonical@ContractMetric@%

Collect[%,metricg[-a,-b],Simplify]

Example: Scalar-Tensor theory

Let us add a scalar field ϕ with potential U(ϕ) and coupling function A(ϕ) . Define these objects:

DefTensor[ϕ[],M]
DefScalarFunction/@{U,A};

We also need a tensor perturbation for the scalar field:

DefTensorPerturbation[δϕ[LI["order"]],ϕ[],{M}]

Here is the Lagrangian for this theory:

LST=Sqrt[-Detmetricg[]](A[ϕ[]] RicciScalarCD[]-(1/2)CD[-a]@ϕ[] CD[a]@ϕ[]-U[ϕ[]])

We compute the linearization of the Lagrangian density:

ExpandPerturbation@Perturbation@LST//ContractMetric//Simplification

-1/4Last@%

LSTpert=%;

Now again vary with respect to the first order perturbations δg[LI[1],a,b] and δϕ[LI[1]]:

VarD[δg[LI[1],a,b],CD]@LSTpert

%/.delta[-LI[1],LI[1]]->1

Collect[%,{A[_],Derivative[_][A][_]},ContractMetric]

VarD[δϕ[LI[1]],CD]@LSTpert/.delta[-LI[1],LI[1]]->1//Expand

Example: Lovelock gravity

We introduce the Lovelock Lagrangian density:

DefConstantSymbol/@{α,β,γ,κ};

LLovelock=Sqrt[-Detmetricg[]](-β RicciScalarCD[]RicciScalarCD[]+α RicciCD[a,b]RicciCD[-a,-b]+γ κ^(-2)RicciScalarCD[])

Compute the linearized Lagrangian density:

LLovelockpert=ExpandPerturbation@Perturbation@LLovelock//ContractMetric//Simplification

1/(2κ^2)Last@%

Variational derivative:

VarD[δg[LI[1],a,b],CD]@%

%/.delta[-LI[1],LI[1]]->1//Expand

ToCanonical@ContractMetric@%

Collect[%,{α,β,γ},Simplify]