Differential Forms Using xTerior

Downloading and Installing xAct         (xTerior is included)

Visit the page: http://www.xact.es
Follow installation instructions on http://www.xact.es/download.html
Linux: 
1. Download the tarball xAct_V.tgz (V is the version number)
2. sudo -i ; cd /usr/share/Mathematica/Applications/; tar xvfz ~/Downloads/xAct_V.tgz
Windows:
1. Download the zip file xAct_V.zip (V is the version number)
2. unzip its contents in C:\Program Files\Wolfram Research\Mathematica\<version>\AddOns\Applications\

Read the documentation: http://www.xact.es/xTerior/index.html
http://www.xact.es/Documentation/English/xTeriorDoc.nb

Linux: /usr/share/Mathematica/Applications/xAct/Documentation/English/xTeriorSlideShowYT.nb

Windows: C:\Program Files\Wolfram Research\Mathematica\<version>\AddOns\Applications\xAct\Documentation\English

Start an xTerior session

If you are already running a Mathematica session, esp. if you have loaded xTerior, xAct, ..., make a call to Quit[] before the loading of the package:
Quit[]; Needs[“xAct`xTerior`”]

Needs["xAct`xTerior`"]

Introduction

First we define a manifold of symbolic dimension dim and the symbols used for its indices:

DefConstantSymbol[dim, PrintAs->"D"];
DefManifold[M,dim,{μ,ν,μ1,μ2,ν1,ν2}];

Then we define forms of different types: a 0-form is a scalar

DefDiffForm[f[],M,0,PrintAs -> "f"];
DefDiffForm[σ[],M,1,PrintAs -> "σ"];
DefDiffForm[λ[],M,2,PrintAs -> "λ"];
DefDiffForm[ω[],M,3,PrintAs -> "ω"];

The wedge product uses the ⋀ character: typeset with [Esc]^[Esc].
Notice that f is a scalar, so the wedge product is reduced to ordinary multiplication

f[]⋀σ[]

No simplification of the expression:

λ[]⋀σ[] + σ[]⋀λ[]

Use the ToCanonical function to make simplifications and write an expression in canonical form when wedge products are present:

λ[]⋀σ[] + σ[]⋀λ[]//ToCanonical

σ[]⋀ω[] + ω[]⋀σ[]//ToCanonical

The Exterior derivative is Diff[x], x an expression

Diff[σ[]⋀λ[]]

Diff[f[] σ[] ⋀ Diff[λ[]] ⋀ Diff[ω[]]]

Define a manifold of specific dimension (here 3) and a chart with coordinates (x,y,z):

DefManifold[M3,3,{α,β,γ,δ}];
DefChart[cartesian,M3,{1,2,3},{x[],y[],z[]}];

Then we can use the basis 1-forms {dx,dy,dz} to write down differential forms:

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

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

Notice that the dz⋀dx⋀dz term is not set to 0:

ω2 ⋀ Diff[z[]]

Simplification[expr] is a wrapper to Simplify[ToCanonical[expr]]. It makes dz⋀dx⋀dz to vanish.

ω2 ⋀ Diff[z[]] // Simplification

Diff[ω2] //Simplification

We can also work with scalars. A scalar function is a head that can take as its arguments any number of coordinates.

Remember that ^= (UpSet) assigns a symbolic property of a symbol:
PrintAs[xx] ^= “x”; area[circle]= 2π r^2; rate[euro]=1.1;rate[usd]= 1.0;

DefScalarFunction /@ {ψx,ψy,ψz};
PrintAs@ψx ^= "(Subscript[ψ, x])";PrintAs@ψy ^= "(Subscript[ψ, y])";PrintAs@ψz ^= "(Subscript[ψ, z])";

ψ=ψx[x[],y[],z[]] Diff[y[]]⋀Diff[z[]]+
  ψy[x[],y[],z[]] Diff[z[]]⋀Diff[x[]]+
  ψz[x[],y[],z[]] Diff[x[]]⋀Diff[y[]]

Divergence ∇·ψ
dψ=((∂_x)(Subscript[ψ, x])+(∂_y)(Subscript[ψ, y])+(∂_z)(Subscript[ψ, z]))  dx⋀dy⋀dz

Diff[ψ] //Simplification

ϕ=ψx[x[],y[],z[]] Diff[x[]]+
  ψy[x[],y[],z[]] Diff[y[]]+
  ψz[x[],y[],z[]] Diff[z[]]

The curl ∇×ψ
dϕ=((∂_y)(Subscript[ψ, z])-(∂_z)(Subscript[ψ, y])) dy⋀dz+((∂_x)(Subscript[ψ, z])-(∂_z)(Subscript[ψ, x])) dx⋀dz+((∂_x)(Subscript[ψ, y])-(∂_y)(Subscript[ψ, z])) dx⋀dy

Diff[ϕ] //Simplification

Change coordinates: This defines a chart with the spherical coordinates. We have also defined cartesian to be the Cartesian coordinates on M3:

DefChart[spherical,M3,{1,2,3},{r[],θ[],φ[]}]

Define coordinate transformation:

cartesian2spherical = {
x[] -> r[] Sin[θ[]] Cos[φ[]],
y[] -> r[] Sin[θ[]] Sin[φ[]],
z[] -> r[] Cos[θ[]] 
}

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

ω2 /. cartesian2spherical //Simplification

Volume 3-form in spherical coordinates:

ϵ=Diff[x[]] ⋀ Diff[y[]] ⋀ Diff[z[]]/. cartesian2spherical //Simplification

ω = ((r[])^2) Sin[θ[]]  Diff[r[]] ⋀ Diff[θ[]] ⋀ Diff[φ[]]

Integrate: First remove the head Wedge, then perform ordinary integration:

FullForm[ω]

ω//Head

ω /. _Wedge-> 1

Integrate[ω /. _Wedge-> 1, {θ[],0, π}, {φ[],0,2π}]

Schwarzschild Geometry

The Schwarzschild metric in (t,r,θ,φ) coordinates is:
g=-(((1-((2M)/r)))^(-1))dt⊗dt+(1-((2M)/r))dr⊗dr+(r^2)dθ⊗dθ+(r^2)(sin^2)(θ) dφ⊗dφ
Its determinant is:
(Sqrt[-g])=(r^2)sin(θ)
and the Levi-Civita tensor:
ϵ=(Sqrt[-g])dt⋀dr⋀dθ⋀dφ

Here, we quit the kernel to start a new session with all symbols undefined, we use the Quit[] function.
We have to reload xTerior:

Quit[]

Needs["xAct`xTerior`"]

DefManifold[             M4,4,{μ,ν,α,β,γ}];
DefChart[trθφ       ,M4,{0,1,2,3},{t[],r[],θ[],φ[]}];
DefChart[Kruskal,M4,{0,1,2,3},{U[],V[],θ[],φ[]}];

DefConstantSymbol[M, PrintAs->"M"]

DefDiffForm[ϵ[],M4,4,PrintAs-> "ϵ"]

ϵ[] = ((r[])^2) Sin[θ[]] Diff[t[]] ⋀ Diff[r[]]⋀ Diff[θ[]]⋀Diff[φ[]]

Coordinate Transformation, r>2M:
U=(Sqrt[(r/(2M))-1]) (e^((r/(4M)) ))cosh((t/(4M))), V=(Sqrt[(r/(2M))-1]) (e^((r/(4M)) ))sinh((t/(4M)))

Kruskal2trθφ = {
U[]-> (Sqrt[((r[])/(2M))-1])  (E^((r[])/(4M)))  Cosh[((t[])/(4M))],
V[]-> (Sqrt[((r[])/(2M))-1])  (E^((r[])/(4M)))  Sinh[((t[])/(4M))]

}

{Diff[U[]]/.Kruskal2trθφ, Diff[U[]]⋀Diff[V[]]/.Kruskal2trθφ} //Simplification

The metric in the Kruskal coordinates is:
g=((32(M^3))/r)(e^((-r)/(2M)))(-dV⊗dV+dU⊗dU)+(r^2)dθ⊗dθ+(r^2)(sin^2)(θ) dφ⊗dφ
so the determinant is
-g=(((((32(M^3))/r)(e^((-r)/(2M))) ))^2)(r^2)(r^2)(sin^2)(θ)

We compute the Levi-Civita symbol in the new coordinates and then transform back to spherical. The result is the same as the ϵ computed above:

sqrtg =  32 (M^3)  (E^((- r[])/(2M))) r[] Sin[θ[]]; (*that is (Sqrt[-g])*)
ϵ[] = sqrtg Diff[U[]] ⋀ Diff[V[]] ⋀ Diff[θ[]] ⋀ Diff[φ[]]

ϵ[] /. Kruskal2trθφ // Simplification

Simplify notation for exterior derivative:

d=Diff

d[ϵ[]]

sqrtg d[U[]] ⋀ d[V[]] ⋀ d[θ[]] ⋀ d[φ[]]

Simplify notation

Quit[]

Needs["xAct`xTerior`"]

DefManifold[             M4,4,{μ,ν,α,β,γ}];
DefChart[trθφ       ,M4,{0,1,2,3},{T[],R[],Θ[],Φ[]}];
DefChart[Kruskal,M4,{0,1,2,3},{U[],V[],Θ[],Φ[]}];

DefConstantSymbol[M, PrintAs->"M"]

Translate symbols to ones that are easier to use and read, without too many brackets.
Notice the use of PrintAs, so that we see expressions in the more familiar form.

t = T[]; dt = Diff[T[]];PrintAs@T ^="t"; 
r = R[]; dr = Diff[R[]];PrintAs@R ^="r"; 
θ = Θ[]; dθ = Diff[Θ[]];PrintAs@Θ ^="θ"; 
ϕ = Φ[]; dϕ = Diff[Φ[]];PrintAs@Φ ^="ϕ"; 

u = U[]; du = Diff[U[]]; PrintAs@U ^="u"; 
v=  V[]; dv = Diff[V[]]; PrintAs@V ^="v";

kruskal2trθφ = {
u-> (Sqrt[(r/(2M))-1])  (E^(r/(4M)))  Cosh[(t/(4M))],
v-> (Sqrt[(r/(2M))-1])  (E^(r/(4M)))  Sinh[(t/(4M))]

}

DefDiffForm[ϵ[],M4,4,PrintAs-> "ϵ"];

sqrtg =  32 (M^3)  (E^((- r)/(2M))) r Sin[θ]; (*that is (Sqrt[-g])*)
ϵ[] = sqrtg  du ⋀ dv ⋀ dθ ⋀ dϕ

ϵ[] /. kruskal2trθφ  //Simplification

Various forms:

{du,dv, du ⋀ dv,Diff[u dv]}

{du,dv, du ⋀ dv}/. kruskal2trθφ  //Simplification

Since U=(Sqrt[(r/(2M))-1]) (e^((r/(4M)) ))cosh((t/(4M))),  we should obtain the same result as for du above:

Diff[(Sqrt[(r/(2M))-1]) (E^(r/(4 M))) Cosh[(t/(4M))]]//Simplification