0. Load xTensor

<<xAct`xTensor`

1. Simple session

1.1. Simple session: define basic objects

Define a 4d manifold:

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

Define a contravariant vector field:

DefTensor[v[a],M]

v[a]

InputForm[%]

The delta tensor:

delta[-a,b]

delta[-a,b]v[a]

delta[-a,a]

Define an antisymmetric covariant vector field:

DefTensor[F[-a,-b],M,Antisymmetric[{-a,-b}]]

F[-a,-b]

1.2. Simple session: canonicalization

No automatic canonicalization. Fully controlled by ToCanonical:

F[-b,-a]

ToCanonical[ F[-b,-a] ]

Commutative products:

v[a]F[-a,-b]v[b]

ToCanonical[%]

Dummies:

expr=F[-a,-d]v[d]v[b]v[-b]+3v[b]v[c]v[-c]F[-b,d]F[-d,-a]

ToCanonical[expr]

Simplify[%]

Simplification[expr]

1.3. Simple session: validation

Our expression is incorrect:

expr

Validate[%]

1.4. Simple session: derivatives

Derivatives are linear operators, defined following Wald:

Options[DefCovD]

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

CD[-a][ v[b] ]

Leibnitz is automatic:

CD[-a][ F[-b,-c]v[c] ]

%v[b]//ToCanonical

1.4. Cont. derivatives

Associated tensors:

{ChristoffelCD[a,-b,-c],TorsionCD[a,-b,-c], RiemannCD[-a,-b,-c,d], RicciCD[-a,-b]}

RiemannCD[-a,-b,-c,d]+RiemannCD[-b,-a,-c,d]//ToCanonical

They can be deduced from other results:

RiemannCD[-a,-b,-c,d]//RiemannToChristoffel

%+RiemannCD[-b,-a,-c,d]//RiemannToChristoffel

ToCanonical[%]

Hide away the dollar-indices:

$PrePrint=ScreenDollarIndices;

RiemannCD[-a,-b,-c,d]//RiemannToChristoffel

1.4. (Second) Bianchi identity

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

3%//ToCanonical

%//CovDToChristoffel

%//RiemannToChristoffel

ToCanonical[%]//AbsoluteTiming

1.5. Simple session: metrics

Define a metric field:

DefMetric[-1,metric[-a,-b],cd,{"|","D"},PrintAs->"g"]

Metric:

metric[-a,-b]

metric[b,c]

metric[-a,-b]metric[b,c]

and its Levi-Civita connection:

cd[-a][ metric[-b,-c] ]

Now:

expr

Validate[%]

1.5. Metric contraction

Metric contraction with other objects is not automatic:

metric[-a,-b]v[b]

ContractMetric[%]

Through derivatives:

metric[-a,-b]cd[-c][ v[b] ]

ContractMetric[%]

metric[-a,-b]CD[-c][ v[b] ]

ContractMetric[%]

ContractMetric[%,OverDerivatives->True]

1.5. Symmetries of Riemann

Symmetries of the Riemann tensor:

Riemanncd[-a,-b,-c,-d]

Riemanncd[-a,-b,-c,-d]+Riemanncd[-a,-b,-d,-c]//RiemannToChristoffel

%//ChristoffelToGradMetric

ToCanonical[%]

1.5. XToY commands

Riemann and Weyl:

Riemanncd[-a,-b,-c,-d]//RiemannToWeyl

Ricci and TFRicci:

Riccicd[-a,-b]//RicciToTFRicci

Ricci and Einstein:

Riccicd[-a,-b]//RicciToEinstein

InputForm[%]

1.6. Rules

Construct a rule:

rule1=MakeRule[{v[a],F[a,b]v[-b]}]

The rule is used following normal Mathematica:

{v[a],v[b],v[c],v[-a],v[-b],v[-c]}/.rule1

MakeRule has lots of options:

Options[MakeRule]

rule2=MakeRule[{v[a],F[a,b]v[-b]},MetricOn->All]

{v[a],v[b],v[c],v[-a],v[-b],v[-c]}/.rule2

ContractMetric[%]

No dummy collisions:

v[a]v[-a]/.rule2

ContractMetric[%]

Symmetries:

rule3=MakeRule[{Riemanncd[-a,-b,-c,-d]v[a],F[-c,-d]v[-b]}]

{Riemanncd[-a,-b,-c,-d]v[c],Riemanncd[-a,-b,c,-d]v[-c]}/.rule3

Remove[rule1,rule2,rule3]

1.7. Undefine objects

These are the objects we have defined:

$Manifolds

$VBundles

$Metrics

$CovDs

$Tensors

IndicesOfVBundle[TangentM]

Undefinition must be done in reverse order:

UndefManifold[M]

UndefMetric[metric]

UndefCovD[CD]

UndefTensor/@$Tensors;

UndefManifold[M]

We only have now

?Global`*

Remove[expr]

2. Mathematics

2.1. Dependencies: manifolds and parameters

Examples:

DefManifold[M3,3,{a,b,c,d,e,f,g}]

DefManifold[M4,4,{A,B,C,D,F,G,H}]

Product manifold:

DefManifold[M7,{M3,M4},{α,β,γ,δ,ϵ,ϕ,χ,η}]

Parameters:

DefParameter[time,PrintAs->"t"]

2.2. Abstract indices: vector bundles (vbundles)

Example of a complex vbundle. Note that it defines its complex conjugate:

?DefVBundle

DefVBundle[complex,M3,2,{𝔄,𝔅,ℭ,𝔇,𝔈,𝔉,𝔊},Dagger->Complex]

IndicesOfVBundle[complex]

IndicesOfVBundle[complex†]

2.3. Tensor fields

Define tensor fields:

DefTensor[scalar[],{M3,time}]

Dependencies on base manifolds are always included:

DefTensor[vector[a],{M4,time}]

DependenciesOfTensor[vector]

Define complex fields:

DefTensor[V[𝔄,a],M3,Dagger->Complex]

V[𝔅,c]

Dagger[%]

DefTensor[T[𝔄,𝔅†],M3,Dagger->Hermitian]

Dagger[T[𝔄,𝔅†]]

2.4. Covariant derivatives (CovDs)

The fiducial PD:

PD[-a][ V[𝔄,b] ]

Define a general connection with torsion, but acting only on the corresponding tangent bundle:

DefCovD[CD[-a],{";","▽"},Torsion->True]

Define a connection acting on our inner vbundle as well:

DefCovD[ICD[-a],complex,{"|","D"}]

2.5. Christoffel *tensors*

Change connection:

ICD[-a][ V[𝔄,b] ]

ChangeCovD[%,ICD,CD]

When one of the derivatives is PD then it is not explicit:

ChangeCovD[%%,ICD,PD]

Christoffels are antisymmetric in their derivative arguments:

Christoffel[ICD,CD][a,-b,-c]

Christoffel[CD,ICD][a,-b,-c]

Christoffel also analyzes its indices:

Christoffel[ICD,CD][𝔄,-b,-c]//Catch

Christoffel[ICD,CD][𝔄,-b,-ℭ]

We can also change curvature:

ChangeCurvature[RiemannICD[-a,-b,-c,d],ICD,CD]

ChangeCurvature[RiemannICD[-a,-b,-c,d],ICD,PD]

or torsion:

TorsionCD[a,-b,-c]

ChangeTorsion[%,CD,PD]

2.6. Lie derivatives. Parametric derivatives

Define some additional tensors:

DefTensor[MaxwellF[-a,-b],{M3,time},PrintAs->"F"]

DefTensor[v[a],M3]

Lie derivative with respect to any vector field:

LieD[v[a]][MaxwellF[a,b] ]

LieD[3v[a]+RicciCD[a,-b]v[b]][MaxwellF[a,b] ]

LieDToCovD[%,PD]

Parametric derivatives.

ParamD[time][MaxwellF[-a,-b]v[b]]

2.7. Metric fields

Define two metrics:

DefMetric[{3,1,0},metric[-a,-b],cd,{"#","𝔻"},PrintAs->"g"]

DefMetric[1,METRIC[-a,-b],MCD,{"&","𝒟"}]

Note the differences:

metric[a,b]metric[-b,-c]

METRIC[a,b]METRIC[-b,-c]

InvMETRIC[a,b]METRIC[-b,-c]

This is because

METRIC[a,b]-metric[a,c]metric[b,d]METRIC[-c,-d]//ContractMetric

Other examples:

metric[-a,-b]v[b]//ContractMetric

METRIC[-a,-b]v[b]//ContractMetric

2.7. Canonicalization with a metric

Here we can swap indices:

vector[-a]cd[-b][v[a]]

ToCanonical[%]

but not here:

vector[-a]CD[-b][v[a]]

ToCanonical[%]

ToCanonical[%%,ExpandChristoffel->True]

Derivatives of inverse metrics are automatically reversed:

CD[-a][metric[b,c]]

2.7. Product metrics

$Manifolds

$Metrics

DefMetric[1,metric4[-A,-B],cd4,{"@","D4"},PrintAs->"γ"]

DefTensor[s3[],{M3,M4}]
DefTensor[s4[],{M3,M4}]

DefProductMetric[metric7[-α,-β],{{TangentM3,s3[]},{TangentM4,s4[]}},cd7,{"%","D7"}]

Outer[metric7,{-a,-A},{-b,-B}]

%//ExpandProductMetric

Outer[Christoffelcd7,{-a,-A},{-b,-B},{-c,-C}]//ExpandProductMetric

Outer[Riemanncd7,{-a,-A},{-b,-B},{-c,-C},{d,D}]//ExpandProductMetric//ContractMetric

Outer[Riccicd7,{-a,-A},{-b,-B}]//ExpandProductMetric//ContractMetric//ToCanonical

RicciScalarcd7[]//ExpandProductMetric//ContractMetric//ToCanonical

2.7. Induced metrics

DefTensor[n[a],M3]

n/:n[a_]n[-a_]:=1

DefMetric[1,hmetric[-a,-b],icd,{"|","iD"},InducedFrom->{metric,n}]

InducedDecomposition[Riemanncd[-a,-b,-c,-d],{hmetric,n}]

ToCanonical[%]

n[a]%//ToCanonical

n[c]%//ToCanonical

The derivative knows its "projected" properties:

{1,n[c]}icd[-a][Ricciicd[-b,-c]]

The system has introduced the extrinsic curvature tensor and the acceleration vector:

cd[-a][n[-b]]

Clean up

$Metrics

UndefMetric/@%;

UndefManifold[M7]

UndefCovD[ICD]

UndefCovD[CD]

UndefTensor/@{scalar,vector,V,T,MaxwellF,v,s3,s4,n};

UndefVBundle[complex]

UndefManifold[M3]

UndefManifold[M4]

UndefParameter[time]

?Global`*

3. Other packages

3.1. Invar: Computer algebra for the Riemann tensor

<<xAct`Invar`

Define background spacetime:

DefManifold[M4,4,{a,b,c,d,e,f,g}]

DefMetric[-1,metric[-a,-b],CD,{";","D"},CurvatureRelations->False,PrintAs->"g"]

PrintAs[RiemannCD]^="R";
PrintAs[epsilonmetric]^="ϵ";

Canonicalize random monomials (perhaps you need to execute this several times until getting something different from zero):

RandomRiemannMonomial[{0,2,2},metric]

expr=RiemannToInv[%]

InvSimplify[expr]

InvToRiemann[%]

3.2. xPert: Perturbation theory in General Relativity

<<xAct`xPert`

Define perturbative framework:

DefParameter[ϵ]

DefMetricPerturbation[metric,h,ϵ]

Unprotect[IndexForm];
IndexForm[LI[x_]]:=ColorString[ToString[x],RGBColor[0,0,1]]

Recursive perturbation command:

Perturbation[metric[-a,-b]]

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

Perturbation[metric[a,b]]

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

All orders:

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

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

% %%//ContractMetric//ToCanonical

Collect[%,ϵ]

Direct formula:

Perturbation[RiemannCD[-a,-b,-c,d],1]

ExpandPerturbation[%]

SortCovDs[%]//ToCanonical

Perturbation[RiemannCD[-a,-b,-c,d],3]//ExpandPerturbation

Clean up:

UndefTensor[h]

UndefParameter[ϵ]

3.3. xCoba: xAct Components and Bases

Load xCoba:

<<xAct`xCoba`

Define a vector field:

DefTensor[v[a],M4]

Define a general frame:

DefBasis[polar,TangentM4,{0,1,2,3}]

Basis elements:

{Basis[{0,-polar},a],Basis[{0,polar},-a]}

Basis[{a,polar},-b]Basis[{-c,-polar},b]

ContractBasis[%]

Basis[{a,polar},-b]Basis[{-a,-polar},c]

ContractBasis[%]

Components:

v[a]Basis[-a,{b,polar}]

ContractBasis[%]

InputForm[%]

Parallel derivative:

PDpolar[-a][ Basis[{0,-polar},a] ]

Poisson brackets:

Bracket[e][Basis[{-a,-polar},z],Basis[{-c,-polar},z]]

Christoffels and frames:

CD[-a][ Basis[{-b,-polar},c] ]

CD[-a][ Basis[{b,polar},-c] ]

Derivatives and components (!!!)

CD[-b][v[a]]

ChangeCovD[%,CD,PD]

CD[-b][v[{a,polar}]]

ChangeCovD[%,CD,PD]

"Relative tensors" (they are densities; use Ashtekar's tilde notation):

etaDownpolar[-a,-b,-c]

WeightOf[%]

etaDownpolar[{0,-polar},{1,-polar},{2,-polar}]

etaUppolar[a,b,c]etaDownpolar[-d,-e,-f]

ExpandGdelta[%]

Component expansions:

RiemannCD[-a,-b,-c,-d]//ToBasis[polar]

%//ComponentArray

%//ToCanonical

Union[Flatten[%]^2]

Length[%]

Tracing:

RiemannCD[a,b,c,d]RiemannCD[-a,-b,-c,-d]//ToBasis[polar]

TraceBasisDummy[%]

ToCanonical[%]

Define another frame:

DefBasis[cart,TangentM4,{1,2,3,4},BasisColor->RGBColor[0,1,0]]

Basis[{1,-cart},a]

Change of basis:

Basis[{a,cart},{-b,-polar}]

CD[-c][%]

UndefBasis[cart]

UndefBasis[polar]

UndefMetric[metric]

UndefTensor[v]

UndefManifold[M4]