In General Relativity, one possible way to decide if a space-time [i.e. a Lorentzian Manifold $(\mathcal{M}, \textbf{g})$ where $\textbf{g}$ is an arbitrary metric tensor.] is a "resonable physical" $[1]$ one, is then check the so called Energy Conditions $[2]$, for exemple:

A physical Space-time is the one who satisfies both:

\begin{cases} G_{\mu \nu} =: R_{\mu \nu} - \frac{1}{2}Rg_{\mu \nu} = \frac{8\pi G}{c^{4}}T_{\mu \nu}\\ T_{\mu \nu}u^{\mu}u^{\nu}\geq 0 \end{cases}

Where $T_{\mu \nu}u^{\mu}u^{\nu}\geq 0$ for all timelike vectors $u^{\alpha}$ is called the Weak Energy Condition (WEC).

Now, if you have a metric and energy-momentum tensor you can calculate almost all the basic quantities in GR, including the WEC. Knowing that fact, consider then this Python Code for SageManifolds:


How can I calculate the WEC based on this code? (I used this example because the author have used a perfect fluid energy-momentum tensor, also, he defined the 4-(time-like) vectors and 4-(time-like) dual vectors (covectors or one-forms)

$$ * * * $$

$[1]$ WALD.R., General Relativity. Chicago University Press. pages 211-219. Chicago, 1984

$[2]$ LOBO.F.S.N., Fundamental Theories of Physics: Wormholes, Warp Drives and Energy Conditions. Springer. pages 193-196.vol 186. Switzerland. 2017.

  • $\begingroup$ What is $u^\mu$? $\endgroup$
    – nicoguaro
    Jun 12, 2019 at 15:45
  • $\begingroup$ It's a contravariant time-like 4-vector called four-velocity. $\endgroup$
    – M.N.Raia
    Jun 12, 2019 at 18:59
  • $\begingroup$ Are you familiar with tensor calculus and general relativity? $\endgroup$
    – M.N.Raia
    Jun 12, 2019 at 19:00
  • 1
    $\begingroup$ @M.N.Raia I think we are facing a common problem of "language/notation difference" between physicists and computational scientists. $\endgroup$
    – Anton Menshov
    Jun 12, 2019 at 19:25
  • 1
    $\begingroup$ Then, what you need is to prove that $T$ is positive semidefinite? I would say that the easiest way is to write $T$ in a coordinate system as a matrix and finding all minors or eigenvalues. Another option would be to expand the product to get an explicit form for the bilinear form and find the minimum, that should be $0$. $\endgroup$
    – nicoguaro
    Jun 14, 2019 at 11:57

1 Answer 1


Given $T_{\mu\nu}$ you must compute its components in an orthonormal base , then find the eigenvalues ($\lambda_0,\lambda_1,\lambda_2,\lambda_3$) corresponding to the timelike and spacelike eigenvectors, then WEC is equivalent to : $$\lambda_0\geq0, \lambda_0+\lambda_i\geq0, (i=1..3)$$

In your case, using an obvious orthonormal basis, $T_{\mu\nu}$ becomes diagonal$(\rho,p,p,p)$ so the condition reads $$\rho\ge0,\rho+p\ge0$$ This is also exlained in Wald and wikipedia.

I am not very familiar with Sage (I just downloaded it today). But I am very familiar with xAct, the powerful differential geometry and tensor manipulation package suite for Mathematica to which I am one of the contributors (xprint package).

You may get more sage specific help at AskSage


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.