xTerior: exterior calculus in the Wolfram language

Exterior calculus has many applications in Mathematics & Physics:

Stokes theorem (fundamental theorem of calculus in any dimension).

Topology: de Rham theorem.

Cartan structure equations.

Gauge theories in physics.

Contents

1st part: differential forms in coordinates.

xTerior and its relation to xAct.

A very simple session with xTerior.

Coordinate changes of differential forms and pull-back. Use for the integration of differential forms.

Finding a local potential for a closed differential form.

Hodge dual and co-differential.

Divergence, curl in terms of differential forms.

2nd part: tensor valued differential forms.

Working with tensor valued forms.

Cartan structure equations.

Example: Chern-Simons forms.

Example: Einstein-Cartan theory.

The xAct project

12 years of development.

500+ different commands and 35000 lines of Wolfram language code.

170+ scientific papers using xAct.

1500+ posts in the xAct forum.

See www.xact.es

Sample session in xTerior

We load xTerior. All necessary xAct packages are automatically loaded.

<<xAct`xTerior`

We remove unnecessary info messages:

$DefInfoQ=False;
$UndefInfoQ=False;

$CVVerbose=False;

We declare a 3-dimensional coordinate system, with coordinates {x, y, z}. For that we use xAct Def commands to declare a manifold and a coordinate chart.

DefManifold[M3,3,{a,b,c,d,f,g}]
DefChart[Ec,M3,{1,2,3},{x[],y[],z[]}]

We are now able to work with arbitrary differential forms written in these coordinates. They are all combinations of the wedge product of coordinate differentials:

Diff[x[]]⋀Diff[y[]]

Wedge product is the Wolfram language built-in symbol Wedge, entered with Esc ^ Esc. All differential forms in these coordinates can be written as combinations of elements in the following list.

{Diff[x[]],Diff[y[]],Diff[z[]],Diff[x[]]⋀Diff[y[]],Diff[x[]]⋀Diff[z[]],Diff[y[]]⋀Diff[z[]],Diff[x[]]⋀Diff[y[]]⋀Diff[z[]]}

Basic operations

We can represent any differential form, and do operations on it.

ω=(x[]^2+y[]^2)Diff[z[]]⋀Diff[x[]]-1/(x[]^2+y[]^2)Diff[x[]]⋀Diff[y[]]

ω⋀Diff[z[]]

The Simplification command takes into account the wedge product and its special properties.

?Simplification

Simplification@%%

The degree of  a differential form is obtained with Deg:

Deg@%

The exterior derivative and its properties are implemented by means of the action of  Diff.

Diff@ω

Simplification@%

We can also work with general differential forms written in the coordinates {x,y,z}. For example, let us declare a set of scalar functions:

DefScalarFunction/@{Fx,Fy,Fz};
PrintAs@Fx^="(Subscript[F, x])";PrintAs@Fy^="(Subscript[F, y])";PrintAs@Fz^="(Subscript[F, z])";

A scalar function is a head that can take as its arguments any number of coordinates:

{Fx[x[]],Fx[x[],x[]],Fx[x[],y[],z[]]}

We can use the scalar functions to represent a generic 2-form and do operations on it:

ψ=Fx[x[],y[],z[]]Diff[y[]]⋀Diff[z[]]-Fy[x[],y[],z[]]Diff[x[]]⋀Diff[z[]]+Fz[x[],y[],z[]]Diff[x[]]⋀Diff[y[]]

Diff@ψ//Simplification

As is well-known the double exterior derivative is zero. Hence the double action of Diff yields zero

Diff@%//Simplification

More examples:

φ=Fx[x[],y[],z[]]Diff@x[]+Fy[x[],y[],z[]]Diff@y[]+Fz[x[],y[],z[]]Diff@z[]

dφ=Diff@φ//Simplification

We check that the previous expression is essentially the curl of the vector field {Fx,Fy,Fz} when regarded as a field in the Euclidean 3-space.

Curl[{Fx[x[],y[],z[]],Fy[x[],y[],z[]],Fz[x[],y[],z[]]},{x[],y[],z[]}]

And this is the divergence

ψ

Coefficient[Diff@ψ//Simplification,Diff[x[]]⋀Diff[y[]]⋀Diff[z[]]]

Div[{Fx[x[],y[],z[]],Fy[x[],y[],z[]],Fz[x[],y[],z[]]},{x[],y[],z[]}]

Change of coordinates

Let us introduce a new coordinate system

DefChart[Sp,M3,{1,2,3},{r[],θ[],ζ[]}]

The relation between the new and the old coordinates is

EcToSp={x[]->r[]Sin[θ[]]Cos[ζ[]],y[]->r[]Sin[θ[]]Sin[ζ[]],z[]->r[]Cos[θ[]]}

This enables us to write any differential form in the new coordinates. For example:

ω

ω/.EcToSp

Simplification@%

Diff[x[]]⋀Diff[y[]]⋀Diff[z[]]

%/.EcToSp//Simplification

The change of coordinates enables us to integrate differential forms over regions: For example take the 2-form

(x[]^2+y[]^2+z[]^2)^(-3/2)(z[]Diff@x[]⋀Diff@y[]-y[]Diff@x[]⋀Diff@z[]+x[]Diff@y[]⋀Diff@z[])

Let us integrate this 2-form over the unit 2-dim sphere: first we write the form in spherical coordinates:

%/.EcToSp//Simplification//PowerExpand

Next we integrate:

Integrate[%/._Wedge->1,{θ[],0,Pi},{ζ[],0,2Pi}]

Find a potential

If ω is a p-form and dω = 0 on an open star-shaped set 𝒰 with respect to a point a, then there exists a p-1 form ϕ on 𝒰 such that 
dϕ =ω (Poincaré Lemma).

We can attempt to find the form ϕ with the command FindPotential.

?FindPotential

Any 3-form is closed

η=Diff[x[]]⋀Diff[y[]]⋀Diff[z[]]

A local potential with (ℝ^3)as the star-shaped set and the origin {0,0,0} as the reference point.

FindPotential[η,{0,0,0},Ec]

Diff@%//Simplification

Another potential with another point as the reference

FindPotential[η,{1,1,1},Ec]//Simplification

Diff@%//Simplification

A more involved example: take the 3-form:

Diff[x[]]⋀Diff[y[]]⋀Diff[z[]]y[]

Again it is closed. Let us find a pontential

FindPotential[%,{0,0,0},Ec]

Diff@%//Simplification

For any other differential form μ, not necessarly exact, the following identity holds

identityForms=μ==Diff@FindPotential[μ,p0,Coord1]+FindPotential[Diff@μ,p0,Coord1];

Where p0 and Coord1 are an arbitrary point and arbitrary coordinate system : let us check the identity in a particular case :

μ=-(x[]^2+y[]^2)Diff[x[]]⋀Diff[y[]]+Diff[z[]]⋀Diff[x[]](x[]^2-y[]^2)

identityForms/.{Coord1->Ec,p0->{1,1,1}}

Simplification@%

Hodge dual and codifferential

If we introduce a metric in a manifold ℳ of dimension n then we can define on the set Λ(ℳ) (differentiable forms on ℳ) the Hodge operator ⋆ and the co-differential δ :
⋆ : (Λ^p)(ℳ)->(Λ^(n-p))(ℳ)
δ :  (Λ^p)(ℳ)->(Λ^(p-1))(ℳ), δ≡(((-1))^(n(p+1)+s))⋆ d ⋆
To compute these operators in xTerior one uses ExpandHodgeDual and CodiffToDiff respectively

We need to associate a metric to the coordinates we are working with. In this example, we shall take a coordinate system predefined in Mathematica.

DefChart[Cyl,M3,{1,2,3},{ρ[],θ[],ζ[]}]

The components of the metric tensor are given by

metricCyl=CoordinateChartData["Cylindrical","Metric"][{ρ[],θ[],ζ[]}]

In order that xTerior recognizes this as the metric in cylindrical coordinates one has to wrap it with the CTensor head as follows:

metricCyl=CTensor[metricCyl,{-Cyl,-Cyl}]

SetCMetric[metricCyl,Cyl,SignatureOfMetric->{3,0,0}]

Once this is done we can compute the Hodge dual and the co-differential of any form in the given coordinates.  For example:

Diff[ρ[]]

Hodge[metricCyl]@%

The actual computation of the Hodge dual is carried out with ExpandHodgeDual as follows:

ToValues@ExpandHodgeDual[%,dx[M3],metricCyl]

%//PowerExpand

We can use these feature to compute the Hodge Laplacian.

DefScalarFunction[Φ]

Forms of degree higher than the dimension will be set to zero automatically.

UseDimensionStart[]

The Hodge laplacian acting on any form ω is defined by dδ ω +δ d ω.  In this case we take ω = ϕ

Codiff[metricCyl]@Diff@Φ[ρ[],θ[],ζ[]]+Diff@Codiff[metricCyl]@Φ[ρ[],θ[],ζ[]]

CodiffToDiff@%

We work out the exterior derivative and the Hodge duals

ExpandHodgeDual[%,dx[M3],metricCyl];

ExpandHodgeDual[%,dx[M3],metricCyl]

Compare with Mathematica.

Laplacian[Φ[ρ[],θ[],ζ[]],{ρ[],θ[],ζ[]},"Cylindrical"]//Expand

UnsetCMetric@metricCyl

Div and Curl in terms of differential forms

Let F be a vector field in (ℝ^3). Then we have the following relations
∇·F ⟺ δ F, if F is regarded as a 1-form in (ℝ^3).
∇×F ⟺ ⋆ d F, if F is regarded as a 1-form in (ℝ^3).
 F  is a 1-form in (ℝ^3) ⟹ F=(Subscript[F, 1])(θ^1)+(Subscript[F, 2])(θ^2)+(Subscript[F, 3])(θ^3)
 {(θ^1),(θ^2),(θ^3)} is an orthonormal co-base in (ℝ^3) with respect to a chosen metric g.

For this we need to define first an orthonormal frame. The orthonormal frame is related to the original cylindrical coordinates by means of the following change of frame matrix:

ChangeFrame={{1,0,0},{0,ρ[],0},{0,0,1}};

%//MatrixForm

Definition of the actual orthonormal frame called frame. Note that we need to specify the relation between frame and  the old coordinate chart called Cyl at definition time.

DefBasis[frame,TangentM3,{1,2,3},BasisColor->RGBColor[0,0,1],BasisChange->CTensor[Inverse@ChangeFrame,{-frame,Cyl}]]

In this frame the metric tensor takes the diagonal form.

metricframe=CTensor[DiagonalMatrix[{1,1,1}],{-frame,-frame}]

We set now this metric as the metric with which we are going to do computations.

SetCMetric[metricframe,Cyl,SignatureOfMetric->{3,0,0}]

Set of orthonormal 1-forms with respect to the defined metric:

{Coframe[M3][{1,frame}],Coframe[M3][{2,frame}],Coframe[M3][{3,frame}]}

Relation between the orthonormal co-base and the holonomic co-base.

dx[M3][{a,Cyl}]==TraceBasisDummy[Basis[-{b,frame},{a,Cyl}]Coframe[M3][{b,frame}]]

ComponentArray@%

%/.Basis->ToCTensor[Basis,{-Cyl,frame}]

ToValues@%

DiffCylToframe=%/.Equal->Rule;

We can now compute the exterior derivatives of the co-base elements by means of the Cartan equations:

Diff/@{Coframe[M3][{1,frame}],Coframe[M3][{2,frame}],Coframe[M3][{3,frame}]}

Equal[#,UseCartan[#,CovDOfMetric@metricframe]]&/@%

Computation of Div

Now, define the components of a 3-vector field with respect to the introduced orthonormal frame.

DefScalarFunction/@{fρ,fθ,fζ};

PrintAs@fρ^="(Subscript[f, ρ])";PrintAs@fθ^="(Subscript[f, θ])";PrintAs@fζ^="(Subscript[f, ζ])";

Take the following 1-form

ω=fρ[ρ[],θ[],ζ[]]Coframe[M3][{1,frame}]+fθ[ρ[],θ[],ζ[]]Coframe[M3][{2,frame}]+fζ[ρ[],θ[],ζ[]]Coframe[M3][{3,frame}]

Computation of Div: according to the relation above this is δ ω:

Codiff[metricframe]@ω

We write the co-differential in terms of the exterior derivative and the Hodge dual

CodiffToDiff[%]

We work out the Hodge duals

ExpandHodgeDual[%,Coframe[M3],metricframe];

%/.DiffCylToframe;

We need to expand out all terms  in terms of the connection. Use the Cartan structure equations for that as shown above.

UseCartan[%,CovDOfMetric@metricframe];

Finally we replace the Hodge duals:

ExpandHodgeDual[%,Coframe[M3],metricframe]

Compare with Mathematica result:

Div[{fρ[ρ[],θ[],ζ[]],fθ[ρ[],θ[],ζ[]],fζ[ρ[],θ[],ζ[]]},{ρ[],θ[],ζ[]},"Cylindrical"]

Rotational in an orthonormal frame

Take again the 1-form ω

ω

As explained, the rotational can be computed as ⋆d ω

Hodge[metricframe]@Diff@ω

Write everything in the orthonormal frame.

%/.DiffCylToframe

Use Cartan structure equations.

UseCartan[%,CovDOfMetric@metricframe]

Expand out the Hodge dual

ExpandHodgeDual[%,Coframe[M3],metricframe]

Collect[%,Coframe[M3][_],Simplify]

Compare with Mathematica result:

Curl[{fρ[ρ[],θ[],ζ[]],fθ[ρ[],θ[],ζ[]],fζ[ρ[],θ[],ζ[]]},{ρ[],θ[],ζ[]},"Cylindrical"]

Example: Hodge Laplacian in the Schwarzschild metric.

This computation was done before for a scalar in (ℝ^3) in cylindrical coordinates. We repeat it now for the case of a scalar field defined on the Schwarzchild solution of the Einstein’s vacuum equations.

DefManifold[M4,4,{α,β,γ,δ,ν}]
DefChart[Sch,M4,{0,1,2,3},{t[],R[],Θ[],λ[]}]

DefConstantSymbol[mass,PrintAs->"M"]

Metric tensor in Matrix form:

Smet={{-1+mass/R[],0,0,0},{0,(1-mass/R[])^(-1),0,0},{0,0,R[]^2,0},{0,0,0,R[]^2 Sin[Θ[]]^2}}

We declare this as a metric tensor.

Smet=CTensor[Smet,{-Sch,-Sch}]

SetCMetric[Smet,Sch,SignatureOfMetric->{3,1,0}]

We use the command UseDimensionStart to get rid of forms whose degree is higher than the dimension of the manifold.

UseDimensionStart[]

Computation of the Hodge Laplacian (d δ+δ d)ϕ

Diff@Codiff[Smet][Φ@@ScalarsOfChart@Sch]+Codiff[Smet]@Diff[Φ@@ScalarsOfChart@Sch]

The procedure is similar as before: we express the co-differential in terms of exterior derivatives and Hodge duals and next we work out the Hodge duals:

CodiffToDiff@%

ExpandHodgeDual[%,dx[M4],Smet];

ExpandHodgeDual[%,dx[M4],Smet]

Simplify//@%

We clear all the symbols used during the first part of the talk.

UnsetCMetric/@$Metrics;

UseDimensionStop[]

UndefChart/@$Charts;

UndefBasis/@$Bases;

UndefCovD/@Rest@$CovDs;

UndefTensor/@$Tensors;

UndefManifold/@$Manifolds;

ω=.

Tensor valued forms

As already explained, xTerior relies on xTensor which is a fast manipulator for tensors in index notation. This means that we can take advantage of all the capabilities of xTensor to manipulate indexed quantities. To illustrate this we declare a manifold of symbolic dimension dim with the appropriate Def commands of xTensor.

DefConstantSymbol@dim

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

Tensors are introduced in xTensor using DefTensor. Example:

DefTensor[T[-a,-b],M,Symmetric[{-a,-b}]]

Any kind of symmetry involving the indices is allowed. Tensorial expressions are canonicalized with ToCanonical.

T[-a,-b]+T[-b,-a]

%//ToCanonical

An special interesting case is that in which a tensor has no indices (zero-rank tensor). These objects were used in the first part to represent the individual coordinates of the charts.

DefTensor[#,M]&/@{x[],y[]};

xTerior extends the capabilities of xTensor in the sense that one can work with tensor valued forms. Example: we define a tensor valued form of rank-2 and degree 3

DefDiffForm[ω[-a,-b],M,3,Symmetric[{-a,-b}]]

We can now construct expressions which involve the wedge product and canonicalize them. The symmetries of the form and the properties of the wedge product are taken into consideration.

ω[-a,-b]⋀ω[-c,-d]-ω[-d,-c]⋀ω[-b,-a]

%//ToCanonical

Diff[x[]]⋀Diff[y[]]-Diff[y[]]⋀Diff[x[]]

%//ToCanonical

UndefDiffForm@ω

UndefTensor/@{x,y};

Cartan structure equations

We introduce a covariant derivative using the xTensor DefCovD.

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

Once we have introduced a covariant derivative we can work with its connection 1 - form and the curvature 2 - form. These are tensor valued forms.

ChristoffelForm[CD][a,-b]

%//Deg

RiemannForm[CD][a,-b]

%//Deg

These elements are related by the Cartan structure equations. We can easily obtain the Cartan structure equations for a given connection by means of UseCartan.

CartanStructureEqs={Diff@Coframe[M][a]==UseCartan[Diff[Coframe[M][a]],CD],Diff@ChristoffelForm[CD][a,-b]==UseCartan[Diff[ChristoffelForm[CD][a,-b]],CD],Diff@TorsionForm[CD][a]==UseCartan[Diff[TorsionForm[CD][a]],CD],Diff@RiemannForm[CD][a,-b]==UseCartan[Diff[RiemannForm[CD][a,-b]],CD]}

We can also check the complete integrability conditions of the Cartan system.

Diff@%

UseCartan[%,CD]

ToCanonical[%]

Some of the Cartan equations can be formulated in any vector bundle. For example take a real vector bundle over the manifold M with 3 - dimensional fibres and define a covariant derivative on it.

DefVBundle[VB,M,3,{A,B,C,D,J,H}]

DefCovD[cdv[-a],VB,{"|","𝒟"}]

For a covariant derivative defined in a general vector bundle, the notation for the connection 1 - form and the curvature 2 - form is slightly different; in addition to the symbol of the covariant derivative it also contains the symbol representing the vector bundle upon which the covariant derivative is defined.

ConnectionForm[cdv,VB][A,-B]

%//Deg

CurvatureForm[cdv,VB][A,-B]

%//Deg

In this case, the Cartan equations adopt now the form :

{Diff@ConnectionForm[cdv,VB][A,-B]==UseCartan[Diff@ConnectionForm[cdv,VB][A,-B],cdv],Diff@CurvatureForm[cdv,VB][A,-B]==UseCartan[Diff@CurvatureForm[cdv,VB][A,-B],cdv]}

We compute the integrability conditions of the Cartan system in this case.

Diff@%

UseCartan[%,cdv]

ToCanonical@%

Chern-Simons forms

If ℱ is the curvature 2-form associated to a connection 1-form 𝒜 then it is known that 
(Ω^(2k))≡tr((Overscript[ℱ⋀…⋀ℱ, (Overscript[⌣, k])])) is closed ((dΩ)^(2k))=0. The form (Ω^(2k)) is a 2k-form and hence there exists a local 2k-1 form potential (ω^(2k-1)) such that ((dω)^(2k-1))=(Ω^(2k)).  The form (ω^(2k-1)) is called a Chern-Simons form. Let us check these results using xTerior.

We define an index free version of the curvature 2 - form and the connection 1 - form.

DefDiffForm[ℱ[],M,2]

DefDiffForm[𝒜[],M,1]

TR is the trace and it is defined with an inert head which is a general operator acting on any tensorial expression. In addition we need some extra code to work with these forms :

DefInertHead[TR,LinearQ->True,PrintAs->"Tr"]

Grade[TR[expr_],Wedge]^:=Grade[expr,Wedge];

addfactor[expr1_,expr2_?xTensorQ]:=expr1⋀expr2[-First@Select[IndicesOf[Free][expr1],DownIndexQ],-NewIndexIn[VB]];

traceindex[expr_]:=expr/.UpIndex/@(Rule@@IndicesOf[Free][expr]);

rules={ℱ[]->CurvatureForm[cdv,VB],𝒜[]->ConnectionForm[cdv,VB]};

expandtrace=expr_TR:>With[{list=List@@First@expr/.rules},traceindex@Fold[addfactor,First[list][B,-A],Rest[list]]];

Code to implement the general formula which yields the Chern-Simons forms (see S. Chern and J. Simons,  Annals of Mathematics, Second Series, 99, No. 1 (1974), 48-69):

DefParameter[t]
TR[expr_Times]:=TR/@expr;
TR[expr_^n_]:=expr^n;
TR[t]=t;
ω[x_?OddQ]:=Integrate[(x+1)/2TR[𝒜[]⋀Wedge@@Table[t ℱ[]+(t^2-t)𝒜[]⋀𝒜[],{(x-1)/2}]],{t,0,1}];

We are now ready to test our results. Let us start with the Chern -Simons 3 - form (ω^3) defined as:

ω[3]

With indices this is

%/.expandtrace//ToCanonical

We compute the exterior derivative of this object :

Diff@%

UseCartan[%,cdv]

ToCanonical@%

This corresponds to (Ω^4)=tr(ℱ⋀ℱ).

Similar computation for the Chern - Simons 5 - form (ω^5).

ω[5]

%/.expandtrace//ToCanonical

Diff@%

UseCartan[%,cdv]

ToCanonical@%

This corresponds to (Ω^6)≡tr(ℱ⋀ℱ⋀ℱ). Let us check that this 6-form is closed:

Diff@%

UseCartan[%,cdv]

ToCanonical@%

Computation for (ω^7)

ω[7]

%/.expandtrace//ToCanonical;

UseCartan[Diff@%,cdv]//ToCanonical

This corresponds to (Ω^8)≡tr(ℱ⋀ℱ⋀ℱ⋀ℱ).

UseCartan[Diff@%,cdv]//ToCanonical

Example: Einstein-Cartan theory in dimension 4

The Lagrangian of a physical theory is given by L=(∫_𝒰)ℒ, where ℒ=ℒ((u^1),… ,(u^N)), N∈ℕ  is the Lagrange density and (u^1),… ,(u^N) the configuration fields. The equations of motion of the theory are obtained from the stationary action principle δL=0 which results in an Euler-Lagrange equation (Subscript[δ, (u^j)])ℒ=0 for each of the configuration fields (u^j), j=1,…, N. If the configuration fields are differential forms on 𝒰 then the Lagrange density can be regarded as a differential form on 𝒰 with degree equal to the dimension of 𝒰. In this particular case we can compute the variational derivative (Subscript[δ, (u^j)])ℒ using the command FormVarD.

?FormVarD

If we call ((δu)^j) to the variation of the configuration field (u^j), then,  the essential identity which we need to use is    (∫_𝒰)d (((δu)^j))⋀(Subscript[⋆, g])b= (∫_𝒰)d[(((δu)^j))⋀(Subscript[⋆, g])b]+ (∫_𝒰)((δu)^j)⋀(Subscript[⋆, g])(Subscript[δ, g])b, ∀b∈(Λ^p)(𝒰), p∈ℕ. Using the Stokes theorem one has that (∫_𝒰)d[(((δu)^j))⋀(Subscript[⋆, g])b]=(∫_(∂ℳ))((δu)^j)⋀(Subscript[⋆, g])b . If  we assume that ((δu)^j)=0 on the boundary  ∂𝒰 then we can get rid of this term.

We set now the manifold dimension to 4 and introduce a metric tensor on it with signature (+1,-1,-1,-1).

dim=4;

DefMetric[{1,3,0},metricg[-a,-b],CV,Torsion->True,PrintAs->"g"]

In this example we explain how to obtain the basic equations of the Einstein-Cartan theory starting from the Einstein-Hilbert Lagrangian written in terms of differential forms.

RiemannForm[CV,TangentM][b,-a]⋀Hodge[metricg][Coframe[M][a]⋀Coframe[M][-b]]

ℒ=ExpandHodgeDual[%,Coframe[M],metricg]

It can be shown that the 1-form (θ^j) and the connection 1-form ({{Γ[▽], ({{b,  }, { , a}})}}) can be taken as the independent fields to compute the dynamical equations. By definition (Subscript[τ, j])≡(Subscript[δ, (θ^j)])ℒ, and ({{𝓈, ({{ , h}, {f,  }})}})≡(Subscript[δ, ({{Γ[▽], ({{f,  }, { , h}})}})])ℒ, where (Subscript[τ, j]) is the energy-momentum 3-form and ({{𝓈, ({{ , h}, {f,  }})}}) is the intrinsic angular momentum (spin) 3-form. We define now these 3-forms

DefDiffForm[τ[-a],M,3]

DefDiffForm[𝓈[-a,-b],M,3,Antisymmetric[{-a,-b}]]

Computation of  (Subscript[τ, j])=(Subscript[δ, (θ^j)])ℒ

τ[-f]==FormVarD[Coframe[M][f],metricg]@ℒ

We perform some manipulations on this expression:

CurvatureFormToTensor[%,Coframe];
Hodge[metricg]/@%;
ExpandHodgeDual[%,Coframe[M],metricg];
ToCanonical/@ContractMetric/@%;
EinsteinA=Simplification@ContractMetric@RicciToEinstein@%

This is the first part of the Einstein equations "Matter curves the spacetime".

We compute next ({{𝓈, ({{ , h}, {f,  }})}})≡(Subscript[δ, ({{Γ[▽], ({{f,  }, { , h}})}})])ℒ. First write the Lagrangian in terms of the connection 1-form.

ℒ/.(IndexSolve[CartanStructureEqs[[2]],RiemannForm[CD][a,-b]]/.CD->CV)

Actual variational derivative.

𝓈[-f,h]==FormVarD[ChristoffelForm[CV][f,-h],metricg][%]

We simplify the above expression. This is a somewhat long computation.

Hodge[metricg]/@%

CodiffToDiff/@%

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

UseCartan[%,CV]

Hodge[metricg]/@%

ToCanonical/@(ContractMetric/@%)

%/.h->-h

ConnectionFormToTensor[%,PD,Coframe]

Hodge[metricg]/@%

ExpandHodgeDual[#,Coframe[M],metricg]&/@%

ToCanonical@ContractMetric@%

Hodge[metricg]/@%

This is the second set of Einstein equations (intrinsic spin generates torsion).

Conclusions

xTerior enables us to work with tensor valued differential forms in any chart, any dimension and also with no reference to a chart.

Further directions of work:

Improve the integration on regions. Take advantage of the new capabilities of the Wolfram language to work with regions.

Better handling of those cases in which FindPotential cannot find an exact potential.

Automatization of certan procedures: for example the computation of the co-differential or the Hodge Laplacian.

Addition of other products besides wedge: for example Clifford geometric algebra.