Solution (source code)

= Solution

For the flat <FRW metric>, $g^{00}=-1$, $g^{0i}=0$, and $g^{ij}=a^{-2}\delta^{ij}$. Consequently the kinetic contraction of the <scalar field> is
$$
g^{\alpha\beta}\partial_\alpha\phi\partial_\beta\phi
=-\dot\phi^2+a^{-2}|\nabla\phi|^2,
\qquad
\mathcal L=\frac12\dot\phi^2-\frac12a^{-2}|\nabla\phi|^2-V.
$$
Inserting this in $T^{\mu\nu}=\partial^\mu\phi\partial^\nu\phi+g^{\mu\nu}\mathcal L$, with $\partial^0\phi=-\dot\phi$ and $\partial^i\phi=a^{-2}\partial_i\phi$, gives
$$
\boxed{T^{00}=\frac12\dot\phi^2+\frac12a^{-2}|\nabla\phi|^2+V,}
$$
$$
\boxed{T^{0i}=-a^{-2}\dot\phi\,\partial_i\phi,}
$$
$$
\boxed{T^{ij}=a^{-4}\partial_i\phi\partial_j\phi+
 a^{-2}\delta^{ij}\left(\frac12\dot\phi^2-\frac12a^{-2}|\nabla\phi|^2-V\right).}
$$
These are contravariant coordinate components of the <stress-energy tensor>; spatial components in an orthonormal frame carry different powers of $a$. In particular $T^{00}$ is the <energy density> seen by the comoving observer.