OGRe: An Object-Oriented General Relativity Package for Mathematica
Abstract
v2.0.0 (2026-05-02) After 4.5 years with no updates, a major OGRe update is finally here! This long-anticipated update includes numerous new features, improvements, and bug fixes. Many of these are due to feature requests, bug reports, and other feedback from the scientific community - submitted on GitHub, sent by email, or even discussed in person at conferences. More updates are coming soon! Breaking changes (may break pre-v2.0.0 code): Replacing all TCalc* modules with cached references: The modules for built-in tensors derived from a metric: TCalcChristoffel, TCalcEinsteinTensor, TCalcGeodesicFromChristoffel, TCalcGeodesicFromLagrangian, TCalcGeodesicWithTimeParameter, TCalcLagrangian, TCalcRicciScalar, TCalcRicciTensor, and TCalcRiemannTensor, have been removed. They are replaced by new modules: TChristoffel, TEinstein, TGeodesicFromChristoffel, TGeodesicFromLagrangian, TGeodesicWithTimeParameter, TLagrangian, TRicciScalar, TRicci, and TRiemann. Unlike the TCalc* modules, the new modules do not perform a calculation every time they are called, and do not generate new user-accessible tensors with IDs of the form " " (such as "SchwarzschildRiemann"). Instead, the new modules perform the calculation only the first time they are called, and then cache the results internally and reuse them on subsequent calls. To access the calculated tensor, you don't use a separate tensor ID (like "SchwarzschildRiemann"); instead, you call the module directly every time (e.g. TRiemann["Schwarzschild"]). This new syntax can be used with most modules that accept tensors, for example TList[TRiemann["Schwarzschild"]], and also in arbitrary tensor calculations with indices using TCalc[], for example TCalc[TRiemann["Schwarzschild"]["\[Lambda]\[Mu]\[Lambda]\[Nu]"],"R"]. The new design makes the package much more user-friendly and easy to use, and it avoids recalculating the same tensor multiple times, cluttering the namespace with many derived tensor IDs, and having to use long and confusing IDs like "SchwarzschildRiemann". Internally, the tensors are cached inside the metric object itself, so they will be exported when using TExport[] on the metric. The new modules essentially just return special reference IDs of the form " -> ", with -> separating the metric of origin from the tensor's role, for example "Schwarzschild->Riemann". These references are then routed to the cached tensors automatically, but the user doesn't need to use the references directly; the new modules should be used instead. You cannot change the ID, symbol, or default indices/coordinates of the cached tensors. Tensor IDs created by the user can no longer contain ->, as this is now reserved for references to cached tensors. Migration guide for pre-v2.0.0 code: Wherever you used a TCalc* module or a derived tensor ID, use the corresponding new module instead, noting that some module names have been shortened (the word Tensor was removed). For example, if before you used TCalcEinsteinTensor["MyMetric"] to calculate the Einstein tensor, and then used the tensor ID "MyMetricEinsteinTensor" to refer to the calculated tensor, now you should simply use TEinstein["MyMetric"] instead, in both cases. The module TCalcNormSquared[] has also been removed, and replaced by TNormSquared[]. The new module returns a scalar expression directly instead of creating a rank-0 tensor object, and accepts an optional coordinate system as the second argument. It does not cache the result, and it can be used for tensors of any type. Migration guide for pre-v2.0.0 code: Wherever you used TCalcNormSquared[] before, use TNormSquared[] now, and note that the result is given directly. For example, if before you used TCalcNormSquared["MyTensor"] and subsequently accessed the scalar component using TGetComponents["MyTensorNormSquared"], now you should simply use TNormSquared["MyTensor"] instead and get the scalar directly. TAddCoordTransformation[] and TChangeID[] now use , instead of -> to separate the first two arguments, so that tensor ID completion can work properly. The old -> syntax has been removed, so old code using -> will need to be updated to use the new syntax. Migration guide for pre-v2.0.0 code: Replace TAddCoordTransformation["MyCoords1"->"MyCoords2",rules] with TAddCoordTransformation["MyCoords1","MyCoords2",rules]. Replace TChangeID["MyTensor1"->"MyTensor2"] with TChangeID["MyTensor1","MyTensor2"]. TVolumeElementSquared[] has been renamed to TMetricDeterminant[], as this is a more accurate name for what the module actually calculates, the determinant of the metric, which may be negative for pseudo-Riemannian metrics. A new module, TVolumeElement[], calculates the actual volume element of a given metric in the form $\mathrm{d}V = \sqrt{|\det(g)|} , {\mathrm{d}x}^{0} \wedge \cdots \wedge {\mathrm{d}x}^{n-1}$, where $n$ is the number of dimensions. Migration guide for pre-v2.0.0 code: Replace TVolumeElementSquared["MyMetric"] with TMetricDeterminant["MyMetric"]. UI improvements: Tensor ID completion: A widely requested feature is now implemented, making OGRe much more user-friendly and easy to use! All OGRe modules that take existing tensor IDs as arguments will now show a dropdown menu with a list of relevant IDs - coordinate systems, metrics, and/or tensors - as soon as you type the opening double quotes for a string in a relevant argument position. Some other strings are also auto-completed, such as common symbols. For example: TList[", TShow[", and TGetComponents[" will show a list of all tensors. TRiemann[", TLagrangian[", and TGeodesicFromChristoffel[" will show a list of all metrics. TAddCoordTransformation[", TNewMetric["MyMetric", ", and TNewTensor["MyTensor", "MyMetric", " will show a list of all coordinate systems (for the first, second, and third argument respectively). TNewMetric[..., " will show a list of commonly used metric symbols (for the last argument). TSetCurveParameter[" will show a list of commonly used curve parameter symbols. And so on. Added SyntaxInformation for all public modules. This allows Mathematica to indicate when an argument is missing, or if there are too many arguments. New modules: TKretschmann[] calculates and caches the Kretschmann scalar of a metric. TWeyl[] calculates and caches the Weyl tensor of a metric. TDim[] returns the dimension of a tensor's manifold. TRank[] returns the rank of a tensor. TSetSimplifyFunc[] allows setting a custom simplification function. TTeXShow[] returns the output of TShow[] as a TeX string. TTeXList[] returns the output of TList[] as a TeX string. TSetExactSignChecks[] can be used to enable or disable exact sign checks. When exact sign checks are enabled (the default), if TList cannot detect equality of two components up to sign by direct comparison, it checks whether the sum of the components can be proven to equal zero, which may require simplification. For tensors with complicated components, this may take a long time, in which case this option can be disabled using TSetExactSignChecks[False]; however, TList will then only be able to detect when two components are the same up to sign in simple cases. Changes to existing modules: TInfo[] now displays the dimension and rank. TList[], TShow[], and TGetComponents[]: The modules TList[], TShow[], and TGetComponents[] now accept a rule or a list of rules as an optional argument. This applies ReplaceAll[rules] to each of the tensor's elements, and then automatically simplifies them, before they are displayed or returned. The full syntax of these modules is now: TList[ID, indices, coordinatesID, rules, function] TShow[ID, indices, coordinatesID, rules, function] TGetComponents[ID, indices, coordinatesID, rules, function] Any of the arguments can be omitted. If both rules and function are given, the rules will be applied before the function. TList[] and TShow[] now use spacers instead of invisible letters to align the indices, which will make copied components less awkward (each index will only appear once). TExportAll[] and TImportAll[] now handle file errors better, add the .m extension if an extension is not provided (unless the file name explicitly ends with a dot), and print out the full path of the file as a hyperlink that can be clicked to open it directly in Mathematica. TCheckForUpdates[] now uses GitHub releases to check for updates, instead of looking directly into the source code. If a new version is available, it gives a link to the release notes, and also allows viewing the release notes directly in the notebook. TDocs[] now loads the documentation for the version of the package that is currently installed, instead of always loading the documentation for the latest version. TImport[] now checks if the metric and coordinates used by the imported tensor exist and have the correct dimension before importing. TCovariantD[] now preserves the default index configuration of the tensor, matching the behavior of TPartialD[] (previously, TCovariantD[] always acted on the representation with all upper indices). Derivative shorthand notation: TList[] and TShow[] now use a clearer shorthand notation for derivatives. Previously the shorthand for something like Derivative[1, 1, 2][f][x, y, z] was $\partial_{x,y,z^2}f$, which was confusing, especially because it seems like the last derivative is with respect to $z^2$, rather than a second derivative with respect to $z$. Now the shorthand for the same is $\partial_x \partial_y \partial_z^2 f$, which more closely resembles familiar tensor notation. Additionally, the shorthand notation has been made more clear in cases where the derivative is taken to a power. Previously the shorthand for something like a'[t]^2 was $\partial_t a^2$, which makes it look like the function itself is squared, instead of the derivative. Now the shorthand for the same is $(\partial_t a)^2$, which is much more clear. Lagrangians
Fields of Study & Subjects
Matrix Theory and Algorithms
Numerical methods for differential equations
Computational Physics and Python Applications
Publication details
- Publication date
- 2 May 2026