General Relativistic Calculations in Mathematica

By George E. Hrabovsky

What I Will Cover

What is xAct?

What Do We Do Next?

Contraction

Covariant Derivatives

The Second Bianchi Identity

Perturbative GR

What is xAct?

This is a very complete system for doing tensor analysis in the Mathematica system.

All you need do is open the system:

<<xAct`xTensor`

What Do We Do Next?

Now that we have started things up, there are some things we need to do.

We need to define the underlying manifold we are working in. We do this with the DefManifold command: DefManifold[M, dim, {a, b, c,...}] defines M to be an n-dimensional differentiable manifold with dimension dim (a positive integer or a constant symbol) and tensor abstract indices a, b, c, ... .  DefManifold[M, {M1, ..., Mm}, {a, b, c,...}] defines M to be the product manifold of previously defined manifolds M1 ... Mm. For backward compatibility dim can be a list of positive integers, whose length is interpreted as the dimension of the defined manifold. Here we define a four-dimensional manifold having the indices a,b,c,d,e,f,g,h,i,j,k,l:

DefManifold[M,4,{a,b,c,d,e,f,g,h,i,j,k,l}]

In defining the manifold, we have also defined the vector bundle called TangentM, π:TM->M. This is where our tensors will be.

We need to define the metric using the DefMetric command: DefMetric[signdet, metric[-a,-b], covd, covdsymbol] defines metric[-a, -b] with signdet 1 or -1 and associates the covariant derivative covd[-a] to it. Note that we have the convention [-a] has a as the subscript, and [a] has it as the superscript.

DefMetric[-1,metric[-i,-j],cd,{";","∇"},PrintAs->"g"]

We can define tensors using the DefTensor command: DefTensor[T[-a, b, c, ...], {M1, ...}] defines T to be a tensor field on manifolds and parameters M1,... and the base manifolds associated to the vector bundles of its indices. DefTensor[T[-a, b, c, ...], {M1, ...}, symmetry] defines a tensor with symmetry given by a generating set or strong generating set of the associated permutation group. In fact we can define any order of tensor just by specifying the indices. A scalar has no indices so we can define the scalar

DefTensor[s[],M]

s

a tangent vector

DefTensor[tv[i],M]

tv[i]

a covector

DefTensor[cv[-i],M]

cv[-i]

and so on.

We can define tensors by their symmetries or antisymmetries, too. Here we define the tensor (Subscript[T, ij]) that is antisymmetric:

DefTensor[T[-i,-j],M,Antisymmetric[{-i,-j}]];

T[-i,-j]

T[-j,-i]

To make this work, since Mathematica does not enforce our symmetry rules, we need to make it do so by using the ToCanonical command. Let’s try it again

T[-j,-i]//ToCanonical

We can add two such tensors in a way that gives us a 0 result,

T[-i,-j]+T[-j,-i]

T[-i,-j]+T[-j,-i]//ToCanonical

Contraction

We can do some operations. Let’s say we have the Riemann tensor (Subscript[R, ijkl]) and we want to contract it using the metric (g^ik). we use the ContractMetric command,

metric[i,k]Riemanncd[-i,-j,-k,-l]//ContractMetric

Mathematica also understands that this is the Ricci tensor, (Subscript[R, jl]),

metric[i,k]Riemanncd[-i,-j,-k,-l]//ContractMetric//InputForm

Contracting it again gives us the Ricci scalar,

metric[j,l]Riccicd[-j,-l]//ContractMetric//InputForm

Covariant Derivatives

The covariant derivative of our tensor, (Subscript[∇, i])(Subscript[T, jl]), is input

cd[-i][T[-j,-l]]

If we have multiple covariant derivatives, we would enter them as follows, where @ is the Map command:

cd[-a]@cd[-b]@cd[-c]@T[-d,-e]//ToCanonical

To evaluate this we use the command SortCovDs

cd[-a]@cd[-b]@cd[-c]@T[-d,-e]//ToCanonical//SortCovDs

This is correct, but too difficult to interpret, we add the command ScreenDollarIndices to put it into a lnaguage we can read instead of just the computer reading it

cd[-a]@cd[-b]@cd[-c]@T[-d,-e]//ToCanonical//SortCovDs//ScreenDollarIndices

Instead of having to write all of this all of the time we make a session-wide command

$PrePrint=ScreenDollarIndices;

cd[-a]@cd[-b]@cd[-c]@T[-d,-e]//ToCanonical//SortCovDs

The Second Bianchi Identity

Here we seek to reproduce the Second Bianchi identity. We redefine our covariant derivative

DefCovD[CD[-a],{";","∇"}]

We begin by establishing a term

term1=Antisymmetrize[CD[-e][ RiemannCD[-c,-d,-b,a] ],{-c,-d,-e} ]

We sum these,

bianchi2=3term1//ToCanonical

We expand the covariant derivatives in Christoffel symbols:

exp1=bianchi2//CovDToChristoffel

We expand the Riemann tensors in Christoffel symbols

exp2=exp1//RiemannToChristoffel

We canonicalize this to enforce symmetries and antisymmetries,

exp3=exp2//ToCanonical

Which is what we expected.

(Subscript[∇, c])({{R[∇], ({{a,  ,  ,  }, { , b, d, e}})}})+(Subscript[∇, d])({{R[∇], ({{a,  ,  ,  }, { , b, e, c}})}})+(Subscript[∇, e])({{R[∇], ({{a,  ,  ,  }, { , b, c, d}})}})=0

Perturbative GR

We begin this by opening the perturbative package:

<<xAct`xPert

We must first establish our metric perturbation, this is because the metric is a vacuum metric; thus all small perturbations are gravitational waves. We define the metric perturbation using the DefMetricPerturbation[the existing metric, name of the perturbation, perturbation parameter]

DefMetricPerturbation[metric,pert,ϵ]

We can tell Mathematica to write the perturbation using the traditional notation h,

PrintAs[pert]^="h";

A second-order perturbation in the metric is then written

pert[LI[2],-a,-b]

So the first-order perturbation of the metric (Subscript[g, ab]) is

Perturbation[metric[-a,-b],1]

for (g^ab) we have,

Perturbation[metric[a,b],1]

What? What is Δ? It turns out that Mathematica does not know how to perform a perturbation on the inverse metric. We need to use the ExpandPerturbation command,

Perturbation[metric[a,b],1]//ExpandPerturbation

This is not too impressive, let’s try a fourth-order perturbation

Perturbation[metric[a,b],4]//ExpandPerturbation

Let’s examine the third-order perturbed metric

Perturbed[metric[-a,-b],3]

and the inverse metric

Perturbed[metric[a,b],3]//ExpandPerturbation

Jolyon Bloomfield [5] produced a method of extracting only the first-order terms of the expansion, since ϵ is assumed to be small, where we can write the metric as the sum of a linearized metric and a perturbed metric,  (Subscript[g, ab])=(Subscript[(g^0), ab])+(Subscript[h, ab]) we adapt it for our use

firstorderonly=pert[LI[n_],__]:>0/;n>1;

Perturbed[metric[-a,-b],3]/.firstorderonly

Given an action we can derive an equation of motion. First we need to establish our scalar field,

DefTensor[sf[],M,PrintAs->"ϕ"]

We now define the perturbations of the scalar field,

DefTensorPerturbation[pertsf[LI[order]],sf[],M,PrintAs->"δϕ"]

We now define the potential and the Planck mass,

DefScalarFunction[V]
DefConstantSymbol[massP, PrintAs ->"(Subscript[m, p])"]

Now we need to construct the Lagrangian

L=Sqrt[-Detmetric[]]((massP^2)/2RicciScalarcd[]-1/2 cd[-b][sf[]] cd[b][sf[]]-V[sf[]])

We vary the fields

varL=L//Perturbation

We expand this

varL=L//Perturbation//ExpandPerturbation

We perform the metric contractions

varL=L//Perturbation//ExpandPerturbation//ContractMetric

?RicciTo*

Then we enforce the symmetries

varL=L//Perturbation//ExpandPerturbation//ContractMetric//ToCanonical

The scalar equation of motion is then found by taking the variational derivatives of the scalar field and set them equal to 0

0==VarD[pertsf[LI[1]],cd][varL]/Sqrt[-Detmetric[]]

we enforce the Kronecker delta

0==VarD[pertsf[LI[1]],cd][varL]/Sqrt[-Detmetric[]]/.delta[-LI[1],LI[1]]->1

We canonicalize it

0==VarD[pertsf[LI[1]],cd][varL]/Sqrt[-Detmetric[]]/.delta[-LI[1],LI[1]]->1//ToCanonical

There we have it.

We can get the tensor equation of motion,

vartf=2(-VarD[pert[LI[1],a,b],cd][varL]/Sqrt[-Detmetric[]])

This is a mess, so we begin enforcing the Kronecker deltas

vartf=2(-VarD[pert[LI[1],a,b],cd][varL]/Sqrt[-Detmetric[]]/.delta[-LI[1],LI[1]]->1)

We now expand by expressing all Ricci tensors of covariant derivatives in terms of Einstein tensors and Ricci scalars

vartf=2(-VarD[pert[LI[1],a,b],cd][varL]/Sqrt[-Detmetric[]]/.delta[-LI[1],LI[1]]->1//SeparateMetric[metric]//RicciToEinstein)

We expand this

vartf=2(-VarD[pert[LI[1],a,b],cd][varL]/Sqrt[-Detmetric[]]/.delta[-LI[1],LI[1]]->1//SeparateMetric[metric]//RicciToEinstein)//Expand

Then we enforce the symmetries,

vartf=2(-VarD[pert[LI[1],a,b],cd][varL]/Sqrt[-Detmetric[]]/.delta[-LI[1],LI[1]]->1//SeparateMetric[metric]//RicciToEinstein)//Expand//ContractMetric//ToCanonical

We set this equal to 0,

0==vartf

Here we get the conservation of energy

eterm=IndexCollect[cd[a]@vartf//ToCanonical,CD[-b][sf[]]]//Simplify

then

0==eterm

this is degenerate with the scalar equation of motion

Bibliography

[1] M. Nakahara, (2003), Geometry, Topology, and Physics, 2nd Edition, Taylor and Francis Group.
[2] Theodore Frankel, (2012), The Geometry of Physics, 3rd Edition, Cambridge University Press
[3] Jose M. Martin-Garcia, (2009), xAct Intro
[4] B. F. Schutz, (1984), The Use of Perturbation and Approximation Methods in General Relativity. In: Relativistic Astrophysics and Cosmology: Proceedings of the GIFT International Seminar on Theoretical Physics, (Eds.) Fustero, Xavier; Verdaguer, Enric; Singapore: World Scientific 35-98 (1984)
[5] Jolyon Bloomfield, (2013), xAct Tutorial

xAct can be found at the website: http://www.xact.es/index.html

Thank You for Attending!