I have written a Mathematica package to perform basic computations in Riemannian geometry. In this post, I share an example of computation that this code can be used for and a link to the package containing the instructions to reproduce the computation presented here.
I started a Mathematica package to performs computations of Riemannian geometry. As an exercise in using it, I present here the computation of the curvature of a 2-sphere embedded in the euclidean space. The package is in development and its content is not meant to be exhaustive. This suffices however to perform some of the most basic computations on (pseudo-)Riemannian real manifolds. The package is available in its own git repository.
For something more general, I recommend you take a look at the excellent SageManifolds.
let us start by defining a background 3-dimensional euclidean space by providing a set of coordinates {x,y,z} and a metric in the form of a squared line-element:
ds2=dx2+dy2+dz2 .
g=⎝⎛100010001⎠⎞ .
One way to embed the 2-sphere in the 3-dimensional euclidean space is to impose that
Φ≡x2+y2+z2−R2=0 ,
where R>0 denotes the Radius of the sphere. One parametrisation satisfying this constraint is
xyz=Rsinθcosϕ ,=Rsinθsinϕ ,=Rcosθ ,(1)
with {θ,ϕ} taking up the role of local ordinates on the 2-sphere which we will denote as S2.
The components of the one-form normal to S2 are obtained as follows
nα=∂xα∂Φ .
Once it has been normalised, this turns out to be
{√x2+y2+z2x,√x2+y2+z2y,√x2+y2+z2z}
The general expression of the projector onto S2 is
Pαβ=gαβ−nαnβ .
Here this gives:
⎝⎜⎜⎜⎜⎜⎜⎜⎜⎛x2+y2+z2y2+z2−x2+y2+z2xy−x2+y2+z2xz−x2+y2+z2xyx2+y2+z2x2+z2−x2+y2+z2yz−x2+y2+z2xz−x2+y2+z2yzx2+y2+z2x2+y2⎠⎟⎟⎟⎟⎟⎟⎟⎟⎞
Finally, the extrinsic curvature is the Lie derivative of this tensor along the normal vector defined above:
Kαβ=−21LnPαβ .
Here this gives:
⎝⎜⎜⎜⎜⎜⎜⎜⎜⎛−(x2+y2+z2)3/2y2+z2(x2+y2+z2)3/2xy(x2+y2+z2)3/2xz(x2+y2+z2)3/2xy−(x2+y2+z2)3/2x2+z2(x2+y2+z2)3/2yz(x2+y2+z2)3/2xz(x2+y2+z2)3/2yz−(x2+y2+z2)3/2x2+y2⎠⎟⎟⎟⎟⎟⎟⎟⎟⎞
The mean curvature is given by the trace of this tensor. Here, it is found to be
Tr K=−R2(2)
All the above was done using only vectors (and one-forms) belonging to the (co-)tangent bundle of the surrounding euclidean space without any explicit reference to the local coordinates on S2. The extrinsic curvature also has a representation on S2.
From (1), one constructs the vielbein:
eaα=∂ya∂xα ,
where xα denotes the coordinates on R3, {x,y,z} and ya are the coordinates on S2, {θ,ϕ}. In our case, this reads, in the matrix form :
⎝⎜⎜⎛Rcos(θ)cos(ϕ)Rcos(θ)sin(ϕ)−Rsin(θ)−Rsin(θ)sin(ϕ)Rcos(ϕ)sin(θ)0⎠⎟⎟⎞
The induced metric on Σ can then be computed as
γab=eaαebβgαβ ,(3)
which here gives:
⎝⎛R200R2sin2(θ)⎠⎞
Applying a transformation similar to Eq.(3) to the extrinsic curvature gives
(−R00−Rsin2(θ))
and so we recover Eq.(2) by taking the trace (γabKab).