1 Introduction

The parametrized post-Newtonian (PPN) formalism [1,2,3,4,5,6,7] is an indispensable tool for testing the viability of gravity theories. It is used to characterize any given theory of gravity by a set of ten parameters, which are closely related to the phenomenological properties of the theory under consideration. This allows to compare the parameters which are obtained theoretical through the PPN formalism with their values measured in experiments within the solar system and related physical settings.

In order for the PPN formalism to be applicable, the gravity theory under consideration must satisfy a number of assumptions. The most important is the existence of a metric governing the motion of test bodies, which can be described by a perturbation around a flat Minkowski background. Another assumption concerns the source of gravity, which is chosen to be a fluid satisfying the covariant conservation of energy-momentum, encoded in the Euler equations of fluid dynamics. Further, it is assumed that the field equations are of second derivative order, or can be brought into this form, so that their solution take a known standard form in terms of particular Poisson-like integrals over the source matter distribution.

In order to determine the post-Newtonian limit of a given gravity theory, one must perform a \(3+1\) split of its field equations (which are, in general, tensor equations) into space and time components, and then perform a perturbative expansion around a fixed vacuum solution. Depending on the structure of the field equations, both tasks may be challenging to perform by hand, and so the use of computer algebra comes as a useful tool. Due to the common assumptions on which the PPN formalism is based, and the similar steps to be applied to different theories of gravity, it appears natural to implement these common tasks into a general computational tool, which can then be used to calculate the post-Newtonian limit for any given theory. A number of functions to achieve this has already been implemented in Maple [8]. The aim of xPPN[9] is to provide another implementation, based on a more extensive framework for performing tensor calculations.

A very powerful tensor algebra software is the xTensor package, which is part of the xAct suite of Mathematica packages [10]. It comes with numerous functions to define and manipulate tensorial expressions, and includes concepts such as induced metrics on hypersurfaces orthogonal to a vector field, or component calculations in xCoba, which can be used to achieve a \(3+1\) split of tensorial expressions. The former is employed, for example, for cosmological perturbation theory in the xPand package [11], in conjunction with the xPert package [12] for general tensor perturbations. It thus appears natural to follow a similar approach to implement also the PPN formalism in xAct. However, the latter comes with a few peculiarities which obstruct this strategy. The main difficulty lies in the different treatment of space and time in the PPN formalism, such as assigning different perturbation orders to space and time components of tensors. Another, albeit smaller issue is the different convention for counting the perturbation orders in xPert and the PPN formalism.

Even though it is possible to implement the PPN formalism also using the existing functionality mentioned above, it appears simpler to overcome the aforementioned difficulties by using a different approach both to the \(3+1\) split and the perturbative expansion, without using the induced metric framework or the xCoba and xPert packages. This is the approach followed by xPPN. The key idea is to complement every tensor defined on the spacetime manifold by a number of tensors on a purely spatial manifold, which additionally depend on an external time parameter, and which represent the separated time and space components of the original spacetime tensor. Also derivatives are split into spatial derivatives and derivatives with respect to the time parameter. This approach allows an essentially different treatment of perturbations for space and time components. The aim of this article is to present this approach, as well as the implementation of the PPN formalism which is based on this framework.

This article is structured as follows. We start with a brief review of the PPN formalism and its extensions implemented by xPPN in Sect. 2. The general concepts on which this implementation is based are explained in Sect. 3. The main functionality of xPPN is laid out in Sect. 4, where we display the geometric objects defined by xPPN, and Sect. 5, where we explain the functions provided for the common operations on tensor expressions. A complete usage example is given in Sect. 6, which shows how to calculate the PPN parameters of a simple scalar-tensor theory of gravity. A summary and outlook towards possible future extensions are given in Sect. 7. For further reference, we provide notes on the implementation and internal operation of xPPN in Appendix A.

In order to make code listings more readable, the following syntax highlighting is used. Mathematica keywords are typeset in , xAct keywords are typeset in and xPPN keywords are typeset in . We use lowercase letters for coordinate indices and uppercase letters for Lorentz indices, where in both cases Greek indices run from 0 to 3 and belong to spacetime, while Latin indices run from 1 to 3 and belong to space only.

2 Parametrized post-Newtonian formalism

The aim of the xPPN package is to provide an implementation of the parametrized post-Newtonian (PPN) formalism and several of its geometric extensions. Here we briefly summarize these theoretical foundations. We first discuss the standard PPN formalism and the perturbative expansion of the metric in Sect. 2.1. An extended formulation using a tetrad as the fundamental field instead of the metric is shown in Sect. 2.2. We then display its application to teleparallel gravity in Sect. 2.3 and symmetric teleparallel gravity in Sect. 2.4.

2.1 Standard formalism for Riemannian geometry

There exist different versions of the PPN formalism. Here we adhere to its form presented in [5]. Its starting point is the assumption that the propagation of light and massive test bodies is governed by a pseudo-Riemannian metric \(g_{\alpha \beta }\) of Lorentzian signature. This metric is further considered in a weak field limit as an asympotically flat perturbation around a flat Minkowski background. The source of this perturbation is assumed to be of compact support and modeled by the energy-momentum tensor

$$\begin{aligned} \Theta ^{\alpha \beta } = (\rho + \rho \Pi + p)u^{\alpha }u^{\beta } + pg^{\alpha \beta } \end{aligned}$$
(1)

of a perfect fluid with four-velocity \(u^{\alpha }\), rest energy density \(\rho \), specific internal energy \(\Pi \) and pressure p. Further, a fixed Cartesian coordinate system \((x^{\alpha }) = (t, x^a)\) is used, denoted as the universe rest frame. It is then assumed that the velocity \(v^a = u^a/u^0\) of the source matter in this coordinate system is small compared to the speed of light, \(|v^a| \ll c \equiv 1\). This velocity takes the role of the perturbation parameter. Physical quantities, such as the metric, are expanded in terms of the source velocity, and any term in this perturbative expansion which is proportional to \(|v^a|^n\) is said to be of n’th velocity order, which is commonly denoted \({\mathcal {O}}(n)\) in the literature.Footnote 1 For the metric \(g_{\alpha \beta }\), this expansion may be written explicitly in the form

(2)

where we used overscripts to indicate velocity orders . Terms beyond the fourth velocity order are usually not considered in the standard PPN formalism implemented by xPPN. The zeroth velocity order is assumed to be the flat Minkowski background,

(3)

For the metric perturbations, one finds that the first velocity order vanishes, , since the lowest velocity order of the matter source is the second order, as we will argue below. Further, the components change their sign under time reversal, and are prohibited by energy-momentum conservation. It follows that only the components

(4)

are non-vanishing. For the first four terms, a particular standard gauge is assumed, in which the metric components take the form

(5a)
(5b)
(5c)
(5d)

For the last term no such expansion is assumed in the standard PPN formalism, but it may be included in an extended formalism [13, 14]. The terms on the right hand side are the so-called PPN potentials and PPN parameters; see Sects. 4.6 and 4.7 for their definition and [5] for a physical explanation. Here the PPN potentials describe the matter distribution, and their form is independent of the theory under consideration, while the PPN parameters are independent of the matter distribution, and their values are determined by the gravity theory. In order to determine the values of the PPN parameters for a given gravity theory, one follows a well-defined procedure to expand the gravitational field equations into velocity orders, which are then solved successively, up to the fourth order. The virtue of the PPN formalism is the fact that this form of the metric is sufficiently generic to solve the metric field equations of a large number of gravity theories, in which the source of gravity is the matter energy-momentum. In order to obtain this solution, one must also decompose the energy-momentum tensor (1) into space and time components, as well as into velocity orders. For the matter variables, one assigns the orders \(\rho \sim \Pi \sim {\mathcal {O}}(2)\) and \(p \sim {\mathcal {O}}(4)\), based on their order of magnitude in the solar system. Lowering the indices of the energy-momentum tensor, its components then take the form

(6a)
(6b)
(6c)

Further, one assumes that the gravitational field is quasi-static, which means that it changes only due to the motion of the source matter, excluding, e.g., transient gravitational waves. Hence, time derivatives of all physical quantities are weighted with an additional velocity order, \(\partial _0 \sim {\mathcal {O}}(1)\). In particular, this affects derivatives of the metric, which enter the field equations through the Levi–Civita connection

(7)

and its curvature tensor. Here and in the following, we denote terms related to the Levi–Civita connection with an empty circle, in order to distinguish them from other connections to be introduced later, following the standard convention in the literature on teleparallel and related gravity theories, where this distinction becomes relevant; note that this circle is a distinct symbol from a zero denoting the zeroth velocity order.

2.2 Tetrad extension

There exist numerous gravity theories in which one of the fundamental fields is a tetrad (or coframe) field \(\theta ^{\Gamma }{}_{\alpha }\), which defines the metric via the relation

$$\begin{aligned} g_{\alpha \beta } = \eta _{\Gamma \Delta }\theta ^{\Gamma }{}_{\alpha }\theta ^{\Delta }{}_{\beta }, \end{aligned}$$
(8)

where \(\eta _{\Gamma \Delta } = \mathrm {diag}(-1, 1, 1, 1)\) is again the Minkowski metric, here with Lorentz indices. Its post-Newtonian expansion can be obtained as follows [15,16,17]. Its zeroth order is given by a diagonal background tetrad,

(9)

defined in the previous section. For any higher order terms in its perturbative expansion, it turns out to be more convenient to work with the expressions [18, 19]

(10)

which carry only spacetime indices, where

$$\begin{aligned} \Delta _{\Gamma }{}^{\alpha } = \mathrm {diag}(1, 1, 1, 1) \end{aligned}$$
(11)

is the inverse background tetrad. While it is entirely possible to use the perturbations as fundamental variables, it turns out to be more convenient to decompose them into metric perturbations and another, independent degree of freedom. This can be achieved by noting that the metric perturbations follow from the relation (8) to be given by

(12)

Hence, the nth order metric perturbation encodes the symmetric part of the tetrad perturbation, up to lower order terms. Isolating the highest orders from the sum on the right hand side, we find that this symmetric part is given by

(13)

For the antisymmetric part, which constitute the aforementioned independent degree of freedom, one may define another, antisymmetric tensor field by

(14)

In summary, the perturbative orders of the tetrad for \(n \ge 1\) are then defined as

(15)

in terms of and . Following a similar line of argument as for the metric, the only non-vanishing components of the antisymmetric tensor up to the fourth velocity order which must be considered are given by

(16)

Note finally that the tetrad \(\theta ^{\Gamma }{}_{\alpha }\) comes also with an inverse, the frame field \(e_{\Gamma }{}^{\alpha }\). It follows from its relation with the coframe field that its background is the diagonal element , while higher perturbation orders are recursively defined as

(17)

where the tetrad perturbations on the right hand side are further expanded using the rule (15).

2.3 Teleparallel geometry

The tetrad and its perturbative expansion discussed above play a fundamental role as the dynamical field variable in a particular class of gravity theories known as teleparallel gravity [20]. In their covariant formulation [21], another fundamental field variable is used, which is the spin connection . Together with the tetrad and its inverse, it defines another connection, whose coefficients are given byFootnote 2

(18)

The spin connection is further restricted to be flat and antisymmetric, so that also the affine connection has vanishing curvature and is metric-compatible,

(19)

but it possesses non-vanishing torsion. Under these conditions, the spin connection turns out to be a gauge quantity, so that one can locally choose a Lorentz gauge in which it vanishes, known as the Weitzenböck gauge [22]. Choosing this gauge, , the connecting coefficients (18) are expressed in terms of the tetrad and its inverse alone [18]. This allows to derive their perturbative expansion, and the perturbative expansion of any derived tensor fields, in terms of the perturbations (15) and (17), and hence in terms of and .

2.4 Symmetric teleparallel geometry

Finally, the third class of gravity theories discussed here has become known as symmetric teleparallel gravity theories [23]. In these theories yet another connection is employed, whose coefficients we denote by , and which is assumed to have vanishing curvature and torsion,

(20)

It follows from these properties that there exists a local coordinate system \((x'^{\alpha })\), called the coincident gauge, such that its connection coefficients in this coordinate system vanish [24]. Hence, in the standard PPN coordinate system \((x^{\alpha })\), the connection coefficients are given by

(21)

The post-Newtonian expansion of these connection coefficients is derived from the assumption that the two coordinate systems \((x^{\alpha })\) and \((x'^{\alpha })\) are related by an infinitesimal coordinate transformation, induced by a vector field \(\xi ^{\alpha }\), so that up to the quadratic order one can write

$$\begin{aligned} x'^{\alpha } = x^{\alpha } + \xi ^{\alpha } + \frac{1}{2}\xi ^{\beta }\partial _{\beta }\xi ^{\alpha } + \cdots \end{aligned}$$
(22)

From this assumption follows that the connection coefficients take the form

(23)

also up to the quadratic order in the vector field \(\xi ^{\alpha }\). Finally, the vector field is expanded in velocity orders. It turns out that in the PPN formalism the only non-vanishing components are given by [25]

(24)

From these components the perturbative expansion of the connection coefficients is obtained.

3 Mathematical foundation

Two fundamental mathematical concepts form the basis of the PPN formalism detailed in the previous section, and so their implementation is an important part of any computational tool to address this formalism. Here we briefly discuss these concepts and their formulation we choose to implement in xPPN. This will serve as an explanation of the mathematical background for the following sections. We discuss the split of tensors on spacetime into their space and time parts in Sect. 3.1 and the perturbative expansion into velocity order in Sect. 3.2.

3.1 \(3+1\) split of tensors

As explained in the previous section, one of the crucial steps in applying the PPN formalism is the \(3+1\) decomposition of all tensorial quantities. A proper, geometric interpretation of this split can be given by regarding the spacetime manifold \(M_4\), equipped with coordinates \((x^{\alpha }) = (t, x^a)\), as a product manifold \(M_4 \cong T_1 \times S_3\), where t is the time coordinate on the manifold \(T_1 \cong {\mathbb {R}}\), while \((x^a)\) are the spatial coordinates on \(S_3\). It follows that for every \(t \in T_1\), one can find a map \(i_t: S_3 \rightarrow M_4, (x^a) \mapsto (t, x^a)\), whose image in \(M_4\) is called the spatial slice, or constant time hypersurface at time t. The collection of all spatial slices then forms a foliation of \(M_4\).

While the construction appears abstract, it gives a clear interpretation of the \(3+1\) split of tensor fields as follows. A vector field with components \(X^{\alpha }\) on \(M_4\) splits in the form

$$\begin{aligned} X^{\alpha }\partial _{\alpha } = X^0\partial _0 + X^a\partial _a \end{aligned}$$
(25)

into a temporal part \(X^0\partial _0\), which is parallel to the coordinate lines generated by the time coordinate t, and a spatial part \(X^a\partial _a\), which is tangent to the spatial hypersurfaces. Under purely spatial coordinate transformations, \(X^0\) behaves as a scalar, while \(X^a\) are the components of a vector field. For any fixed value of t, we may thus take the pullback along \(i_t\) to obtain a scalar function \(i_t^*X^0\), as well as a vector field \(i_t^*(X^a\partial _a)\), both now being tensor fields on \(S_3\), hence functions of the spatial coordinates \((x^a)\). The dependence of the components \(X^{\alpha }\) on the time coordinate t is still present as a dependence on the choice of the spatial hypersurface, and t is regarded as a parameter which corresponds to this choice, instead of a coordinate.

The interpretation of time t as a parameter instead of a coordinate is, of course, purely mathematical, but it allows for a number of simplification when it comes to the implementation of the \(3+1\) split in computer algebra. Most importantly for the PPN formalism, it allows to treat time derivatives \(\partial _0\) essentially differently from spatial derivatives \(\partial _a\). This is necessary, because in the PPN formalism time derivatives are weighted with an additional velocity order, which is not the case for spatial derivatives. Another advantage becomes apparent when considering tensors with symmetries. For example, considering an antisymmetric tensor field \(A_{\alpha \beta }\), the \(3+1\) split can be written as

$$\begin{aligned} A_{\alpha \beta }\mathrm {d}x^{\alpha } \otimes \mathrm {d}x^{\beta }= & {} A_{00}\mathrm {d}t \otimes \mathrm {d}t + A_{0a}\mathrm {d}t \otimes \mathrm {d}x^a \nonumber \\&+ A_{a0}\mathrm {d}x^a \otimes \mathrm {d}t + A_{ab}\mathrm {d}x^a \otimes \mathrm {d}x^b, \end{aligned}$$
(26)

where \(A_{00} = 0\) and \(A_{0a} = -A_{a0}\). Hence, the independent components can be described by a single covector field \(A_{0a}\) and antisymmetric tensor field \(A_{ab}\) on \(S_3\). Thus, the use of tensor symmetries in conjunction with the \(3+1\) split allows to immediately discard vanishing components, which helps to simplify the calculation.

The outlined interpretation of the \(3+1\) split and the decomposition of tensor fields on spacetime \(M_4\) into tensor fields on space \(S_3\), with an additional parameter dependence, and corresponding counting of velocity orders, are a central ingredient of xPPN. In Sect. 5.1 we explain how to select certain components from the \(3+1\) decomposition of a tensor field, while Sect. 5.3 shows how to decompose arbitrary tensorial expressions. The implementation of these operations is outlined in Appendix A.1, which shows the internal representation of decomposed tensor fields, while in Sect. A.2 we schematically explain the decomposition algorithm and its treatment of tensor symmetries.

3.2 Perturbative expansion in velocity orders

Another important ingredient of the PPN formalism is the perturbative expansion of tensor fields into velocity orders. Similarly to the expansion (2) for the metric, also any other tensor field A is expanded as

(27)

where each term is of the corresponding velocity order , and where we omit tensor indices for brevity. Note that this is different from the convention used, e.g., in the xPert package [12], where the perturbative expansion takes the form

$$\begin{aligned} A = \sum _{n = 0}^{\infty }\frac{\varepsilon ^n}{n!}\Delta ^n[A], \end{aligned}$$
(28)

and thus has the explicit form of a Taylor expansion in the perturbation parameter \(\varepsilon \). We therefore list a few formulas which follow from the perturbative expansion (27). Most notably, for a tensor \(A = A_1 \cdots A_N\) given as a product of N tensors \(A_1, \ldots , A_N\), one has the nth order term given by

(29)

where the orders \(k_i\) of the factors \(A_i\) run over non-negative integers. Another important relation is the expansion of expressions \(F = f(A)\), where f is a scalar, or more general a tensorial function. In this case a Taylor expansion of the function f around the background is used,

(30)

where \(f^{(k)}\) denotes the kth derivative, and then the product formula (29) is applied. For a function of N arguments, this formula naturally generalizes to

(31)

Finally, time derivatives are weighted with an additional velocity order, and so for \(A' = \partial _0A\) one has

(32)

and analogously for higher derivative orders, where the left hand side is to be understood as the nth order term in the expansion of \(A'\).

In xPPN, the perturbative expansion of tensor fields into velocity orders, which takes into account the rules outlined above, is implemented in the function , which is explained in detail in Sect. 5.4. A few notes on the implementation of this function are given in Appendix A.3.

4 Geometric objects defined by xPPN

The PPN formalism relies on the existence of a number of objects, such as the spacetime manifold, the physical metric and its background value, as well as a particular set of potentials and constant parameters, which are necessary for its application to any gravity theory. For convenience, these objects are already defined by xPPN when the package is loaded, so that the user must define only those additional geometric objects which are specific to the gravity theory under consideration. Here we give an overview of these pre-defined objects. The manifolds corresponding to the split of spacetime into space and time, as well as a number of bundles over these manifolds, are given in Sect. 4.1. To define tensors on these manifolds and write tensorial expressions, xAct relies on indices; Sect. 4.2 lists the indices defined by xPPN for the given bundles. The geometric objects constituting the background geometry are listed in Sect. 4.3, while Sect. 4.4 gives a detailed account of the dynamical geometry and its perturbative expansion. The energy-momentum tensor and its expansion in fluid variables is shown in Sect. 4.5. Finally, the objects constituting the standard PPN metric are the PPN potentials detailed in Sect. 4.6 and the PPN parameters listed in Sect. 4.7.

4.1 Manifolds and bundles

Tensors in xTensor are defined with respect to a manifold. In order to implement the \(3+1\) decomposition discussed in Sect. 3.1, xPPN defines three manifolds:

  1. 1.

    is the one-dimensional time manifold \(T_1\).

  2. 2.

    is the three-dimensional space manifold \(S_3\). All tensors for which the \(3+1\) split into time and space components has been carried out are defined on this manifold, with an additional dependence on the time parameter .

  3. 3.

    is the four-dimensional spacetime manifold \(M_4 \cong T_1 \times S_3\). It is defined as a product manifold, so that sums over tensor indices of \(M_4\) may automatically be decomposed into sums over \(T_1\) and \(S_3\). All geometric objects which appear in the theory under consideration should be defined on this manifold.

Each of these manifolds is canonically equipped with a tangent bundle; xTensor defines these automatically, and they are named , and , respectively, and denoted by prefixing the manifold symbol with \({\mathbb {T}}\). In addition, xPPN defines another vector bundle over each of these three manifolds, whose rank is the same as the dimension of the manifold, and which is used to define quantities carrying Lorentz indices. These bundles are named , and , respectively, and denoted by prefixing the manifold symbol with \({\mathbb {L}}\).

4.2 Indices

Indices play an important role in xTensor, since they are used to denote tensor expressions and establish the relation between tensor slots and vector bundles. Often a large number of indices is necessary for longer tensor expressions, and each of them must be defined as a symbol (possibly with an appended number). xPPN addresses this problem by pre-defining a large number of indices using symbols which are unlikely to collide with other notation. In particular, the following indices are defined:

  1. 1.

    is used by xPPN to denote the time component of the \(3+1\) decomposed forms of tensors, and is printed as 0. From the viewpoint of xTensor, this is a label index, which is not associated with any vector bundle and has no implied meaning. It is used because \(3+1\) decompositions are defined on \(S_3\), and so only spatial indices can be associated with the tangent bundle. Also it may appear an arbitrary number of times and in any position in any tensor expression.

  2. 2.

    (printed as ) is the generic index on the tangent bundle \({\mathbb {T}}T_1\). xTensor will use this to automatically generate as many indices as needed as an intermediate step when performing a \(3+1\) decomposition of indices, before replacing them with 0.

  3. 3.

    (printed as ) is the generic index on the Lorentz bundle \({\mathbb {L}}T_1\). It is used by xTensor in the same way as on \({\mathbb {T}}T_1\).

  4. 4.

    Lowercase Latin letters \(a, \ldots , z\) (character codes 97–122) are used to denote indices on \({\mathbb {T}}S_3\). xPPN automatically defines the symbols , \(\ldots \), to denote these indices, so that there is no need for the user to manually declare any indices, while at the same time avoiding possible name conflicts and leaving single letters free for other use. The prefix “T3” is omitted when the symbol is printed in output form, so that only the index letter itself appears in printed output.

  5. 5.

    Uppercase Latin letters \(A, \ldots , Z\) (character codes 65–90) are used to denote indices on \({\mathbb {L}}S_3\). As for the lowercase indices listed in the previous item, xPPN defines symbols , \(\ldots \), for these uppercase indices, and omits the prefix “L3” when printing the indices in output form.

  6. 6.

    Lowercase Greek letters \(\alpha , \ldots , \omega \) (character codes 945–969, 977, 981, 982, 1008, 1009, 1013) are used to denote indices on \({\mathbb {T}}M_4\). The corresponding symbols defined by xPPN are denoted , \(\ldots \), .

  7. 7.

    Uppercase Greek letters \(\mathrm {A}, \ldots , \Omega \) (character codes 913–929, 931–937) are used to denote indices on \({\mathbb {L}}M_4\). The corresponding symbols defined by xPPN are , \(\ldots \), .

To obtain a list of pre-defined indices for any of these bundles, the xTensor command may be used. For example, to list all indices defined on \({\mathbb {T}}M_4\), use:

figure aa

The Mathematica command , together with a string pattern, may also be used to list these indices. This will give a similar result as the aforementioned command:

figure ac

4.3 Background geometry

xPPN automatically defines a number of geometric objects corresponding to the background geometry, around which the perturbative PPN expansion is performed. On each of the three manifolds \(T_1, S_3, M_4\) a metric, a tetrad and an inverse tetrad are defined. They are denoted as given in Table 1. Each of these geometric objects is defined to be constant with respect to the partial derivative on its respective manifold, so that applied to any of these objects vanishes. Further, contractions of a tetrad and its inverse are carried out automatically, and yield the corresponding tensor.

Table 1 Background geometric objects defined by xPPN

NB! Note that each of the background metrics is defined as the first metric on its respective manifold. Hence, it is also used by xTensor in order to raise and lower indices, such that for a vector defined as \(A^{\alpha }\) one has \(A_{\alpha }A^{\alpha } = A^{\alpha }A^{\beta }\eta _{\alpha \beta }\), which can easily be verified by using the xTensor command :

figure aq

In order to raise and lower indices with the physical metric \(g_{\alpha \beta }\), the metric (as defined in the following section) must be written out explicitly.

4.4 Dynamical geometry

The background geometry detailed above is defined independently of any gravity theory and matter configuration. This is contrasted with the dynamical geometry which we discuss next. These are the dynamical fields which are used to mediate the gravitational interaction, and which are related to the matter source by the gravitational field equations. The most important of these geometric objects is the metric, which we discuss in Sect. 4.4.1. A similar role may be taken by the tetrad, as shown in Sect. 4.4.2. Further, three covariant derivatives are defined, which represent the three connections used in different formulations of general relativity [26]: the Levi–Civita connection in Sect. 4.4.3, the teleparallel connection in Sect. 4.4.4 and the symmetric teleparallel connection in Sect. 4.4.5.

4.4.1 Metric

As detailed in Sect. 2.1, the central object in the PPN formalism is the metric \(g_{\alpha \beta }\), which is denoted by in xPPN. Its inverse \(g^{\alpha \beta }\) is written as . Also here it must be emphasized that this is different from , which would be interpreted differently:

figure au

A number of rules are defined for the perturbative expansion of the metric, and automatically applied when this expansion is performed. The zeroth order reduces to the background Minkowski metric (3), and so its space and time components are given by

(33)

The remaining components, up to the fourth velocity order, are set to vanish, except for the components (4), for which no further rules are defined. These must be solved for in order to determine the PPN parameters. See Sect. 5.2 for more information how to apply these rules using the function .

4.4.2 Tetrad

In order to implement the tetrad extension to the PPN formalism detailed in Sect. 2.2, xPPN defines the tetrad \(\theta ^{\Gamma }{}_{\alpha }\) as the object , together with an appropriate set of rules to evaluate its perturbative expansion using the formula (15). The antisymmetric tensor field \(a_{\alpha \beta }\) occurring in this expansion is denoted by in xPPN. Further, next to the tetrad, also its inverse \(e_{\Gamma }{}^{\alpha }\) is defined in xPPN, which is entered as . A number of automatically applied rules are defined for these inverse tetrads, so that they are contracted with tetrads if possible, and derivatives are evaluated according to

$$\begin{aligned}&e_{\Gamma }{}^{\alpha }\theta ^{\Gamma }{}_{\beta } = \delta ^{\alpha }_{\beta }, \quad e_{\Gamma }{}^{\alpha }\theta ^{\Delta }{}_{\alpha } = \delta _{\Gamma }^{\Delta }, \quad \nonumber \\&\partial _{\beta }e_{\Gamma }{}^{\alpha } = -e_{\Gamma }{}^{\gamma }e_{\Delta }{}^{\alpha }\partial _{\beta }\theta ^{\Delta }{}_{\gamma }. \end{aligned}$$
(34)

Further, perturbations of the tetrad are evaluated following the formula (17), together with expanding the tetrad perturbation using the expansion (15).

4.4.3 Levi–Civita connection

Together with the metric , xPPN defines its unique metric-compatible, torsion-free Levi–Civita connection, whose coefficients are defined from the metric by the well-known formula (7). The corresponding covariant derivative is entered as , and it is written in postfix notation using a semicolon “;”, as well as using the symbol in prefix notation, to distinguish it from other covariant derivatives introduced later. xTensor automatically defines a number of tensors for any covariant derivative. Most notably are the Christoffel “tensors” , which are defined as the difference between the connection coefficients and the (vanishing) coefficients of a fiducial connection associated to the partial derivatives \(\partial _{\alpha }\) with respect to the coordinates. Further, xTensor defines a number of curvature tensors, such as the Riemann, Ricci, Einstein and Weyl tensors. xPPN defines the corresponding perturbative expansions in terms of the metric perturbations for all tensor fields derived from the covariant derivative .

4.4.4 Teleparallel connection

In order to work with teleparallel gravity theories, as discussed in Sect. 2.3, xPPN defines also the teleparallel connection (18), along with its torsion tensor and their perturbative expansion. The corresponding covariant derivative is entered as , and is denoted in prefix notation and a bar “|” in postfix notation. Working in the Weitzenböck gauge implies that the connection coefficients take the simple form

(35)

and their perturbative expansion is defined accordingly.

4.4.5 Symmetric teleparallel connection

Finally, to accommodate the PPN formalism for symmetric teleparallel theories of gravity shown in Sect. 2.4, xPPN provides yet another pre-defined connection, which is characterized by vanishing torsion and curvature, but which is not compatible with the metric \(g_{\mu \nu }\). Its covariant derivative is entered as and denoted by the symbol in prefix notation, and a hash “#” in postfix notation. The perturbative expansion (23) of its connection coefficients is expressed in terms of a vector field \(\xi ^{\alpha }\), which is defined under the name in xPPN. Its perturbative expansion is implemented such that the only non-vanishing components are the three components (24). Also for this connection, xAct automatically defines torsion and curvature tensors, but both are set to vanish identically. The only tensorial quantity describing this connection and its relation to the Levi–Civita connection is the nonmetricity, which is given by

(36)

In xPPN, the nonmetricity is called , and its perturbative expansion is obtained from the definition above.

4.5 Energy–momentum variables

In the PPN formalism it is assumed that the source of gravity is the energy-momentum tensor \(\Theta _{\alpha \beta }\) of a perfect fluid (1), which defined by xPPN is a tensor on \(M_4\) denoted by . Note that it is defined with lower indices. In order to raise the indices, the physical metric \(g_{\alpha \beta }\) must be used explicitly; implicitly raising the indices by writing would use the background metric \(\eta _{\alpha \beta }\), and hence not give the correct result. Also note that we use the symbol \(\Theta \) instead of the more conventional T in order to avoid confusion with the torsion tensor.

For convenience, xPPN also defines the trace-reversed energy-momentum tensor

$$\begin{aligned} {\bar{\Theta }}_{\alpha \beta } = \Theta _{\alpha \beta } - \frac{1}{2}g_{\alpha \beta }g^{\gamma \delta }\Theta _{\gamma \delta }, \end{aligned}$$
(37)

denoted by , and which is likewise defined as a tensor on \(M_4\).

In order to describe the \(3+1\) split of the energy-momentum tensor and its decomposition into velocity orders, xPPN further defines the following tensors on \(S_3\) depending on , which represent the variables describing the perfect fluid:

  1. 1.

    is the rest mass density \(\rho \sim {\mathcal {O}}(2)\).

  2. 2.

    is the pressure \(p \sim {\mathcal {O}}(4)\).

  3. 3.

    is the specific internal energy \(\Pi \sim {\mathcal {O}}(2)\).

  4. 4.

    is the velocity \(v^a \sim {\mathcal {O}}(1)\).

When the energy–momentum tensor \(\Theta _{\alpha \beta }\) is expanded in velocity orders as shown in Sect. 5.4, the relations

(38)

which follow directly from the expansion (6), are applied, while all other components vanish.

4.6 Post-Newtonian potentials

The post-Newtonian potentials are a central ingredient to the PPN formalism. In xPPN they are defined as tensors on the space manifold \(S_3\) with an additional time dependence. Most of them are scalars, but there are also vector and tensor potentials, which therefore carry indices in the tangent bundle \({\mathbb {T}}S_3\). In particular, the following PPN potentials are defined:

  1. 1.

    is the post-Newtonian superpotential

    $$\begin{aligned} \chi (t, \vec {x}) = -\int \mathrm {d}^3x'\rho (t, \vec {x}')|\vec {x} - \vec {x}'|. \end{aligned}$$
    (39)
  2. 2.

    is the Newtonian potential

    $$\begin{aligned} U(t, \vec {x}) = \int \mathrm {d}^3x'\frac{\rho (t, \vec {x}')}{|\vec {x} - \vec {x}'|}. \end{aligned}$$
    (40)
  3. 3.

    is the anisotropic potential

    $$\begin{aligned} U_{ab}(t, \vec {x})= & {} \int \mathrm {d}^3x'\frac{\rho (t, \vec {x}')}{|\vec {x} - \vec {x}'|^3}(x_a - x_a')(x_b - x_b') \nonumber \\= & {} \chi _{,ab} - \frac{1}{2}\triangle \chi \delta _{ab}. \end{aligned}$$
    (41)
  4. 4.

    is the isotropic vector potential

    $$\begin{aligned} V_a(t, \vec {x}) = \int \mathrm {d}^3x'\frac{\rho (t, \vec {x}')v_a(t, \vec {x}')}{|\vec {x} - \vec {x}'|}. \end{aligned}$$
    (42)
  5. 5.

    is the anisotropic vector potential

    $$\begin{aligned} W_a(t, \vec {x}) = \int \mathrm {d}^3x'\frac{\rho (t, \vec {x}')v_b(t, \vec {x}')(x_a - x_a')(x_b - x_b')}{|\vec {x} - \vec {x}'|^3}.\nonumber \\ \end{aligned}$$
    (43)
  6. 6.

    is the kinetic energy potential

    $$\begin{aligned} \Phi _1(t, \vec {x}) = \int \mathrm {d}^3x'\frac{\rho (t, \vec {x}')v(t, \vec {x}')^2}{|\vec {x} - \vec {x}'|}. \end{aligned}$$
    (44)
  7. 7.

    is the gravitational self-energy potential

    $$\begin{aligned} \Phi _2(t, \vec {x}) = \int \mathrm {d}^3x'\frac{\rho (t, \vec {x}')U(t, \vec {x}')}{|\vec {x} - \vec {x}'|}. \end{aligned}$$
    (45)
  8. 8.

    is the internal energy potential

    $$\begin{aligned} \Phi _3(t, \vec {x}) = \int \mathrm {d}^3x'\frac{\rho (t, \vec {x}')\Pi (t, \vec {x}')}{|\vec {x} - \vec {x}'|}. \end{aligned}$$
    (46)
  9. 9.

    is the pressure potential

    $$\begin{aligned} \Phi _4(t, \vec {x}) = \int \mathrm {d}^3x'\frac{p(t, \vec {x}')}{|\vec {x} - \vec {x}'|}. \end{aligned}$$
    (47)
  10. 10.

    is the anisotropic kinetic potential

    $$\begin{aligned} {\mathcal {A}}(t, \vec {x}) = \int \mathrm {d}^3x'\frac{\rho (t, \vec {x}')\left[ v_a(t, \vec {x}')(x_a - x_a')\right] ^2}{|\vec {x} - \vec {x}'|^3}. \end{aligned}$$
    (48)
  11. 11.

    is the potential related to change in velocity

    $$\begin{aligned} {\mathcal {B}}(t, \vec {x}) = \int \mathrm {d}^3x'\frac{\rho (t, \vec {x}')}{|\vec {x} - \vec {x}'|}(x_a - x_a')\frac{\mathrm {d}v_a(t, \vec {x}')}{\mathrm {d}t}. \end{aligned}$$
    (49)
  12. 12.

    is the Whitehead potential

    $$\begin{aligned} \Phi _W(t, \vec {x})= & {} \int \mathrm {d}^3x'\int \mathrm {d}^3x''\rho (t, \vec {x}')\rho (t, \vec {x}'')\nonumber \\&\times \frac{x_a - x_a'}{|\vec {x} - \vec {x}'|^3}\left( \frac{x_a' - x_a''}{|\vec {x} - \vec {x}''|} - \frac{x_a - x_a''}{|\vec {x}' - \vec {x}''|}\right) .\nonumber \\ \end{aligned}$$
    (50)

Note that these integrals are not implemented directly in xPPN, which makes no explicit use of the coordinates apart from the assumption that partial derivatives of the tensors defining the background geometry vanish. However, they enter into the formalism indirectly, since they define the relations between the potentials and the source terms which are explained in detail in Sect. 5.6.

4.7 Post-Newtonian parameters

The PPN parameters are represented in xPPN by objects which are declared as constants within xTensor, so that any derivatives acting on them vanish. A full list is given in Table 2. Note that assuming the PPN parameters to be constant, which is one of the standard assumptions of the PPN formalism, means that it cannot be directly applied to, e.g., theories with massive fields mediating the gravitational interaction, since in such theories the values of the PPN parameters depend on the distance between the source and the test mass; also time variation of PPN parameters depending on a cosmological background is not considered. The former may be included in a future version of xPPN by introducing additional Yukawa-type potentials, which depend on a mass determining the interaction scale [27, 28]. The latter might be implemented by allowing for PPN parameters which depend on instead of being declared constant [29].

Table 2 Constants representing the PPN parameters in xPPN

5 Utility functions

We now present a number of utility functions defined by xPPN, which can be used to manipulate terms which typically appear in the post-Newtonian expansion, perform necessary computational steps and solve the gravitational field equations in terms of the post-Newtonian potentials and parameters listed in the previous sections. Which of these functions need to be used highly depends on the gravity theory under consideration, and we show this for a few of them in an explicit example in Sect. 6; here we give an overview of the functions provided and how they are applied. In Sect. 5.1 we show how to refer to specific parts of tensors in their space-time decomposition and perturbative expansion. The definition and application of substitution rules for such terms is explained in Sect. 5.2. The decomposition of general tensorial expressions into space and time components is shown in Sect. 5.3, and further into velocity orders in Sect. 5.4. The transformation of terms using the Euler equations derived from energy-momentum conservation is displayed in Sect. 5.5, and applied to post-Newtonian potentials in Sect. 5.6. Finally, utility functions for sorting derivatives prior to applying these rules are shown in Sect. 5.7.

5.1 Selecting space-time components and velocity orders of tensors

As explained in Sect. 3.1, xPPN defines for each tensor declared on the spacetime manifold \(M_4\) a number of tensors on the space manifold \(S_3\), which represent the \(3+1\) decomposition of the initial tensor and its velocity orders. In order to access these components, xPPN defines the utility function to easily obtain them from a tensor head, a sequence of indices and optionally a velocity order. This function can be used in two ways, taking the following arguments:

  1. 1.

    , where h is a tensor head and i is a sequence of indices, such that each index either belongs to \(S_3\) or is (possible with a minus sign);

  2. 2.

    , where n is a non-negative integer and h and i are as above.

The application of this function is illustrated by the following example of a vector \(A^{\alpha }\):

figure cr

Note that the indices do not have to be in the natural position in which they have been for the tensor head h. The function yields the same result as if the indices had been specified in their natural position, and then raised or lowed with the background metric on \(S_3\):

figure cu

Tensor symmetries are taken into account, and indices are sorted into canonical order if possible:

figure cv

5.2 Definition and application of replacement rules

For pre-defined tensors on the spacetime manifold \(M_4\), such as the metric or the energy-momentum tensor, xPPN defines a number of substitution rules for the terms in their post-Newtonian expansion. In order to apply these rules to any given tensorial expression, xPPN provides the function , which can be invoked in two different ways:

  1. 1.

    recursively applies the defined PPN rules to all tensors which appear in the expression X and its subexpressions.

  2. 2.

    applies the defined PPN rules only to those tensors within X with head h.

For example, the zeroth order of the physical metric is given by the Minkowski background metric:

figure cz

By default, xPPNdoes not associate any rules to the terms in the post-Newtonian expansion of user-defined tensors. Therefore, xPPN provides a number of functions to define and undefine such rules. This can be done with the following functions:

  1. 1.

    defines or replaces a rule, such that substitutes the n’th order term by X, where X can be any tensorial expression which has the same free indices as defined by i.

  2. 2.

    removes the PPN rule associated with the term in the post-Newtonian expansion.

  3. 3.

    removes any PPN rules associated to the tensor head h.

Their application can be illustrated as follows.

figure dg

5.3 \(3+1\) space-time split of tensorial expressions

xPPN defines two functions handling the \(3+1\) decomposition of arbitrary tensorial expressions on spacetime into their space and time components, as explained in Sect. 3.1: and . While the former calculates one specific component of the \(3+1\) decomposition, the latter yields an array with all components. In both functions the decomposition is applied to both free and dummy indices.

The function takes two arguments: a tensor on \(M_4\) (possibly containing free indices) and a list of replacement rules, which assigns to each free index in a bundle over \(M_4\) either an index over the corresponding bundle over \(S_3\) or the label index (possibly dressed with a minus sign to indicate a lower index). For example, for an expression of the form \(A^{\alpha }{}_{\beta }\) with free indices , , the second argument may be any of the following:

  1. 1.
  2. 2.
  3. 3.
  4. 4.

Of course, other names than ab may be used for the indices on \(S_3\), but their position must remain the same; their role is to specify how the free indices in the resulting expression will be named. The function then calculates the component of the expression where each free index on \(M_4\) is replaced by the specified indices of the \(3+1\) decomposition. For example, for a tensor \(A^{\alpha }{}_{\beta }\) defined by

figure ds

one may use

figure dt

to obtain the component \(A^a{}_0\). In contrast to the function , which yields the \(3+1\) decomposed component of a single tensor only, any tensorial expression may be decomposed by instead of a single tensor. For example, to decompose the expression \(A^{\alpha }{}_{\gamma }A^{\gamma }{}_{\beta }\) one may use

figure dw

Observe that also the dummy index \(\gamma \) has been split into a sum over dummy indices in the \(3+1\) decomposition.

The function is similar, but in its second argument only indices of \(S_3\) (and hence no ) are allowed as the right hand sides of the rules. The function then returns an array in which the free indices of the original expression are replaced either by the specified spatial indices or the time index 0, as shown in the following example:

figure dz

The order of the rules in the replacement list corresponds to the order of the dimensions of the resulting array. In the example above, the first dimension corresponds to \(\alpha \), while the second dimension corresponds to \(\beta \). Hence,

figure ea

selects the component where \(\alpha \) is replaced by 0 (the first element of (0, a)), while \(\beta \) is replaced by b (the second element of (0, b)). Similarly,

figure eb

yields the transposed array.

Finally, we remark that both and also operate on partial derivatives with respect to spacetime coordinates. These are converted as follows:

figure ef

Observe that the time derivative is not represented as a partial derivative, but as a parameter derivative with respect to the time parameter . Finally, we remark that the automatic split is implemented only for partial derivatives ; any other derivatives most be converted with or , as appropriate.

5.4 Decomposition into velocity orders

As explained in Sect. 3.2, an important part of the PPN formalism is the series expansion of expressions in velocity orders. In order to select a single term from an expression X, xPPN provides the function . The term is then expressed as . Here n must be a non-negative integer, while X can be any tensorial expression on \(S_3\), which may in addition depend on . It makes use of a number of standard relations for the velocity order in the PPN formalism: orders are distributed over products, and time derivatives are weighted with an additional velocity order. This is illustrated in the following example:

figure en

The function supports the boolean option . If it is set to (the default case), any rules assigned to objects are applied immediately as soon as they are encountered. If it is set to , no PPN rules are applied. For example, for the energy-momentum tensor this yields the following results:

figure et

Observe that in the first case the rule is applied, but not in the second case. For large expressions the default setting is significantly faster, since the PPN rules imply the vanishing of many terms in the post-Newtonian expansion, which are thus immediately discarded when the rules are applied.

5.5 Euler equations

An important assumption of the PPN formalism is that the energy-momentum tensor \(\Theta _{\alpha \beta }\) introduced in Sect. 4.5 satisfies the covariant conservation equation . Expanding this equation into velocity orders and performing a \(3+1\) split into space and time components, one obtains the Euler equations, which govern the dynamics of the fluid. These equations are implemented in xPPN in three different functions, which perform the following substitutions on all matching subexpressions of their arguments:

  1. 1.

    applies the replacement

    $$\begin{aligned} \rho _{,0} \rightarrow -(\rho v_a)_{,a}. \end{aligned}$$
    (51)
  2. 2.

    applies the replacement

    (52)
  3. 3.

    applies the replacement

    (53)

The functions can be successively applied in order to transform terms involving higher order time derivatives.

5.6 Transformation of PPN potentials

The post-Newtonian potentials defined in Sect. 4.6 and their derivatives satisfy a number of relations among each other and with the energy-momentum variables defined in Sect. 4.5, some of which follow directly from the definition of the potentials, while others can be derived from the Euler equations discussed in the previous section. xPPN defines a number of utility functions in order to implement these relations and use them to turn PPN potentials and their derivatives into either other PPN potentials or terms constructed from the energy-momentum tensor. The most important of these is , which performs the following replacements on all subexpressions of X:

$$\begin{aligned}&\triangle \triangle \chi \rightarrow 8\pi \rho , \quad \triangle \triangle {\mathcal {A}} \rightarrow 8\pi (\rho v_av_b)_{,ab} - 4\pi \triangle (\rho |v|^2), \nonumber \\&\quad \triangle \triangle {\mathcal {B}} \rightarrow 8\pi [\triangle p - (U_{,a}\rho )_{,a}],\nonumber \\&\quad \triangle \Phi _1 \rightarrow -4\pi \rho |v|^2, \quad \triangle \Phi _2 \rightarrow -4\pi \rho U, \nonumber \\&\quad \triangle \Phi _3 \rightarrow -4\pi \rho \Pi , \triangle \Phi _4 \rightarrow -4\pi p, \nonumber \\&\quad \triangle U \rightarrow -4\pi \rho , \quad \triangle V_a \rightarrow -4\pi \rho v_a, \nonumber \\&\quad \triangle \Phi _W \rightarrow 4\pi \rho U - 4U_{,a}U_{,a} + 2U_{,ab}\chi _{,ab}. \end{aligned}$$
(54)

The remaining functions act on specific PPN potentials or their derivatives. Their effects are listed in Table 3.

Table 3 Functions to transform specific PPN potentials

5.7 Sorting of derivatives

In xAct, derivatives are, in general, not sorted automatically. This poses two difficulties, which may lead to problems in simplifications:

  1. 1.

    Mathematica does not recognize terms which are mathematically equal if they contain derivatives in different order. For example, expressions of the form \(\partial _{\alpha }\partial _{\beta }X\) and \(\partial _{\beta }\partial _{\alpha }X\) are equal, since partial derivatives commute, but since they are represented differently, Mathematica does not recognize this.

  2. 2.

    In order to apply the transformations listed in Sect. 5.6, pattern matching is applied to find divergences, time derivatives and Laplace operators acting on tensors. However, due to the way how derivatives are represented in xTensor, Mathematica recognizes such terms only if they are not interspersed with other derivatives. For example, \(\partial _{\alpha }A^{\alpha }\) is found in \(\partial _{\beta }\partial _{\alpha }A^{\alpha }\), but not in \(\partial _{\alpha }\partial _{\beta }A^{\alpha }\), even though these terms are mathematically equal.

The first of these problems can be solved by defining a canonical order for derivatives and keeping them always sorted in canonical order. Such a canonical ordering is implemented as part of the xTensor function , so that the following terms are recognized by Mathematica as equal and canceled:

figure fp

However, this does not solve the second problem, since a different order of derivatives is required, depending on the type of pattern to be matched; for example, matching a time derivative would require the order \(\partial _{\alpha }\partial _0A^{\alpha }\), while matching a divergence would require the order \(\partial _0\partial _{\alpha }A^{\alpha }\). Hence, keeping all indices in a fixed, canonical order would not allow for such patterns to be found. Hence, xPPN implements a different method by defining different functions, which allow sorting derivatives on demand in any of the necessary orders. The following functions are defined:

  1. 1.

    sorts all derivatives in canonical order by applying the following rules:

    1. (a)

      Spatial derivatives are applied before time derivatives, i.e., moved to the right.

    2. (b)

      Spatial derivatives are sorted in lexicographic order, i.e., indices which come earlier in lexicographic order, are applied first.

    3. (c)

      Derivatives with upper indices are applied before derivatives with otherwise identical lower indices.

  2. 2.

    sorts derivatives acting on tensors with head h such that time derivatives are applied first, i.e., moved to the right.

  3. 3.

    sorts derivatives acting on tensors with head h such that divergences may be matched, i.e., such that derivatives are applied first, whose index is contracted with a corresponding index of the tensor expression.

  4. 4.

    sorts derivatives acting on tensors with head h such that Laplace operators are formed from spatial derivatives, if possible, and those are applied first.

The effect of these functions on an expression with multiple derivatives acting on a tensor is shown by the following code:

figure fu

The implementation of these functions is inspired by the field theory package xTras [30], which defines a similar set of functions, which take into account also non-commuting derivatives by adding suitable correction terms. Also note that the replacement functions listed in Sect. 5.6 make use of these sorting functions automatically in order to establish the necessary order of indices before pattern matching is performed.

6 Example: scalar-tensor gravity

In order to demonstrate the use of the xPPN package, we provide a practical example in form of a complete, commented session, which calculates the PPN parameters of a scalar-tensor class of gravity theories, thereby showing the use of some of the functions detailed in the previous sections. The precise steps which are needed to determine the PPN parameters highly depend on the specific theory under consideration, and must be chosen accordingly. We briefly present the action and field equations of this class in Sect. 6.1. A few preliminary commands, for loading the package and setup, are given in Sect. 6.2. In section 6.3, the necessary tensors and constants for the calculation are defined. These are used in the definition of the field equations in Sect. 6.4. Their post-Newtonian expansion is derived in Sect. 6.5. In Sect. 6.6, the perturbative solution of the resulting equations is obtained. Finally, in Sect. 6.7, the PPN metric and parameters are calculated.

6.1 Action and field equations

In the following we discuss a class of scalar–tensor theories of gravity, whose action is given by [31]

$$\begin{aligned}&S = \frac{1}{2\kappa ^2}\int _{M_4}\mathrm {d}^4x\sqrt{-g}\left( \psi R - \frac{\omega (\psi )}{\psi }\partial _{\rho }\psi \partial ^{\rho }\psi \right) \nonumber \\&\quad + S_m[g_{\mu \nu }, \chi ] \end{aligned}$$
(55)

in Brans–Dicke like parametrization in the Jordan conformal frame. Here \(S_m\) denotes the matter part of the action, where we collectively denoted by \(\chi \) the set of matter fields. The gravitational part contains a free function \(\omega \) of the scalar field \(\psi \). Each theory of this class is defined by a particular choice of this free function \(\omega \). By variation of this action with respect to the metric and the scalar field as well as subtraction of a suitable multiple of the trace of the metric field equation one obtains the field equations

(56a)
(56b)

where is the d’Alembert operator on the physical spacetime \(M_4\).

6.2 Package loading and preliminaries

In order to load and use xPPN, as the first prerequisite a working installation of xAct [10] is needed. The files provided by xAct then reside in a directory named xAct in the Mathematica package search path. The xPPN package comes as a directory named xPPN, which must be placed inside the xAct directory. If both packages are installed correctly, xPPN can be loaded with the command

figure fv

This should load xPPN and its dependencies from the xAct package suite. Note that loading may take some time, since xPPN calculates the perturbative expansion of the pre-defined tensor fields upon package loading. To suppress $ symbols in the index notation, it is useful to set the following xAct printing option:

figure fw

Finally, we define two utility functions which help to create rules from equations; this functionality, which is simply a shorthand notation for the versatile function from the xTensor package, are not specific to xPPN, and are defined here only to shorten the notation in the later course of this example:

figure fy

6.3 Object definitions

We continue by defining the xAct objects which we will be using for the calculation and their notation. We start with the scalar field \(\psi \), which is a tensor without any indices.

figure fz

We then continue with the cosmological background value \(\Psi \) of the scalar field. This is a constant.

figure ga

Another constant which we will need is the gravitational constant \(\kappa \).

figure gb

The action (55) also depends on a free function \(\omega \). This is defined as a scalar function.

figure gc

We then come to the field equations (56), which we write in the form \({\mathcal {E}}_{\alpha \beta } = 0\) and \({\mathcal {E}} = 0\), by moving the energy-momentum tensor to the left hand side. The two tensors representing these field equations are then defined as follows.

figure gd

Finally, in this example we will solve the field equations by making an ansatz for the solution in terms of PPN potentials and unknown, constant coefficients, which we will then determine. For this purpose, we define a function which creates such constant coefficients on demand as follows.

figure ge

6.4 Field equations

In the next step, we enter the field equations (56). As mentioned before, we must pay attention to explicitly use the inverse metric \(g^{\alpha \beta }\) for terms such as the kinetic term \(\partial _{\rho }\psi \partial ^{\rho }\psi \) of the scalar field or the trace \(\Theta ^{\rho }{}_{\rho }\) of the energy-momentum tensor. Taking these into account, we can enter the metric field equation (56a) as follows.

figure gf

Similarly, we continue with the scalar field equation (56b):

figure gg

6.5 Post-Newtonian expansion

The most crucial and resource intensive part of the calculation is the derivation of the post-Newtonian expansion of the field equations. For this purpose, we must first define the expansion of the scalar field. Here we impose the relations

(57)

In xPPN, they are implemented as follows:

figure gh

With these definitions in place, we can continue with the calculation. We will do so in two steps. First, we perform a \(3+1\) decomposition of the field equations. For this purpose, we convert the Levi–Civita covariant derivatives to partial derivatives and Christoffel symbols. Also we perform a number of simplifications. Again we start with the metric field equations.

figure gi

We proceed similarly with the scalar field equations:

figure gj

In the second step, we further decompose the equations obtained in the previous step into velocity orders \({\mathcal {O}}(0), \ldots , {\mathcal {O}}(4)\). Also here we perform a few tensor simplifications alongside the calculation, starting again with the metric equation.

figure gk

Finally, we apply the same step also to the scalar field equation.

figure gl

6.6 Perturbative solution

We can now use the post-Newtonian expansion of the field equations and solve them order by order. For this purpose we make use of prior knowledge that the field equations of the theory at hand can be solved by a particular ansatz for the metric and scalar field, so that at every step of the calculation we are left with solving for a number of constant coefficients; this ansatz and solution method must be adapted if the package is applied to other theories. We show the zeroth velocity order (the background vacuum solution) in Sect. 6.6.1, the second velocity order in Sect. 6.6.2, the third velocity order in Sect. 6.6.3 and the fourth velocity order in Sect. 6.6.4.

6.6.1 Zeroth velocity order

First, we verify that the background vacuum equations are solved identically by the background geometry. This can be checked as follows.

figure gm

6.6.2 Second velocity order

We then continue with the second velocity order. First, we gather the equations to be solved:

figure gn

These equations take the form

(58)

The easiest way to solve these equations is using an ansatz for the metric and scalar field perturbations in terms of the post-Newtonian potentials, with arbitrary, constant coefficients. This ansatz can be defined as follows:

figure go

To obtain the equations to be solved, one inserts this ansatz into the field equations. Since the field equations contain derivatives of the metric and scalar field perturbations, this will yield derivatives of the post-Newtonian potentials U and \(U_{ab}\). These must be matched with the terms arising from the energy-momentum tensor \(\Theta _{\alpha \beta }\). For this purpose, one applies the functions listed in Sect. 5.6. For the potentials at hand it is most convenient to first convert them to derivatives of the superpotential \(\chi \), before transforming them to terms involving the matter density \(\rho \).

figure gp

Inspecting the obtained equations shows that they are given by

(59)

These equations are solved if and only if the coefficients of each of the terms \(\rho \), \(\rho \delta _{ab}\) and \(\triangle \chi _{,ab}\) vanishes individually. This yields four equations for the four coefficients \(a_1, \ldots , a_4\). However, one finds that these are not linearly independent, due to the gauge freedom arising from the diffeomorphism invariance of the theory. Hence, they must be supplemented with an additional, gauge fixing equation. The common choice in the PPN formalism is to eliminate the term \(U_{ab}\) from the component , thus setting \(a_3 = 0\). We can thus determine the component equations:

figure gq

We can then solve the equations:

figure gr

This yields the solution

$$\begin{aligned} a_1= & {} \kappa ^2\frac{\omega (\Psi ) + 2}{2\pi \Psi (2\omega (\Psi ) + 3)}, \nonumber \\ a_2= & {} \kappa ^2\frac{\omega (\Psi ) + 1}{2\pi \Psi (2\omega (\Psi ) + 3)}, \nonumber \\ a_3= & {} 0, \quad a_4 = \frac{\kappa ^2}{4\pi (2\omega (\Psi ) + 3)}. \end{aligned}$$
(60)

We may check that this indeed solves the equations:

figure gs

Together with the ansatz we defined, this solution now yields the solution for the perturbations :

figure gt

Finally, we also check that this result solves the second-order field equations:

figure gu

6.6.3 Third velocity order

We then come to the third velocity order. Also here we proceed in full analogy to the second velocity order shown above. First, we isolate the field equation which we will solve:

figure gv

This equation takes the form

(61)

We then choose an ansatz for the third-order metric perturbation . This now involves the post-Newtonian vector potentials \(V_a\) and \(W_a\) with constant coefficients:

figure gw

To obtain the equation to be solved, we insert this ansatz into the field equation, together with the second-order solution obtained in the previous step. Also here we obtain derivatives acting on the post-Newtonian potentials, which we can simplify by using their interrelations, and finally convert them to terms matching the energy–momentum source. Here it is most useful to first eliminate the potential \(W_a\). The resulting terms can then be converted to source terms and terms involving derivatives acting on U only:

figure gx

Inspecting this equation shows the following form:

(62)

This equation only determines the sum \(a_5 + a_6\) of the coefficients we introduced. Here we leave their difference as an undetermined parameter, which we will solve for when we come to the fourth velocity order, which will fix the post-Newtonian gauge. We thus determine the solution:

figure gy

The solution is given by

$$\begin{aligned} a_5 = -\frac{a_0}{2} - \frac{\kappa ^2}{4\pi \Psi }, \quad a_6 = \frac{a_0}{2} - \frac{\kappa ^2}{4\pi \Psi }. \end{aligned}$$
(63)

We check that this solves the equations:

figure gz

Together with the ansatz for the third-order metric component we obtain the solution:

figure ha

Finally, we also check that this solves the third-order field equation we started with:

figure hb

6.6.4 Fourth velocity order

Finally, we come to the fourth velocity order, which is the most involved. For the theory under consideration, it is sufficient to solve the field equation , as it determines the necessary component . We hence isolate this equation:

figure hc

We find that it takes the following form:

(64)

As we shall see below, this equation can be solved by the following ansatz:

figure hd

We then insert this ansatz into the fourth-order field equation, alongside the previously determined solutions at lower velocity order. In order to convert the post-Newtonian potentials to a unified form, from which we can read off the independent equations for the constant coefficients in the ansatz, it is sufficient to replace the divergence terms \(V_{a,a}\) and \(W_{a,a}\) by time derivatives of U, before replacing all potentials by source terms. This is done as follows:

figure he

The resulting equation , which we do not display here for brevity, involves the six independent terms p, \(\rho \Pi \), \(\rho U\), \(U_{,00}\), \(\rho |v|^2\), \(U_{,a}U_{,a}\), whose constant coefficients must vanish. We thus isolate these constant coefficients:

figure hf

For consistency, it is useful to check the completeness of this decomposition:

figure hg

We have thus obtained six equations for the six remaining unknowns \(a_0, a_6, \ldots , a_{11}\). It turns out that these equations are linearly independent, so that we can solve for all missing constants:

figure hh

This yields the solution

$$\begin{aligned} a_0= & {} \frac{\kappa ^2}{4\pi \Psi }\frac{3\omega (\Psi ) + 4}{2\omega (\Psi ) + 3}, \quad a_9 = \frac{\kappa ^2}{2\pi \Psi }\frac{\omega (\Psi ) + 2}{2\omega (\Psi ) + 3}, \nonumber \\ a_8= & {} \frac{\kappa ^4}{16\pi ^2\Psi ^2}\frac{12 + 38\omega (\Psi ) + 32\omega ^2(\Psi ) + 8\omega ^3(\Psi ) - \Psi \omega '(\Psi )}{(2\omega (\Psi ) + 3)^3},\nonumber \\ a_7= & {} \frac{\kappa ^2}{2\pi \Psi }, \quad a_{10} = \frac{3\kappa ^2}{2\pi \Psi }\frac{\omega (\Psi ) + 1}{2\omega (\Psi ) + 3}, \nonumber \\ a_{11}= & {} -\frac{\kappa ^4}{32\pi ^2\Psi ^2}\frac{48 + 80\omega (\Psi ) + 44\omega ^2(\Psi ) + 8\omega ^3(\Psi ) + \Psi \omega '(\Psi )}{(2\omega (\Psi ) + 3)^3}.\nonumber \\ \end{aligned}$$
(65)

We check that it is indeed a solution:

figure hi

Since we have now determined \(a_0\), we can complete the partial third-order solution we obtained earlier:

figure hj

Using the remaining constants \(a_6, \ldots , a_{11}\), we obtain the solution for :

figure hk

Again, we check for consistency that this solves the fourth-order field equation:

figure hl

6.7 PPN metric and parameters

Using the solution we determined so far, we can now calculate the post-Newtonian metric and parameters. For this purpose, we first isolate the metric components to be determined.

figure hm

We then insert the solution we have found.

figure hn

We will compare this to the standard PPN metric.

figure ho

This can be done in two steps. First, we choose the normalization constant \(\kappa \), which corresponds to the effective Newtonian constant, such that . We define the following equation:

figure hp

This takes the form

$$\begin{aligned} 2U = \frac{\kappa ^2}{2\pi \Psi }\frac{\omega (\Psi ) + 2}{2\omega (\Psi ) + 3}U. \end{aligned}$$
(66)

To solve this equation, we take its positive root:

figure hq

This yields the solution

$$\begin{aligned} \kappa = \sqrt{4\pi \Psi \frac{2\omega (\Psi ) + 3}{\omega (\Psi ) + 2}}. \end{aligned}$$
(67)

With this solution, we can now determine the PPN parameters. These are the equations to be solved.

figure hr

To determine the PPN parameters, we isolate the constant coefficients in front of the post-Newtonian potentials \(U\delta _{ab}, V_a, W_a, {\mathcal {A}}, U^2, \Phi _W, \Phi _1, \Phi _2, \Phi _3, \Phi _4\).

figure hs

Finally, we can solve for the full set of PPN parameters.

figure ht

This finally yields the solution

$$\begin{aligned} \gamma= & {} \frac{\omega (\Psi ) + 1}{\omega (\Psi ) + 2}, \quad \beta = 1 + \frac{\Psi \omega '(\Psi )}{4(2\omega (\Psi ) + 3)(\omega (\Psi ) + 2)^2}, \quad \nonumber \\ \alpha _1= & {} \alpha _2 = \alpha _3 = \zeta _1 = \zeta _2 = \zeta _3 = \zeta _4 = \xi = 0. \end{aligned}$$
(68)

This is of course the well-known post-Newtonian limit of scalar-tensor gravity with a massless scalar field [31].

7 Summary and outlook

We have presented the Mathematica package xPPN, which is based on the tensor algebra suite xAct and which implements the PPN formalism in its formulation presented in [5], with extensions to adapt it to the geometries employed in the three formulations of general relativity [26] and modifications thereof. Besides discussing its underlying mathematical concepts and giving a detailed account on its usage, we provided an example application to a simple scalar-tensor theory of gravity. We believe that this package will find wide application to assess the viability of gravity theories by comparing their post-Newtonian limit to observations in the solar system.

Despite the generality of xPPN, being applicable to gravity theories based on different geometric foundations, various extensions and modifications are possible and may be implemented in future versions. For example, one may consider the following types of extensions:

  1. 1.

    Alternative formulations of the PPN formalism: A newer approach towards the PPN formalism employs a different density variable [7, Sec. 4], which has the advantage that it simplifies the gauge transformation of the PPN potentials compared to the original formulation. Another approach to simplify the issue of gauge transformations is to resort to a formulation which makes use of gauge-invariant perturbation theory, thereby resolving the necessity of gauge considerations and simplifying the application of the PPN procedure [32]. Such modifications may be included by changing the expansion of the metric in terms of PPN potentials.

  2. 2.

    Additional post-Newtonian potentials and parameters: Various theories of gravity exhibit a post-Newtonian limit in which the metric perturbation cannot be expressed only in terms of the post-Newtonian potentials used in the standard formalisms, and so more general potentials and corresponding parameters have been introduced. The presence of massive fields leads to the appearance of Yukawa-type potentials [27, 28], while higher-order derivatives can be accommodated by further integrals in the post-Newtonian potentials [33, 34]. Another class of terms arises from theories which include parity-violating contributions [35,36,37], or by violation of diffeomorphism invariance [38,39,40]. Further, one may introduce also fourth-order tensor potentials to expand the term , which is neglected in the standard PPN formalism, but may be used to describe higher-order corrections to light propagation [13, 14]. Such additional potentials may easily be included by defining the corresponding tensor fields and the equations which relate them to the corresponding source terms, in full analogy to the standard PPN potentials.

  3. 3.

    Higher than fourth order in the post-Newtonian expansion: While in the standard PPN formalism implemented in the present version of xPPN the metric (and possible other fields present in the theory) are expanded only up to the fourth velocity order, one may also consider higher order terms, and address problems such as the post-Newtonian dynamics of systems involved in the generation of gravitational waves [7, 41]. Care must be taken since the Euler equations governing the dynamics of the source matter attain dissipative terms at higher orders, and also the gravitational field exhibits dissipative behavior due to the loss of energy by emitted gravitational waves. Further, such as extension requires the definition of higher-order post-Newtonian potentials, along with corresponding post-Newtonian parameters, whose relation to observations and associated observables must be defined, so that such an extension would be a major task.

  4. 4.

    Generalized post-Newtonian expansion: The standard PPN formalism assumes the validity of a post-Newtonian expansion around a flat Minkowski background. This assumption may be generalized, by allowing for a time-dependent Friedmann–Lemaître–Robertson–Walker background [29], or by including non-perturbative effects arising from the Vainshtein screening mechanism [42].

  5. 5.

    More general geometric frameworks: Another assumption of the standard PPN formalism states that the motion of test masses is governed by a single metric, and so the observable effects on test masses are fully covered by a post-Newtonian expansion of this single metric. This assumption may be relaxed if there are several dynamical metrics present in the considered gravity theory, which lead to more complex test matter dynamics and generalized sources of gravity [43,44,45]. Also more general connections may be considered, such as a general teleparallel connection [46], as well as Riemann-Cartan [16, 33, 34, 47, 48] or metric-affine geometry [49]. In theories of this class additional matter currents may appear from a coupling of spin to gravity, which gives rise to additional source terms, which must be accommodated for by further PPN potentials, together with their respective equations of motion and conservation laws generalizing the Euler equations [50,51,52,53,54,55,56,57].