# Equation of Motion: Perturb Scalar Field and flat FLRW Metric (xAct)

Is there a way to get the equations of motion (eom) of a scalar field from a Lagrangian in a perturbed FLRW metric? I want to perturb the field as well as the metric to 1st order. What I did so far:

1. I derived the eom using xAct without specifying a metric.
2. I tried using xPand, but wasn't convinced by my result:

$$S=\int\!\mathrm{d}^4x\sqrt{-g}\left(\frac{M_P^2R}{2}-\frac{g^{\mu\nu}\partial_\mu\phi\partial_\nu\phi }{2}-\frac{m^2(\phi)\phi^2}{2}-V\left(\phi\right)\right)+S_m.$$

I gain the equations of motion using xAct and its "addon" xPand:

<< xActxPand
$$PrePrint = ScreenDollarIndices; org[expr_] := NoScalar@Collect[ContractMetric[expr],$$PerturbationParameter,ToCanonical]
collect[expr_] := NoScalar@Collect[expr, \$PerturbationParameter, Identity]
order = 1;
DefManifold[M, 4, {α, β, γ, μ, ν, λ, σ}]
DefMetric[-1, g[-α, -β], CD, {";", "∇"}, PrintAs -> "\!$$\*OverscriptBox[\(g$$, $$_$$]\)"]
DefConformalMetric[g, a]
SetSlicing[g, n, h, cd, {"|", "\[CapitalDifferentialD]"}, "FLFlat"]
DefMetricFields[g, dg, h]
DefTensor[sf[], M, PrintAs -> "ϕ"]
DefTensorPerturbation[pertsf[LI[order]], sf[], M, PrintAs -> "δϕ"]
DefScalarFunction[V]
DefScalarFunction[m]
DefConstantSymbol[massP, PrintAs -> "\!$$\*SubscriptBox[\(m$$, $$p$$]\)"]
L = Sqrt[-Detg[] ] (massP^2/2 RicciScalarCD[] -
1/2 CD[-β][sf[]] CD[β][sf[]] - V[sf[]] -
1/2 m[sf[]] m[sf[]] sf[] sf[])
varL = L // Perturbation // ExpandPerturbation // ContractMetric //
ToCanonical
0 == VarD[pertsf[LI], CD][varL]/Sqrt[-Detg[]] /.
delta[-LI, LI] -> 1 //
ToCanonical // ContractMetric(*Scalar EoM*)


Till here, everything seems to work fine. I get the eom: $$0=-m(\phi)^2\phi +\nabla_a\nabla^a\phi -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)^2\phi +\frac{\nabla_a\nabla^a\phi}{a^2} +2\frac{\nabla_a\phi\nabla^aa}{a^3} -m(\phi)\phi^2 m^\prime(\phi)-V^\prime(\phi)$$

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

1. I'm trying to use xCoba, but I couldn't figure out how to do the perturbation of the field. Is there a way to use the metric-independent expression of xAct and re-evaluate it given a metric?