How does the scale factor depend on temperature? So, I'm studying cosmology and my professor often uses the result $a=\frac{T}{T_0}$, but he never derived this relation and he just treates it as something intuitive... I think I can see how this would make sense, but I'd like to get a more formal understanding of it. Any light on this will be much appreciated. Thanks!
 A: I think you are referring to the temperature of the cosmic microwave background? In which case, the derivation arises from Wien's law for a blackbody distribution, which connects the temperature of the blackbody with the peak wavelength of the intensity vs wavelength distribution. As the universe expands, this wavelength increases along with all other length scales according to the scale factor $a(t)$. Then, since Wien's law is that the temperature is inversely proportional to the wavelength at the peak of the intensity distribution, then $T \propto a^{-1}$. Hence
$$ \frac{T}{T_0} = \frac{a_0}{a}$$
and since $a_0=1$, we have the exact inverse of what your Professor (allegedly) says. I'm fairly confident that I'm right since the temperature is higher for smaller scale factors...
Another way of looking at this is that the redshifting of light of all wavelengths according to the scale factor does not affect the shape of the blackbody distribution. In which case, the energy density of a blackbody scales as $T^4$, but since the volume changes as $a^3$ and the photon energies change as $hc/\lambda \propto a^{-1}$, then for a fixed number of photons, the energy density scales as $a^{-4}$. Hence $T \propto a^{-1}$ as before.
A: This relation refers to the era of what is often called the Hot Big Bang, or simply the era before recombination. It is characterized by

*

*All species of particles (matter, radiation), being in thermal equilibrium. In that case we may assume a single $T$ for the entire Universe.

*The Universe being radiation dominated.

From this we can derive $T/T_0  = a_0/a$ as follows.
Since the Universe is dominated by radiation and is in thermal equilibrium, all of the species can be summed into a single effective fluid with energy density $\varepsilon$ and the pressure fulfilling approximately $P = \varepsilon/3$. Then, from conservation of stress-energy we get
$$\frac{\varepsilon}{\varepsilon_0} = \left(\frac{a_0}{a} \right)^{4}$$
Now in any referential coordinate volume $V$ we have the entropy
$$S = \frac{(\varepsilon + P)V}{T} = \frac{\varepsilon(1 + w)}{T}$$
Every volume expands as
$$\frac{V}{V_0} = \left(\frac{a}{a_0}\right)^3$$
and we assume that the expansion is adiabatic, i.e., it keeps $S$ constant. Combining these two pieces of information, we finally get
$$\frac{T}{T_0} = \frac{a_0}{a}$$
Note, as mentioned by ProfRob, that if you have a massless field that is out of thermal equilibrium with other mass/energy species, its temperature will also follow this scaling. However, keeping track of the cosmic expansion using temperature is really only done in the case before thermal equilibrium is broken.
A: There is a result the same as your professor's here
https://www.ita.uni-heidelberg.de/~pcc/dark_ages_script.pdf?lang=en
section 1.6, Thermal History, near equation (37).  You can decide what aspect of temperature your professor was referring to.
The first two lines of that section say
"How does the temperature change as the Universe expands?
The answer to this differs, depending on whether we are considering radiation or non-relativistic matter."
