TensoriaCalc: A User-Friendly Tensor Calculus Package for the Wolfram Language
Wei-Hao Chen 1 , Yi-Zen Chu 1,2 , Vaidehi Varma 3,4 · 2025
Read TensoriaCalc: A User-Friendly Tensor Calculus Package for the Wolfram Language by Wei-Hao Chen 1 , Yi-Zen Chu 1,2 , Vaidehi Varma 3,4 (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2512-18796.txt.
Introduction
Wei-Hao Chen, Yi-Zen Chu, and Vaidehi Varma present TensoriaCalc, a tensor calculus package for the Wolfram Language. Tensor calculations underpin general relativity and differential geometry, but hand computation is slow and error-prone. Their 126-page guide, posted to arXiv in December 2025, describes software designed to feel native to Mathematica rather than bolted on.
A session can hold several metrics at once. Once a metric is set, the package computes covariant derivatives, Hodge duals, index raising and lowering, and geodesic equations. It also handles operations that need no metric, including Lie and exterior derivatives and coordinate changes on tensors. The code and full user guide are public. For researchers and students, TensoriaCalc turns week-long index gymnastics into checked, repeatable commands.
Catalog record
| CREATOR | Wei-Hao Chen 1 , Yi-Zen Chu 1,2 , Vaidehi Varma 3,4 |
|---|---|
| YEAR | 2025 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 82 KB |
| VERSION | 1.0 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2512-18796
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
TensoriaCalc: A User-Friendly Tensor Calculus Package for the Wolfram Language Wei-Hao Chen 1 , Yi-Zen Chu 1,2 , Vaidehi Varma 3,4 Abstract We describe TensoriaCalc , a tensor calculus package written to be smoothly consistent with the Wolfram Language, so as to ensure ease of usage. It allows multiple metrics to be defined in a given session; and, once a metric is computed, associated standard differential geometry operations to be carried out – covariant derivatives, Hodge duals, index raising and lowering, derivation of geodesic equations, etc. Other non-metric operations, such as the Lie and exterior derivatives, coordinate transformation on tensors, etc. are also part of its built-in functionality. I Introduction Mathematica MMA and its associated Wolfram language is widely used by physicists, likely at least in part due to their ease of use. To date, however, the Wolfram language does not offer a comprehensive range of built-in functionality needed for differential geometric calculations commonly encountered in General Relativity, classical and quantum field theory, and cosmology; though both general and somewhat more specialized packages do exist that attempt to fill this gap – see, for instance, Shtabovenko:2023idz Shoshany:2021iuc xAct Gravitas . The goal of this article is to introduce TensoriaCalc TC , a package that performs concrete (as opposed to abstract) differential geometry calculations, whereby various operations such as covariant derivatives can be carried out once an explicit metric has been entered. In particular, to maximize as much as possible user-friendliness, we have undertaken serious effort to ensure that using TensoriaCalc is very similar to using Mathematica itself. One of the key aspects of the Wolfram language is its symbolic computation ability. There is no programming overhead spent in terms of variable(s) declaration. Together with Mathematica ’s multitude of in-built functions, this means mathematical calculations can often be accomplished with a single or few lines of code. For instance, one may perform an indefinite integral, say of \sin x with respect to x – – without having to declare the integration variable x . (Strictly speaking, x and the abstract variables used in this paper should be identified in the Wolfram Language as Symbol(s), in that MatchQ[ x , \_ Symbol ]= True or, equivalently, Head [x]= Symbol.) Let us now illustrate how this straightforward style of symbolic computation works similarly for TensoriaCalc , by defining the metric tensor – the primary object in most differential geometry calculations. Defining a metric In TensoriaCalc , an arbitrary metric tensor may be defined by specifying its indices, explicit components, and the associated coordinate system. For example, the round 2- sphere geometry with the usual spherical coordinates \{0\leq\theta\leq\pi,\ 0\leq\phi<2\pi\} is defined either by the sum of squares of infinitesimal displacements – namely, in terms of (\text{d}\theta)^{2}=\text{DifferentialD}[\theta]^{2} and (\text{d}\phi)^{2}=\text{DifferentialD}[\phi]^{2} – or by its matrix representation. (The d can be entered via the keystrokes Esc dd Esc.) The box displaying the metric components is triggered by hovering the cursor over the g_{ab} . The same geometry may also be defined through the inverse metric, as a sum over the squares of the partial derivatives – namely, superposition of (\nabla\theta)^{2}=\mathrm{Del}[\theta]^{2}\;(\equiv\partial_{\theta}\otimes\partial_{\theta})\ \text{and}\ (\nabla\phi)^{2}=\mathrm{Del}[\phi]^{2}\;(\equiv\partial_{\phi}\otimes\partial_{\phi}) – or by its matrix representation. Above, the a and b indices cannot belong to the given coordinate system but are otherwise arbitrary Symbol’s. The SubMinus notation, \text{SubMinus}[a]=a_{-} and \text{SubMinus}[b]=b_{-} , indicates they are lower indices; while the SuperMinus notation, \text{SuperMinus}[a]=a^{-} and \text{SuperMinus}[b]=b^{-} , indicates they are upper indices. The StartIndex and TensorAssumption Rule’s are optional arguments; with default values given by StartIndex \to 0 and TensorAssumption \to\{\} . Our notation here follows that of the Wolfram Language, where optional arguments are Rule’s, with a predefined default value. In our online manual, whenever a default value for a function argument is given, that means the argument in question is an optional one. Note, however, even though Coordinates looks like an optional argument, it is actually mandatory. StartIndex refers to the integer associated with the first coordinate. For example, in the flat spacetime \text{d}s^{2}=\text{d}t^{2}-\text{d}\vec{x}^{2} , it is common practice to let the time t be not only the leading coordinate, but also labeled as t=x^{0} ; while x^{i}=(x^{1},\dots,x^{D}) are the spatial ones (where D is the dimension of space). For the 2- sphere metric at hand, StartIndex \to 1 means (x^{1},x^{2})=(\theta,\phi) . TensorAssumption allows the user to record properties of the parameters occurring within the metric components, which may then be invoked when, applying Simplify or FullSimplify on expressions. Other optional arguments associated with Metric are described in the online manual; which shall be released in the near future. Once a metric (or the inverse metric) has been defined, its inverse (or the metric) can be readily obtained by feeding it back into the Metric function. Upon the definition of a geometry through Metric, TensoriaCalc then outputs a Tensor object with arguments consisting of Rule’s containing the metric components, indices, coordinates, Christoffel symbols, Ricci scalar, Ricci tensor and Riemann tensor, etc. – see below. TensoriaCalc has built in functions to extract these geometric information. This allows for different geometries to be defined and computed within the same Mathematica session. Specifically, the g2Sphere reads as follows. This is analogous to, say, the output of any graphics related function in the Wolfram Language; where a Graphics object is generated, with its arguments containing the (text-based) relevant information that would allow Mathematica to display it correctly. For example, To extract the information stored within the metric Tensor object g2Sphere, we simply apply to it the associated functions: Indices, Coordinates, Christoffel, Riemann, Ricci, RicciScalar and the (metric) Determinant. TensorComponents applied to any Tensor object returns its components, usually a List. For instance, the components of the metric or inverse metric expressed as a square matrix (List of List’s) can themselves be extracted with TensorComponents. The 2 -sphere is a maximally symmetric spacetime with three Killing vectors – the maximum allowed for a two-dimensional ( 2D ) space. One feature of such a spacetime is that its Riemann tensor can be constructed from a tensor product of the metric: R_{abmn}=\frac{R}{2}g_{a[m}g_{n]b} , where [mn] denotes antisymmetrization; for e.g., T_{[mn]}\equiv T_{mn}-T_{nm} . Generic Tensor objects Let us now turn, briefly, to defining other (i.e., non-metric) tensors. Just as the above 2 -sphere metric was really a Tensor object, non-metric tensors may simply be directly entered as Tensor objects. A scalar \varphi , vector V^{a} , and rank-2 tensor T^{m}_{\phantom{m}n} are defined as follows. Note that the order of the arguments of Tensor is immaterial; we have set its Attributes to be Orderless. The information stored in an arbitrary Tensor object can be extracted in a similar way as we did for the metric Tensor. Specifically, the left hand sides of all replacement Rule’s occurring in a Tensor can be used an extraction function, in that applying it to the Tensor object returns the corresponding right hand side. Thus far, we have dealt with tensors with abstract indices. If we wish to extract specific components of tensors, however, we would need to evaluate their indices at the desired coordinates or their associated numerical values. For the 2 -sphere example at hand, with StartIndex \to 1 , we may re-construct the metric component-by-component. Or, extract the 2\times 2 matrix given by the Christoffel symbol \Gamma^{\theta}_{\phantom{\theta}mn}=\Gamma^{1}_{\phantom{1}mn}