Function Repository Resource:

# EinsteinTensor

Represent the Einstein curvature tensor (field) for a Riemannian or pseudo-Riemannian manifold

Contributed by: Jonathan Gorard
 ResourceFunction["EinsteinTensor"][ResourceFunction["MetricTensor"][…],i1,i2] represents the Einstein curvature tensor associated to the given metric tensor, with indices i1 and i2 (with True representing a covariant index and False representing a contravariant one). ResourceFunction["EinsteinTensor"][ResourceFunction["EinsteinTensor"][…],coords] transforms a specified ResourceFunction["EinsteinTensor"] into the new coordinate system coords. ResourceFunction["EinsteinTensor"][ResourceFunction["EinsteinTensor"][…],i1,i2] transforms a specified ResourceFunction["EinsteinTensor"] into one with new indices i1 and i2 (with True representing a covariant index and False representing a contravariant one), raising and lowering existing indices as necessary. ResourceFunction["EinsteinTensor"][ResourceFunction["EinsteinTensor"][…],coords,i1,i2] transforms a specified ResourceFunction["EinsteinTensor"] into one with new coordinate system coords and new indices i1 and i2 (with True representing a covariant index and False representing a contravariant one), raising and lowering existing indices as necessary.

## Details

Formally, the Einstein curvature tensor is a (symmetric) bilinear form defined on the tangent space at a specified point of a manifold, and the Einstein curvature tensor field associates an Einstein curvature tensor to every such point in that manifold. From Lovelock's theorem, we know that the Einstein curvature tensor is the unique tensor-valued function of the metric tensor and its first and second (covariant) derivatives that also has zero (covariant) divergence, at least for the case of 4-dimensional Riemannian manifolds.
Strictly speaking, ResourceFunction["EinsteinTensor"] represents an Einstein curvature tensor field rather than a single Einstein curvature tensor (this terminological ambiguity is commonplace in both geometry and physics, and ResourceFunction["EinsteinTensor"] generally does not make any such distinction).
By default, ResourceFunction["EinsteinTensor"][ResourceFunction["MetricTensor"][],i1,i2] represents an Einstein curvature tensor by a (symmetric) matrix representation of linear combinations of second (covariant) derivatives of the metric tensor in a given coordinate basis, such that the entries of this matrix transform either covariantly or contravariantly, or some mixture of the two, with respect to transformations of the coordinates. The indices i1 and i2 can either be set to True (covariant) or False (contravariant). By default, both indices are set to True (i.e. all components of the matrix transform covariantly).
In differential geometry, the mathematical significance of the Einstein curvature tensor is that it allows one to express the (contracted) Bianchi identities as the statement that the covariant divergence of the Einstein curvature tensor vanishes. In general relativity, the physical significance of the Einstein curvature tensor is that, up to a cosmological constant term, the Einstein field equations either set it identically equal to zero (in the vacuum case) or equal to the stress-energy tensor, up to a multiplicative constant (in the non-vacuum case); in the latter case, the vanishing of the covariant divergence of the Einstein curvature tensor guarantees consistency with the conservation of energy and momentum.
ResourceFunction["EinsteinTensor"] derives the Einstein curvature tensor from the Ricci curvature tensor by subtracting its trace (the Ricci curvature scalar) multiplied by the metric tensor.
ResourceFunction["EinsteinTensor"] does not assume any particular number of dimensions, nor any particular metric convention, for the underlying manifold (although some properties, such as "LorentzianConditions", implicitly assume a (-,+,+,+,) signature). ResourceFunction["EinsteinTensor"] also does not require the metric to be strictly symmetric (i.e. spin and torsion connections are also supported), although the computation of the Einstein curvature tensor implicitly assumes the torsion-free Levi-Civita connection by default.
ResourceFunction["EinsteinTensor"] implicitly keeps track of all known algebraic equivalences between tensor expressions, and can apply them for simplification purposes where necessary. Requesting any property with "Reduced" in its name has the effect of applying all known tensor equivalences and simplifying (note that this can have the effect of increasing computation time significantly).
By default, ResourceFunction["EinsteinTensor"] evaluates all partial derivatives of the metric tensor automatically. In certain cases, however, these partial derivatives may be difficult or even impossible to compute, in which case the evaluation may not terminate in a reasonable time. Requesting any property with "Symbolic" in its name has the effect of leaving all partial derivatives unevaluated instead (note that this can have the effect of increasing expression length significantly).
If the function succeeds in constructing the specified Einstein curvature tensor, it will return an ResourceFunction["EinsteinTensor"] expression.
Calling ResourceFunction["EinsteinTensor"][][i,j] returns the entry in the i-th column and the j-th row of the matrix representation of the Einstein curvature tensor; similarly, ResourceFunction["EinsteinTensor"][][i,All] and ResourceFunction["EinsteinTensor"][All,j] returns the complete i-th row and the complete j-th column of the matrix representation, respectively.
Calling ResourceFunction["EinsteinTensor"][ResourceFunction["EinsteinTensor"][],coords] has the effect of transforming the metric tensor (and hence the Einstein curvature tensor) to the new coordinate system coords. Calling ResourceFunction["EinsteinTensor"][ResourceFunction["EinsteinTensor"][],i1,i2] has the effect of raising and lowering appropriate indices of the Einstein curvature tensor to match i1 and i2 (with True representing lowered/covariant and False representing raised/contravariant). Calling ResourceFunction["EinsteinTensor"][ResourceFunction["EinsteinTensor"][],coords,i1,i2] has the effect of performing both transformations simultaneously.
By default, ResourceFunction["EinsteinTensor"] keeps track of the positions of all indices and performs all raising and lowering operations automatically, as required for a given computation.
Based on the eigenvalues of the matrix representation of the underlying metric tensor in covariant form, the underlying manifold will be classified by ResourceFunction["EinsteinTensor"] as either Riemannian (all eigenvalues positive or all eigenvalues negative), pseudo-Riemannian (some eigenvalues positive and some eigenvalues negative), Lorentzian (all eigenvalues positive except for one negative, or all eigenvalues negative except for one positive) or Indeterminate.
The property "RiemannianConditions" returns the conditions necessary to guarantee that the eigenvalues of the matrix representation of the underlying metric tensor are strictly positive; "PseudoRiemannianConditions" returns the conditions necessary to guarantee that the eigenvalues of the matrix representation of the underlying metric tensor are all non-zero; "LorentzianConditions" returns the conditions necessary to guarantee that the eigenvalue corresponding to the {1,0,0,} eigenvector of the underlying metric tensor (if it exists) is negative, with all other eigenvalues being positive. Note that this is strictly less general than the behavior of properties such as "RiemannianQ" (described in the point above), since it assumes certain features of the metric signature.
In ResourceFunction["EinsteinTensor"], the following properties are supported:
 "MatrixRepresentation" Einstein curvature tensor represented in explicit matrix form "ReducedMatrixRepresentation" Einstein curvature tensor represented in explicit matrix form, modulo all tensor equivalences "SymbolicMatrixRepresentation" Einstein curvature tensor represented in explicit matrix form, with purely symbolic partial derivative operators "Trace" trace of the Einstein curvature tensor "ReducedTrace" trace of the Einstein curvature tensor, modulo all tensor equivalences "SymbolicTrace" trace of the Einstein curvature tensor, with purely symbolic partial derivative operators "MetricTensor" underlying metric tensor associated to the Einstein curvature tensor "Coordinates" list of coordinate symbols for the Einstein curvature tensor "CoordinateOneForms" list of differential 1-form symbols for the coordinates of the Einstein curvature tensor "Indices" list of booleans specifying whether each index of the Einstein curvature tensor is lowered/covariant (True) or raised/contravariant (False) "CovariantQ" whether the Einstein curvature tensor is covariant (i.e. both indices are lowered/covariant) "ContravariantQ" whether the Einstein curvature tensor is contravariant (i.e. both indices are raised/contravariant) "MixedQ" whether the Einstein curvature tensor is mixed (i.e. one index is lowered/covariant and one index is raised/contravariant) "Symbol" symbolic representation of the Einstein curvature tensor with appropriately raised/lowered indices "EinsteinFlatQ" whether the underlying manifold is Einstein-flat (i.e. all components of the Einstein curvature tensor vanish) "VanishingEinsteinTraceQ" whether the trace of the Einstein curvature tensor vanishes "EinsteinFlatConditions" list of conditions required to guarantee that the underlying manifold is Einstein-flat (i.e. all components of the Einstein curvature tensor vanish) "VanishingEinsteinTraceConditions" condition required to guarantee that the trace of the Einstein curvature tensor vanishes "CovariantDerivatives" association of covariant derivatives (i.e. derivatives along tangent vectors of the underlying manifold) of the Einstein curvature tensor "ReducedCovariantDerivatives" association of covariant derivatives (i.e. derivatives along tangent vectors of the underlying manifold) of the Einstein curvature tensor, modulo all tensor equivalences "SymbolicCovariantDerivatives" association of covariant derivatives (i.e. derivatives along tangent vectors of the underlying manifold) of the Einstein curvature tensor, with purely symbolic partial derivative operators "BianchiIdentities" list of (contracted) Bianchi identities asserting that the covariant divergence of the Einstein curvature tensor vanishes "SymbolicBianchiIdentities" list of (contracted) Bianchi identities asserting that the covariant divergence of the Einstein curvature tensor vanishes, with purely symbolic partial derivative operators "Dimensions" number of dimensions of the underlying manifold/spacetime described by the Einstein curvature tensor "SymmetricQ" whether the Einstein curvature tensor is symmetric (i.e. is represented by a symmetric matrix in covariant form) "DiagonalQ" whether the Einstein curvature tensor is diagonal (i.e. is represented by a diagonal matrix in covariant form) "Signature" list of +1s and -1s designating the signature of the underlying manifold described by the Einstein curvature tensor (+1 for each positive eigenvalue of the metric, -1 for each negative eigenvalue of the metric) "RiemannianQ" whether the underlying manifold described by the Einstein curvature tensor is Riemannian (i.e. all eigenvalues of the metric have the same sign) "PseudoRiemannianQ" whether the underlying manifold described by the Einstein curvature tensor is pseudo-Riemannian (i.e. all eigenvalues of the metric are non-zero, but not all have the same sign) "LorentzianQ" whether the underlying manifold described by the Einstein curvature tensor is Lorentzian (i.e. all eigenvalues of the metric have the same sign, except for one eigenvalue which has the opposite sign) "RiemannianConditions" list of conditions required to guarantee that the underlying manifold described by the Einstein curvature tensor is Riemannian (i.e. all eigenvalues of the metric are positive) "PseudoRiemannianConditions" list of conditions required to guarantee that the underlying manifold described by the Einstein curvature tensor is pseudo-Riemannian (i.e. all eigenvalues of the metric are non-zero) "LorentzianConditions" list of conditions required to guarantee that the underlying manifold described by the Einstein curvature tensor is Lorentzian (i.e. the "time" eigenvalue of the metric is negative and all other eigenvalues are positive) "CurvatureSingularities" list of possible coordinate values that cause the Einstein curvature tensor to become singular "TraceSingularities" list of possible coordinate values that cause the trace of the Einstein curvature tensor to become singular "Determinant" determinant of the Einstein curvature tensor (represented in covariant matrix form) "ReducedDeterminant" determinant of the Einstein curvature tensor (represented in covariant matrix form), modulo all tensor equivalences "SymbolicDeterminant" determinant of the Einstein curvature tensor (represented in covariant matrix form), with purely symbolic partial derivative operators "Eigenvalues" eigenvalues of the Einstein curvature tensor (represented in covariant matrix form) "ReducedEigenvalues" eigenvalues of the Einstein curvature tensor (represented in covariant matrix form), modulo all tensor equivalences "Eigenvectors" eigenvectors of the Einstein curvature tensor (represented in covariant matrix form) "ReducedEigenvectors' eigenvectors of the Einstein curvature tensor (represented in covariant matrix form), modulo all tensor equivalences "CovariantEinsteinTensor" covariant form of the Einstein curvature tensor (i.e. both indices are lowered/covariant) "ContravariantEinsteinTensor" contravariant form of the Einstein curvature tensor (i.e. both indices are raised/contravariant) "Properties" list of properties

## Examples

### Basic Examples (3)

Construct the Einstein curvature tensor for the Schwarzschild metric (e.g. for an uncharged, non-rotating black hole with symbolic mass "M") in standard spherical polar coordinates:

 In[1]:=
 Out[1]=
 In[2]:=
 Out[2]=

Show the Einstein curvature tensor for the Schwarzschild metric in explicit (covariant) matrix form:

 In[3]:=
 Out[3]=

Show the Einstein curvature tensor for the Schwarzschild metric in explicit (covariant) matrix form, with all algebraic equivalences imposed:

 In[4]:=
 Out[4]=

Deduce that the Schwarzschild metric is Einstein-flat:

 In[5]:=
 Out[5]=

Show the list of Schwarzschild coordinate symbols:

 In[6]:=
 Out[6]=

Show the list of differential 1-form symbols for each of the Schwarzschild coordinates:

 In[7]:=
 Out[7]=

Show the list of coordinate conditions that must hold for the Schwarzschild metric to be Lorentzian:

 In[8]:=
 Out[8]=

Construct the Einstein curvature tensor for the Friedmann-Lemaître-Robertson-Walker (FLRW) metric (for a homogeneous, isotropic and uniformly-expanding/contracting universe, with symbolic curvature parameter "k" and symbolic scale factor "a") in standard spherical polar coordinates:

 In[9]:=
 Out[9]=
 In[10]:=
 Out[10]=
 In[11]:=
 Out[11]=

Show the explicit matrix form, with all algebraic equivalences imposed:

 In[12]:=
 Out[12]=

Deduce that the FLRW metric is not Einstein-flat:

 In[13]:=
 Out[13]=

Show the list of conditions that must hold for the FLRW metric to be Einstein-flat:

 In[14]:=
 Out[14]=

Show the trace of the Einstein curvature tensor for the FLRW metric:

 In[15]:=
 Out[15]=

Show the trace of the Einstein curvature tensor for the FLRW metric, with all algebraic equivalences imposed:

 In[16]:=
 Out[16]=

Deduce that the trace of the Einstein curvature tensor for the FLRW metric is non-vanishing:

 In[17]:=
 Out[17]=

Show the condition that must hold for the FLRW metric to have a vanishing trace of the Einstein curvature tensor:

 In[18]:=
 Out[18]=

Show the list of coordinate values that cause the Einstein curvature tensor for the FLRW metric to become singular:

 In[19]:=
 Out[19]=

Show the list of coordinate values that cause the trace of the Einstein curvature tensor for the FLRW metric to become singular:

 In[20]:=
 Out[20]=

Show the association of all covariant derivatives (i.e. derivatives along tangent vectors of the manifold) of the Einstein curvature tensor for the FLRW metric:

 In[21]:=
 Out[21]=

Show the association of all covariant derivatives of the Einstein curvature tensor for the FLRW metric, with all algebraic equivalences imposed:

 In[22]:=
 Out[22]=

Show the list of all (contracted) Bianchi identities asserting that the covariant divergence of the Einstein curvature tensor vanishes for the FLRW metric:

 In[23]:=
 Out[23]=

Show that the (contracted) Bianchi identities for the FLRW metric all hold identically:

 In[24]:=
 Out[24]=

Construct the Einstein curvature tensor for the Kerr-Newman metric (e.g. for a charged, spinning black hole with symbolic mass "M", symbolic angular momentum "J" and symbolic electric charge "Q") in Boyer-Lindquist/oblate spheroidal coordinates:

 In[25]:=
 Out[25]=
 In[26]:=
 Out[26]=
 In[27]:=
 Out[27]=

Extract (and simplify) the time-time component of the Einstein curvature tensor for the Kerr-Newman metric:

 In[28]:=
 Out[28]=

Extract (and simplify) the first row of the Einstein curvature tensor for the Kerr-Newman metric in matrix form:

 In[29]:=
 Out[29]=

Extract (and simplify) the first column of the Einstein curvature tensor for the Kerr-Newman metric in matrix form:

 In[30]:=
 Out[30]=

Compute the contravariant form of the Einstein curvature tensor (with both indices raised):

 In[31]:=
 Out[31]=
 In[32]:=
 Out[32]=
 In[33]:=
 Out[33]=
 In[34]:=
 Out[34]=

Compute a mixed form of the Einstein curvature tensor with one index raised/contravariant and one index lowered/covariant:

 In[35]:=
 Out[35]=
 In[36]:=
 Out[36]=
 In[37]:=
 Out[37]=
 In[38]:=
 Out[38]=

Transform to use the new coordinate symbols t, r, a1 and a2:

 In[39]:=
 Out[39]=
 In[40]:=
 Out[40]=

Transform to use the new coordinate symbols t, r, a1 and a2, and raise both indices, simultaneously:

 In[41]:=
 Out[41]=
 In[42]:=
 Out[42]=

### Scope (3)

Einstein curvature tensors can be constructed directly from a MetricTensor expression:

 In[43]:=
 Out[43]=
 In[44]:=
 Out[44]=

Additional arguments can be used to specify the coordinate symbols (otherwise default symbols will be chosen automatically):

 In[45]:=
 Out[45]=
 In[46]:=
 Out[46]=

Or the indices (True for lowered/covariant and False for raised/contravariant - otherwise both indices will be set as lowered/covariant by default):

 In[47]:=
 Out[47]=
 In[48]:=
 Out[48]=

Or both simultaneously:

 In[49]:=
 Out[49]=
 In[50]:=
 Out[50]=

New coordinate symbols can be specified for any Einstein curvature tensor:

 In[51]:=
 Out[51]=
 In[52]:=
 Out[52]=
 In[53]:=
 Out[53]=
 In[54]:=
 Out[54]=

Indices can also be raised and lowered on any Einstein curvature tensor:

 In[55]:=
 Out[55]=
 In[56]:=
 Out[56]=

New coordinate symbols and new index positions can also be specified simultaneously:

 In[57]:=
 Out[57]=
 In[58]:=
 Out[58]=
 In[59]:=
 Out[59]=

Construct the Einstein curvature tensor for the FLRW metric, with symbolic curvature parameter "k" and symbolic scale factor "a":

 In[60]:=
 Out[60]=
 In[61]:=
 Out[61]=

Show the list of properties:

 In[62]:=
 Out[62]=

Show the explicit matrix representation of the Einstein curvature tensor:

 In[63]:=
 Out[63]=

Show the explicit matrix representation of the Einstein curvature tensor, with all algebraic equivalences imposed:

 In[64]:=
 Out[64]=

Show the explicit matrix representation of the Einstein curvature tensor, with all partial derivative operators left purely symbolic:

 In[65]:=
 Out[65]=

Show the trace of the Einstein curvature tensor:

 In[66]:=
 Out[66]=

Show the trace of the Einstein curvature tensor, with all algebraic equivalences imposed:

 In[67]:=
 Out[67]=

Show the trace of the Einstein curvature tensor, with all partial derivative operators left purely symbolic:

 In[68]:=
 Out[68]=

Show the metric tensor for the underlying manifold represented by the Einstein curvature tensor:

 In[69]:=
 Out[69]=

Show the list of coordinate symbols for the Einstein curvature tensor:

 In[70]:=
 Out[70]=

Show the list of differential 1-form symbols for the coordinates of the Einstein curvature tensor:

 In[71]:=
 Out[71]=

Show the list of booleans specifying the positions of the indices of the Einstein curvature tensor (True for lowered/covariant and False for raised/contravariant):

 In[72]:=
 Out[72]=

Determine whether the Einstein curvature tensor is covariant (i.e. both indices are lowered/covariant):

 In[73]:=
 Out[73]=

Determine whether the Einstein curvature tensor is contravariant (i.e. both indices are raised/contravariant):

 In[74]:=
 Out[74]=

Determine whether the Einstein curvature tensor is mixed (i.e. one index is lowered/covariant and one index is raised/contravariant):

 In[75]:=
 Out[75]=

Show a symbolic representation of the Einstein curvature tensor with appropriately raised/lowered indices:

 In[76]:=
 Out[76]=

Determine whether the underlying manifold is Einstein-flat (i.e. all components of the Einstein curvature tensor vanish):

 In[77]:=
 Out[77]=

Determine whether the underlying manifold has a vanishing trace of the Einstein curvature tensor:

 In[78]:=
 Out[78]=

Show the list of conditions required to guarantee that the underlying manifold is Einstein-flat (i.e. all components of the Einstein curvature tensor vanish):

 In[79]:=
 Out[79]=

Show the condition required to guarantee that the underlying manifold has a vanishing trace of the Einstein curvature tensor:

 In[80]:=
 Out[80]=

Show the association of all covariant derivatives (i.e. all derivatives along tangent vectors of the underlying manifold) of the Einstein curvature tensor:

 In[81]:=
 Out[81]=

Show the association of all covariant derivatives (i.e. all derivatives along tangent vectors of the underlying manifold) of the Einstein curvature tensor, with all algebraic equivalences imposed:

 In[82]:=
 Out[82]=

Show the association of all covariant derivatives (i.e. derivatives along tangent vectors of the underlying manifold) of the Einstein curvature tensor, with all partial derivative operators left purely symbolic:

 In[83]:=
 Out[83]=

Show the list of all (contracted) Bianchi identities asserting that the covariant divergence of the Einstein curvature tensor must vanish:

 In[84]:=
 Out[84]=

Show the list of all (contracted) Bianchi identities asserting that the covariant divergence of the Einstein curvature tensor must vanish, with all partial derivative operators left purely symbolic:

 In[85]:=
 Out[85]=

Show the number of dimensions of the underlying manifold represented by the Einstein curvature tensor:

 In[86]:=
 Out[86]=

Determine whether the Einstein curvature tensor is symmetric (in explicit, covariant matrix form):

 In[87]:=
 Out[87]=

Determine whether the Einstein curvature tensor is diagonal (in explicit, covariant matrix form):

 In[88]:=
 Out[88]=

Show the signature of the underlying manifold represented by the Einstein curvature tensor (with +1s representing positive eigenvalues and -1s representing negative eigenvalues of the metric tensor):

 In[89]:=
 Out[89]=

Determine whether the underlying manifold represented by the Einstein curvature tensor is Riemannian (i.e. all eigenvalues of the metric tensor have the same sign):

 In[90]:=
 Out[90]=

Determine whether the underlying manifold represented by the Einstein curvature tensor is pseudo-Riemannian (i.e. all eigenvalues are non-zero, but not all have the same sign):

 In[91]:=
 Out[91]=

Determine whether the underlying manifold represented by the Einstein curvature tensor is Lorentzian (i.e. all eigenvalues of the metric tensor have the same sign, except for one eigenvalue which has the opposite sign):

 In[92]:=
 Out[92]=

Show the list of conditions on the coordinates required to guarantee that the underlying manifold represented by the Einstein curvature tensor is Riemannian (i.e. all eigenvalues of the metric tensor are positive):

 In[93]:=
 Out[93]=

Show the list of conditions on the coordinates required to guarantee that the underlying manifold represented by the Einstein curvature tensor is pseudo-Riemannian (i.e. all eigenvalues of the metric tensor are non-zero):

 In[94]:=
 Out[94]=

Show the list of conditions on the coordinates required to guarantee that the underlying manifold represented by the Einstein curvature tensor is Lorentzian (i.e. the "time" eigenvalue is negative, and all other eigenvalues are positive):

 In[95]:=
 Out[95]=

Show the list of coordinate values that cause the Einstein curvature tensor to become singular:

 In[96]:=
 Out[96]=

Show the list of coordinate values that cause the trace of the Einstein curvature tensor to become singular:

 In[97]:=
 Out[97]=

Show the determinant of the Einstein curvature tensor (when represented as a covariant matrix):

 In[98]:=
 Out[98]=

Show the determinant of the Einstein curvature tensor (when represented as a covariant matrix), with all algebraic equivalences imposed:

 In[99]:=
 Out[99]=

Show the determinant of the Einstein curvature tensor (when represented as a covariant matrix), with all partial derivative operators left purely symbolic:

 In[100]:=
 Out[100]=

Show the eigenvalues of the Einstein curvature tensor (when represented as a covariant matrix):

 In[101]:=
 Out[101]=

Show the eigenvalues of the Einstein curvature tensor (when represented as a covariant matrix), with all algebraic equivalences imposed:

 In[102]:=
 Out[102]=

Show the eigenvectors of the Einstein curvature tensor (when represented as a covariant matrix):

 In[103]:=
 Out[103]=

Show the eigenvectors of the Einstein curvature tensor (when represented as a covariant matrix), with all algebraic equivalences imposed:

 In[104]:=
 Out[104]=

Compute the covariant form of the Einstein curvature tensor (with both indices lowered/covariant):

 In[105]:=
 Out[105]=

Compute the contravariant form of the Einstein curvature tensor (with both indices raised/contravariant):

 In[106]:=
 Out[106]=

Jonathan Gorard

## Version History

• 1.0.0 – 01 March 2023