I am trying to perturb equations of motion (eom) of a scalar field in a flat FLRW universe. I set the action to be:

$$

S=int!mathrm{d}^4xsqrt{-g}left(frac{M_P^2R}{2}-frac{g^{munu}partial_muphipartial_nuphi }{2}-frac{m^2(phi)phi^2}{2}-Vleft(phiright)right)+S_m.

$$

I gain the equations of motion using `xAct`

and its “addon” `xPand`

:

```
<< xAct`xPand`
$PrePrint = ScreenDollarIndices;
org(expr_) := NoScalar@Collect(ContractMetric(expr), $PerturbationParameter,ToCanonical)
collect(expr_) := NoScalar@Collect(expr, $PerturbationParameter, Identity)
order = 1;
DefManifold(M, 4, {(Alpha), (Beta), (Gamma), (Mu), (Nu), (Lambda), (Sigma)})
DefMetric(-1, g(-(Alpha), -(Beta)), CD, {";", "(Del)"}, PrintAs -> "!(*OverscriptBox((g), (_)))")
DefConformalMetric(g, a)
SetSlicing(g, n, h, cd, {"|", "(CapitalDifferentialD)"}, "FLFlat")
DefMetricFields(g, dg, h)
DefTensor(sf(), M, PrintAs -> "(Phi)")
DefTensorPerturbation(pertsf(LI(order)), sf(), M, PrintAs -> "(Delta)(Phi)")
DefScalarFunction(V)
DefScalarFunction(m)
DefConstantSymbol(massP, PrintAs -> "!(*SubscriptBox((m), (p)))")
L = Sqrt(-Detg() ) (massP^2/2 RicciScalarCD() -
1/2 CD(-(Beta))(sf()) CD((Beta))(sf()) - V(sf()) -
1/2 m(sf()) m(sf()) sf() sf())
varL = L // Perturbation // ExpandPerturbation // ContractMetric //
ToCanonical
0 == VarD(pertsf(LI(1)), CD)(varL)/Sqrt(-Detg()) /.
delta(-LI(1), LI(1)) -> 1 //
ToCanonical // ContractMetric(*Scalar EoM*)
```

Till here, everything seems to work fine. I get the eom:

$$

0=-m(phi)^2phi +nabla_anabla^aphi -m(phi)phi^2 m^prime(phi)-V^prime(phi)

$$

Now in the next step I get

```
eoms0c = Conformal(g, ga2)(%) // ToCanonical
```

$$

0=-m(phi)^2phi +frac{nabla_anabla^aphi}{a^2} +2frac{nabla_aphinabla^aa}{a^3} -m(phi)phi^2 m^prime(phi)-V^prime(phi)

$$

But something is off here. For instance, I should have a $3dot{phi}dot{a}/a$ term, but instead here I have a $2dot{phi}dot{a}/a^3$ term.

Does anyone see by any chance, what I did wrong? Or alternatively, another way to gain the perturbed equations of motion? Every reply is highly appreciated. Thank you very much in advance. ðŸ™‚