Other stuff

Computing metrics using TensorFlow

In differential geometry/general relativity/cosmology, you need to compute metrics of manifolds that are defined as embeddings that live inside higher-dimensional spaces. Examples of such manifolds are de Sitter dS_{d+1}, (Euclidean/Lorentzian) anti-de Sitter AdS_{d+1} or simply the sphere S^d.

Analytically, this can be done in Mathematica (which isn't open source) or SymPy. Numerically, this requires a system that knows how to compute Jacobians of complicated functions. There's a famous open-source package that can do this: TensorFlow (see here for the relevant documentation). Usually this is done under the hood for neural networks, but we can easily use tf.GradientTape to compute the metric of any of the above manifolds, or really any manifold that you could care about.

The key idea is compute the Jacobian as follows, where embedding() is the map that embeds your manifold M into the higher-dimensional embedding space.

To check that this makes sense, we can take a simple manifold like de Sitter in n dimensions, for which we can compute the metric analytically too. See this paper for some standard formulas. Using this code you can compare both approaches:

which returns: