# Deriving energy Conservation for matter from Friedmann equations using continuity equation

Define:

$$\rho \qquad \text{Density}$$

$$P \qquad \text{ Pressure}$$

$$H=\frac 1 a \frac{da}{dt} \qquad \text {Hubble Factor}$$

Assuming FRW metric, then from the Friedmann equations we get (for a perfect fluid Universe):

$$\frac{d\rho}{dt} = -3H(\rho+P) \qquad \text{Continuity Equation}$$

How do I prove: $$dE=-PdV$$

where $dE=\frac{d(\rho L^3 a^3)}{dt}$ is the energy inside a volume element $dV=a^3 L^3$ of co-moving size $L^3$

The key here is to substitute the Hubble factor and multiply by $a^3$:

$$a^3 \frac{d\rho}{dt} = -3a^2 \frac{da}{dt}(\rho+P)$$

and after some arrangements,

$$a^3 \frac{d\rho}{dt} +3a^2 \frac{da}{dt}\rho = -3a^2 \frac{da}{dt}P$$

$$\frac{d}{dt} (a^3 \rho) = -P \frac{d}{dt} (a^3)$$

$$\frac{d}{dt} (L^3 a^3 \rho) = -P \frac{d}{dt} (L^3 a^3)$$

you recover the well-known thermodynamic relation. In the last step I have used that $L$ is independent of $t$ (the co-moving time).