Lagrangian density for flat space time The lagrangian density of a classical scalar  field is given as $$\mathcal{L}=\frac{1}{2}\partial_{\mu}\phi \partial^{\mu}\phi -V(\phi).$$
For a flat and homogenous space time the FRW metric is $g_{\mu \nu}=diag(-1, a(t)^2,a(t)^2,a(t)^2)$. How the Lagrangian density is simplified to $$\mathcal{L}=\frac{1}{2}\dot\phi^2-V(\phi)~?$$
 A: There are two common conventions that can be confusing across sources,

*

*$+---$ viz. $g_{\mu\nu}=\operatorname{diag}(1,\,-a^2,\,-a^2,\,-a^2)$ and

*$-+++$ viz. $g_{\mu\nu}=\operatorname{diag}(-1,\,a^2,\,a^2,\,a^2)$.

In both cases, the inverse metric just replaces $a^2$ with $a^{-2}$.
Given $\partial_i\phi=0$ (homogeneity), these conventions respectively write $\dot{\phi}^2$ as $\partial_0\phi\partial^0\phi=\partial_\mu\phi\partial^\mu\phi$ and $-\partial_0\phi\partial^0\phi=-\partial_\mu\phi\partial^\mu\phi$.
Putting relativity aside for the moment, $\dot{\phi}^2$ should have a positive coefficient in $\mathcal{L}$ so a time-dependence in $\phi$ has a kinetic cost. (We're trying to minimize action, after all.) So in the $-+++$ convention,$$\mathcal{L}=-\tfrac12\partial_\mu\phi\partial^\mu\phi-V(\phi).$$
A: This is just a matter of the metric sign convention.  The Lagrange density for the $(+{} -{} -{} -)$ convention is
$$
\mathcal{L} = \partial_\mu \phi \partial^\mu \phi - V(\phi)
$$
but for the $(-{} +{} +{} +)$ convention, it is
$$
\mathcal{L} = -\partial_\mu \phi \partial^\mu \phi - V(\phi)
$$
It is not hard to see that these two densities are the same if you write out the kinetic term in terms of derivatives with respect to time and space.
More generally, given a Lagrangian density defined under one sign convention in a fixed spacetime background, we can switch to the other sign convention by making the substitution $g_{\mu \nu} \to - g_{\mu \nu}$.
