# Is the energy density due to radiation inversely proportional to the volume of the universe?

For example, if you take a cube of length $l$ containing a photon $r$ with frequency $\nu$, you can calculate the energy density as

$$\rho_{r,1} = \frac{h \nu}{l^3}$$

Now imagine that the universe expands, such that the size of the box is now $al$. The number of photons inside the box (1) remains unchanged. Does the energy density inside the box then become

$$\rho_{r,2} = \frac{h \nu}{(al)^3} = \frac{1}{a^3}\frac{h \nu}{l^3} = a^{-3}\rho_{r,1}$$

? That is, does the energy density associated with radiation $r$ change with the scale of the universe according to

$$\rho_R \sim a^{-3}$$

?

There's one additional effect, that the frequency of the photons drops as $a^{-1}$ with expansion (the 'cosmological redshift') . Since the photon energy is $E=h\nu$, the radiation energy density is $\propto a^{-4}$.