Cadabra

Friedmann-Robertson-Walker

This example starts from the Friedmann-Robertson-Walker metric for a homogeneous and isotropic universe, to derive the Friedmann equations. We start by declaring indices. We also introduce some shorthand notations to display derivatives using dots.
__cdbkernel__.display_fractions=True
{t, r, \theta, \phi}::Coordinate(); {\mu,\nu,\rho,\sigma,\kappa,\lambda}::Indices(values={t, r, \theta, \phi}, position=fixed);
\(\displaystyle{}\text{Property Coordinate attached to }\left[t, r, \theta, \phi\right].\)
\(\displaystyle{}\text{Property Indices(position=fixed, values=\{{t} , {r} , {\theta} , {\phi} \}) attached to }\left[\mu, \nu, \rho, \sigma, \kappa, \lambda\right].\)
a::Depends(t); \partial{#}::PartialDerivative; \partial_{t}{A??}::LaTeXForm("\dot{", A??, "}"); \partial_{t t}{A??}::LaTeXForm("\ddot{", A??, "}");
\(\displaystyle{}\text{Property Depends attached to }a.\)
\(\displaystyle{}\text{Property PartialDerivative attached to }\backslash\texttt{partial}\{\#\}.\)
\(\displaystyle{}\text{Property LaTeXForm attached to $\setminus\texttt{partial}$.}\)
\(\displaystyle{}\text{Property LaTeXForm attached to $\setminus\texttt{partial}$.}\)
Now it is time to declare the metric and its components.
g_{\mu\nu}::Metric; g^{\mu\nu}::InverseMetric;
\(\displaystyle{}\text{Property Metric attached to }g_{\mu \nu}.\)
\(\displaystyle{}\text{Property TableauSymmetry attached to }g^{\mu \nu}.\)
metric:= { g_{t t} = -1, g_{r r} = a**2 / (1 - k r**2), g_{\theta\theta} = a**2 r**2, g_{\phi\phi} = a**2 r**2 \sin(\theta)**2 };
\(\displaystyle{}\left[g_{t t} = -\,1, g_{r r} = \frac{{a}^{2\,}}{\left(1 -\,k {r}^{2\,}\right)}, g_{\theta \theta} = {a}^{2\,} {r}^{2\,}, g_{\phi \phi} = {a}^{2\,} {r}^{2\,} {\left(\sin{\theta}\right)}^{2\,}\right]\)
The inverse metric is computed by using complete,
complete(metric, $g^{\mu\nu}$);
\(\displaystyle{}\left[g_{t t} = -\,1, g_{r r} = \frac{{a}^{2\,}}{\left(1 -\,k {r}^{2\,}\right)}, g_{\theta \theta} = {a}^{2\,} {r}^{2\,}, g_{\phi \phi} = {a}^{2\,} {r}^{2\,} {\left(\sin{\theta}\right)}^{2\,}, g^{t t} = -\,1, g^{r r} = \frac{\left(-\,k {r}^{2\,} +1\right)}{{a}^{2\,}}, g^{\theta \theta} = \frac{1}{{r}^{2\,} {a}^{2\,}}, g^{\phi \phi} = \frac{1}{{r}^{2\,} {a}^{2\,} {\left(\sin{\theta}\right)}^{2\,}}\right]\)
Now we need the Christoffel symbols, and then the Riemann tensor. First define them,
chr:= \Gamma^{\sigma}_{\mu\nu} = 1/2 g^{\sigma\rho} ( \partial_{\mu}{g_{\nu\rho}} + \partial_{\nu}{g_{\mu\rho}} - \partial_{\rho}{g_{\mu\nu}} );
\(\displaystyle{}\Gamma^{\sigma}\,_{\mu \nu} = \frac{1}{2}\,g^{\sigma \rho} \left(\partial_{\mu}{g_{\nu \rho}} +\partial_{\nu}{g_{\mu \rho}} -\,\partial_{\rho}{g_{\mu \nu}}\right)\)
and then evaluate the components for the particular component values of the FRW metric:
evaluate(chr, metric, rhsonly=True);
\(\displaystyle{}\Gamma^{\sigma}\,_{\mu \nu} = \square{}_{\nu}{}_{\mu}{}^{\sigma}\left\{\begin{aligned}\square{}_{\phi}{}_{t}{}^{\phi}& = \square{}_{t}{}_{\phi}{}^{\phi} = \square{}_{\theta}{}_{t}{}^{\theta} = \square{}_{r}{}_{t}{}^{r} = \square{}_{t}{}_{\theta}{}^{\theta} = \square{}_{t}{}_{r}{}^{r} = \frac{\dot{a}}{a}\\[-.5ex] \square{}_{\phi}{}_{r}{}^{\phi}& = \square{}_{r}{}_{\phi}{}^{\phi} = \square{}_{\theta}{}_{r}{}^{\theta} = \square{}_{r}{}_{\theta}{}^{\theta} = \frac{1}{r}\\[-.5ex] \square{}_{\phi}{}_{\theta}{}^{\phi}& = \square{}_{\theta}{}_{\phi}{}^{\phi} = \frac{1}{\tan{\theta}}\\[-.5ex] \square{}_{r}{}_{r}{}^{r}& = -\frac{k r}{\left(k {r}^{2\,} -\,1\right)}\\[-.5ex] \square{}_{\phi}{}_{\phi}{}^{t}& = {r}^{2\,} a {\left(\sin{\theta}\right)}^{2\,} \dot{a}\\[-.5ex] \square{}_{\phi}{}_{\phi}{}^{r}& = r \left(k {r}^{2\,} -\,1\right) {\left(\sin{\theta}\right)}^{2\,}\\[-.5ex] \square{}_{\phi}{}_{\phi}{}^{\theta}& = - \frac{1}{2}\,\sin\left(2\,\theta\right)\\[-.5ex] \square{}_{\theta}{}_{\theta}{}^{t}& = {r}^{2\,} a \dot{a}\\[-.5ex] \square{}_{\theta}{}_{\theta}{}^{r}& = k {r}^{3\,} -\,r\\[-.5ex] \square{}_{r}{}_{r}{}^{t}& = -\frac{a \dot{a}}{\left(k {r}^{2\,} -\,1\right)}\\[-.5ex] \end{aligned}\right\} \)
riem:= R^{\rho}_{\sigma\mu\nu} = \partial_{\mu}{\Gamma^{\rho}_{\sigma\nu}} - \partial_{\nu}{\Gamma^{\rho}_{\sigma\mu}} + \Gamma^{\rho}_{\mu\lambda} \Gamma^{\lambda}_{\nu\sigma} - \Gamma^{\rho}_{\nu\lambda} \Gamma^{\lambda}_{\mu\sigma};
\(\displaystyle{}R^{\rho}\,_{\sigma \mu \nu} = \partial_{\mu}{\Gamma^{\rho}\,_{\sigma \nu}} -\,\partial_{\nu}{\Gamma^{\rho}\,_{\sigma \mu}} +\Gamma^{\rho}\,_{\mu \lambda} \Gamma^{\lambda}\,_{\nu \sigma} -\,\Gamma^{\rho}\,_{\nu \lambda} \Gamma^{\lambda}\,_{\mu \sigma}\)
substitute(riem, chr)
evaluate(riem, metric, rhsonly=True);
\(\displaystyle{}R^{\rho}\,_{\sigma \mu \nu} = \square{}_{\nu}{}_{\sigma}{}^{\rho}{}_{\mu}\left\{\begin{aligned}\square{}_{r}{}_{r}{}^{t}{}_{t}& = -\frac{a \ddot{a}}{\left(k {r}^{2\,} -\,1\right)}\\[-.5ex] \square{}_{\theta}{}_{\theta}{}^{r}{}_{r}& = \square{}_{\theta}{}_{\theta}{}^{\phi}{}_{\phi} = {r}^{2\,} \left(k +{\left(\dot{a}\right)}^{2\,}\right)\\[-.5ex] \square{}_{\theta}{}_{\theta}{}^{t}{}_{t}& = {r}^{2\,} a \ddot{a}\\[-.5ex] \square{}_{\phi}{}_{\phi}{}^{\theta}{}_{\theta}& = \square{}_{\phi}{}_{\phi}{}^{r}{}_{r} = {r}^{2\,} \left(k +{\left(\dot{a}\right)}^{2\,}\right) {\left(\sin{\theta}\right)}^{2\,}\\[-.5ex] \square{}_{\phi}{}_{\phi}{}^{t}{}_{t}& = {r}^{2\,} a {\left(\sin{\theta}\right)}^{2\,} \ddot{a}\\[-.5ex] \square{}_{r}{}_{t}{}^{r}{}_{t}& = \square{}_{\phi}{}_{t}{}^{\phi}{}_{t} = \square{}_{\theta}{}_{t}{}^{\theta}{}_{t} = \frac{\ddot{a}}{a}\\[-.5ex] \square{}_{\theta}{}_{r}{}^{\theta}{}_{r}& = \square{}_{\phi}{}_{r}{}^{\phi}{}_{r} = \frac{\left(k +{\left(\dot{a}\right)}^{2\,}\right)}{\left(k {r}^{2\,} -\,1\right)}\\[-.5ex] \square{}_{\phi}{}_{\theta}{}^{\phi}{}_{\theta}& = -\,{r}^{2\,} \left(k +{\left(\dot{a}\right)}^{2\,}\right)\\[-.5ex] \square{}_{t}{}_{r}{}^{t}{}_{r}& = \frac{a \ddot{a}}{\left(k {r}^{2\,} -\,1\right)}\\[-.5ex] \square{}_{r}{}_{\theta}{}^{r}{}_{\theta}& = {r}^{2\,} \left(-\,k -\,{\left(\dot{a}\right)}^{2\,}\right)\\[-.5ex] \square{}_{t}{}_{\theta}{}^{t}{}_{\theta}& = -\,{r}^{2\,} a \ddot{a}\\[-.5ex] \square{}_{\theta}{}_{\phi}{}^{\theta}{}_{\phi}& = -\,{r}^{2\,} \left(k +{\left(\dot{a}\right)}^{2\,}\right) {\left(\sin{\theta}\right)}^{2\,}\\[-.5ex] \square{}_{r}{}_{\phi}{}^{r}{}_{\phi}& = {r}^{2\,} \left(-\,k -\,{\left(\dot{a}\right)}^{2\,}\right) {\left(\sin{\theta}\right)}^{2\,}\\[-.5ex] \square{}_{t}{}_{\phi}{}^{t}{}_{\phi}& = -\,{r}^{2\,} a {\left(\sin{\theta}\right)}^{2\,} \ddot{a}\\[-.5ex] \square{}_{t}{}_{t}{}^{r}{}_{r}& = \square{}_{t}{}_{t}{}^{\theta}{}_{\theta} = \square{}_{t}{}_{t}{}^{\phi}{}_{\phi} = -\frac{\ddot{a}}{a}\\[-.5ex] \square{}_{r}{}_{r}{}^{\theta}{}_{\theta}& = \square{}_{r}{}_{r}{}^{\phi}{}_{\phi} = \frac{\left(-\,k -\,{\left(\dot{a}\right)}^{2\,}\right)}{\left(k {r}^{2\,} -\,1\right)}\\[-.5ex] \end{aligned}\right\} \)
Finally, the Ricci tensor and after that the Ricci scalar, which we need to compute the Einstein tensor shortly.
ricc:= R_{\mu\nu} = R^{\rho}_{\mu\nu\rho};
\(\displaystyle{}R_{\mu \nu} = R^{\rho}\,_{\mu \nu \rho}\)
substitute(ricc, riem) evaluate(ricc, metric, rhsonly=True);
\(\displaystyle{}R_{\mu \nu} = \square{}_{\mu}{}_{\nu}\left\{\begin{aligned}\square{}_{t}{}_{t}& = \frac{3\,\ddot{a}}{a}\\[-.5ex] \square{}_{r}{}_{r}& = \frac{\left(2\,k +a \ddot{a} +2\,{\left(\dot{a}\right)}^{2\,}\right)}{\left(k {r}^{2\,} -\,1\right)}\\[-.5ex] \square{}_{\theta}{}_{\theta}& = {r}^{2\,} \left(-2\,k -\,a \ddot{a} -2\,{\left(\dot{a}\right)}^{2\,}\right)\\[-.5ex] \square{}_{\phi}{}_{\phi}& = {r}^{2\,} \left(-2\,k -\,a \ddot{a} -2\,{\left(\dot{a}\right)}^{2\,}\right) {\left(\sin{\theta}\right)}^{2\,}\\[-.5ex] \end{aligned}\right\} \)
rsc:= R = g^{\mu\nu} R_{\mu\nu};
\(\displaystyle{}R = g^{\mu \nu} R_{\mu \nu}\)
substitute(rsc, ricc) evaluate(rsc, metric, rhsonly=True);
\(\displaystyle{}R = \frac{6\,\left(-\,k -\,a \ddot{a} -\,{\left(\dot{a}\right)}^{2\,}\right)}{{a}^{2\,}}\)
Let's compute the Einstein tensor, as we will need that to compute equations of motion for the scale factor. Start with the definition,
einstein:= G_{\mu\nu} = R_{\mu\nu} - 1/2 g_{\mu\nu} R;
\(\displaystyle{}G_{\mu \nu} = R_{\mu \nu} - \frac{1}{2}\,g_{\mu \nu} R\)
Substitute the components for the Ricci tensor and scalar computed above, and then use the metric at the last step to finish the computation,
substitute(einstein, ricc) substitute(einstein, rsc) evaluate(einstein, metric, rhsonly=True);
\(\displaystyle{}G_{\mu \nu} = \square{}_{\mu}{}_{\nu}\left\{\begin{aligned}\square{}_{t}{}_{t}& = \frac{3\,\left(-\,k -\,{\left(\dot{a}\right)}^{2\,}\right)}{{a}^{2\,}}\\[-.5ex] \square{}_{r}{}_{r}& = \frac{\left(-\,k -2\,a \ddot{a} -\,{\left(\dot{a}\right)}^{2\,}\right)}{\left(k {r}^{2\,} -\,1\right)}\\[-.5ex] \square{}_{\theta}{}_{\theta}& = {r}^{2\,} \left(k +2\,a \ddot{a} +{\left(\dot{a}\right)}^{2\,}\right)\\[-.5ex] \square{}_{\phi}{}_{\phi}& = {r}^{2\,} \left(k +2\,a \ddot{a} +{\left(\dot{a}\right)}^{2\,}\right) {\left(\sin{\theta}\right)}^{2\,}\\[-.5ex] \end{aligned}\right\} \)
Let's compute the Einstein tensor with mixed indices by simply raising one:
evaluate(substitute($G^{\mu}_{\nu} = g^{\mu\rho} G_{\rho\nu}$, einstein), metric, rhsonly=True);
\(\displaystyle{}G^{\mu}\,_{\nu} = \square{}_{\nu}{}^{\mu}\left\{\begin{aligned}\square{}_{t}{}^{t}& = \frac{3\,\left(k +{\left(\dot{a}\right)}^{2\,}\right)}{{a}^{2\,}}\\[-.5ex] \square{}_{r}{}^{r}& = \square{}_{\theta}{}^{\theta} = \square{}_{\phi}{}^{\phi} = \frac{\left(k +2\,a \ddot{a} +{\left(\dot{a}\right)}^{2\,}\right)}{{a}^{2\,}}\\[-.5ex] \end{aligned}\right\} \)
einsteinmixed:= G^{\mu}_{\nu} = g^{\mu\rho} G_{\rho\nu};
\(\displaystyle{}G^{\mu}\,_{\nu} = g^{\mu \rho} G_{\rho \nu}\)
substitute(einsteinmixed, einstein) evaluate(einsteinmixed, metric, rhsonly=True);
\(\displaystyle{}G^{\mu}\,_{\nu} = \square{}_{\nu}{}^{\mu}\left\{\begin{aligned}\square{}_{t}{}^{t}& = \frac{3\,\left(k +{\left(\dot{a}\right)}^{2\,}\right)}{{a}^{2\,}}\\[-.5ex] \square{}_{r}{}^{r}& = \square{}_{\theta}{}^{\theta} = \square{}_{\phi}{}^{\phi} = \frac{\left(k +2\,a \ddot{a} +{\left(\dot{a}\right)}^{2\,}\right)}{{a}^{2\,}}\\[-.5ex] \end{aligned}\right\} \)
Now on to the Friedmann equations. We need the Einstein equations first (could have used the pre-computed Einstein tensor above),
frw:= R_{\mu\nu} - 1/2 g_{\mu\nu} = T_{\mu\nu};
\(\displaystyle{}R_{\mu \nu} - \frac{1}{2}\,g_{\mu \nu} = T_{\mu \nu}\)
The stress tensor depends on the density $\rho$ and the pressure $p$,
stress:= { T_{t t} = \rho, T_{r r} = p g_{r r}, T_{\phi\phi} = p g_{\phi\phi}, T_{\theta\theta} = p g_{\theta\theta} };
\(\displaystyle{}\left[T_{t t} = \rho, T_{r r} = p g_{r r}, T_{\phi \phi} = p g_{\phi \phi}, T_{\theta \theta} = p g_{\theta \theta}\right]\)
substitute(frw, ricc);
\(\displaystyle{}\square{}_{\mu}{}_{\nu}\left\{\begin{aligned}\square{}_{t}{}_{t}& = \frac{3\,\ddot{a}}{a}\\[-.5ex] \square{}_{r}{}_{r}& = \frac{\left(2\,k +a \ddot{a} +2\,{\left(\dot{a}\right)}^{2\,}\right)}{\left(k {r}^{2\,} -\,1\right)}\\[-.5ex] \square{}_{\theta}{}_{\theta}& = {r}^{2\,} \left(-2\,k -\,a \ddot{a} -2\,{\left(\dot{a}\right)}^{2\,}\right)\\[-.5ex] \square{}_{\phi}{}_{\phi}& = {r}^{2\,} \left(-2\,k -\,a \ddot{a} -2\,{\left(\dot{a}\right)}^{2\,}\right) {\left(\sin{\theta}\right)}^{2\,}\\[-.5ex] \end{aligned}\right\} - \frac{1}{2}\,g_{\mu \nu} = T_{\mu \nu}\)
evaluate(frw, join(metric, stress));
\(\displaystyle{}\square{}_{\mu}{}_{\nu}\left\{\begin{aligned}\square{}_{t}{}_{t}& = \frac{1}{2}\, +\frac{3\,\ddot{a}}{a}\\[-.5ex] \square{}_{r}{}_{r}& = \frac{\left(2\,k +\frac{1}{2}\,{a}^{2\,} +a \ddot{a} +2\,{\left(\dot{a}\right)}^{2\,}\right)}{\left(k {r}^{2\,} -\,1\right)}\\[-.5ex] \square{}_{\theta}{}_{\theta}& = {r}^{2\,} \left(-2\,k - \frac{1}{2}\,{a}^{2\,} -\,a \ddot{a} -2\,{\left(\dot{a}\right)}^{2\,}\right)\\[-.5ex] \square{}_{\phi}{}_{\phi}& = {r}^{2\,} \left(-2\,k - \frac{1}{2}\,{a}^{2\,} -\,a \ddot{a} -2\,{\left(\dot{a}\right)}^{2\,}\right) {\left(\sin{\theta}\right)}^{2\,}\\[-.5ex] \end{aligned}\right\} = \square{}_{\mu}{}_{\nu}\left\{\begin{aligned}\square{}_{t}{}_{t}& = \rho\\[-.5ex] \square{}_{r}{}_{r}& = p g_{r r}\\[-.5ex] \square{}_{\phi}{}_{\phi}& = p g_{\phi \phi}\\[-.5ex] \square{}_{\theta}{}_{\theta}& = p g_{\theta \theta}\\[-.5ex] \end{aligned}\right\} \)
substitute(frw, metric);
\(\displaystyle{}\square{}_{\mu}{}_{\nu}\left\{\begin{aligned}\square{}_{t}{}_{t}& = \frac{1}{2}\, +\frac{3\,\ddot{a}}{a}\\[-.5ex] \square{}_{r}{}_{r}& = \frac{\left(2\,k +\frac{1}{2}\,{a}^{2\,} +a \ddot{a} +2\,{\left(\dot{a}\right)}^{2\,}\right)}{\left(k {r}^{2\,} -\,1\right)}\\[-.5ex] \square{}_{\theta}{}_{\theta}& = {r}^{2\,} \left(-2\,k - \frac{1}{2}\,{a}^{2\,} -\,a \ddot{a} -2\,{\left(\dot{a}\right)}^{2\,}\right)\\[-.5ex] \square{}_{\phi}{}_{\phi}& = {r}^{2\,} \left(-2\,k - \frac{1}{2}\,{a}^{2\,} -\,a \ddot{a} -2\,{\left(\dot{a}\right)}^{2\,}\right) {\left(\sin{\theta}\right)}^{2\,}\\[-.5ex] \end{aligned}\right\} = \square{}_{\mu}{}_{\nu}\left\{\begin{aligned}\square{}_{t}{}_{t}& = \rho\\[-.5ex] \square{}_{r}{}_{r}& = \frac{p {a}^{2\,}}{\left(1 -\,k {r}^{2\,}\right)}\\[-.5ex] \square{}_{\phi}{}_{\phi}& = p {a}^{2\,} {r}^{2\,} {\left(\sin{\theta}\right)}^{2\,}\\[-.5ex] \square{}_{\theta}{}_{\theta}& = p {a}^{2\,} {r}^{2\,}\\[-.5ex] \end{aligned}\right\} \)
This is still a bit ugly; we would like to move the right-hand sides to the left-hand side so we have four expressions that need to vanish for the Einstein equations to hold. Use the `cdb.core.manip` module for that, which contains `lhs` and `rhs` functions:
from cdb.core.manip import *
q=lhs(frw) - rhs(frw);
\(\displaystyle{}\square{}_{\mu}{}_{\nu}\left\{\begin{aligned}\square{}_{t}{}_{t}& = \frac{1}{2}\, +\frac{3\,\ddot{a}}{a}\\[-.5ex] \square{}_{r}{}_{r}& = \frac{\left(2\,k +\frac{1}{2}\,{a}^{2\,} +a \ddot{a} +2\,{\left(\dot{a}\right)}^{2\,}\right)}{\left(k {r}^{2\,} -\,1\right)}\\[-.5ex] \square{}_{\theta}{}_{\theta}& = {r}^{2\,} \left(-2\,k - \frac{1}{2}\,{a}^{2\,} -\,a \ddot{a} -2\,{\left(\dot{a}\right)}^{2\,}\right)\\[-.5ex] \square{}_{\phi}{}_{\phi}& = {r}^{2\,} \left(-2\,k - \frac{1}{2}\,{a}^{2\,} -\,a \ddot{a} -2\,{\left(\dot{a}\right)}^{2\,}\right) {\left(\sin{\theta}\right)}^{2\,}\\[-.5ex] \end{aligned}\right\} +\square{}_{\mu}{}_{\nu}\left\{\begin{aligned}\square{}_{t}{}_{t}& = -\,\rho\\[-.5ex] \square{}_{r}{}_{r}& = -\frac{p {a}^{2\,}}{\left(1 -\,k {r}^{2\,}\right)}\\[-.5ex] \square{}_{\phi}{}_{\phi}& = -\,p {a}^{2\,} {r}^{2\,} {\left(\sin{\theta}\right)}^{2\,}\\[-.5ex] \square{}_{\theta}{}_{\theta}& = -\,p {a}^{2\,} {r}^{2\,}\\[-.5ex] \end{aligned}\right\} \)
Now we can collect the components into one tensor,
collect_components(q);
\(\displaystyle{}\square{}_{\mu}{}_{\nu}\left\{\begin{aligned}\square{}_{t}{}_{t}& = -\,\rho +\frac{1}{2}\, +\frac{3\,\ddot{a}}{a}\\[-.5ex] \square{}_{r}{}_{r}& = \frac{\left(2\,k +p {a}^{2\,} +\frac{1}{2}\,{a}^{2\,} +a \ddot{a} +2\,{\left(\dot{a}\right)}^{2\,}\right)}{\left(k {r}^{2\,} -\,1\right)}\\[-.5ex] \square{}_{\theta}{}_{\theta}& = {r}^{2\,} \left(-2\,k -\,p {a}^{2\,} - \frac{1}{2}\,{a}^{2\,} -\,a \ddot{a} -2\,{\left(\dot{a}\right)}^{2\,}\right)\\[-.5ex] \square{}_{\phi}{}_{\phi}& = {r}^{2\,} \left(-2\,k -\,p {a}^{2\,} - \frac{1}{2}\,{a}^{2\,} -\,a \ddot{a} -2\,{\left(\dot{a}\right)}^{2\,}\right) {\left(\sin{\theta}\right)}^{2\,}\\[-.5ex] \end{aligned}\right\} \)
If you want to extract the individual components, use the get_component function of the cdb.core.component package:
from cdb.core.component import *
e1=get_component(q, $\theta, \theta$);
\(\displaystyle{}{r}^{2\,} \left(-2\,k -\,p {a}^{2\,} - \frac{1}{2}\,{a}^{2\,} -\,a \ddot{a} -2\,{\left(\dot{a}\right)}^{2\,}\right)\)
e2=get_component(q, $t, t$);
\(\displaystyle{}-\,\rho +\frac{1}{2}\, +\frac{3\,\ddot{a}}{a}\)