How is pressure calculated in the early universe? I'm trying to calculate the sound horizon from the start of time to decoupling. 
 To do this I need to know the speed of sound and how it changes as the universe grows.  The speed of sound in a fluid is:$$c_s^2=\frac{\partial p}{\partial \rho}$$Where $c_s^2$ is the speed of sound, $p$ is the pressure, $\rho$ is the density.  I think I have a handle on calculating the density:$$\rho(z)=\Omega_b h^2 \rho_{crit} (z+1)^3 \space g\space m^{-3}$$But I have no idea how you calculate the pressure.  I'm assuming that the pressure was mainly photonic up to the time of decoupling but I'm having trouble finding reference material.
Also, intuitively I would think that the pressure would fall in exact proportion to density since they're both related to the change in volume.  So is it enough just to find the pressure at the time of decoupling and divide by the density and use it as a constant?
 A: Before recombination baryons and photons are highly coupled and act like a single fluid, so the density is $\rho = \rho_{\rm bar} + \rho_\gamma$, with the usual scaling $\rho_{\rm bar} \sim (1 + z)^{3}$ and $\rho_{\gamma} \sim (1 + z)^{4}$. However, the pressure is the same for both components $P = P_{\rm bar} = P_{\gamma}$, this will lead to
$$
c_s^2 = \frac{c^2}{3}\left[\frac{3}{4}\frac{\rho_{\rm bar}}{\rho_\gamma} 
 + 1\right]^{-1} \tag{1}
$$
To derive this expression remember that in an uniform field $P_{\gamma} = \rho_\gamma c^2 / 3$ so that the adiabatic speed of sound is
$$
c_s^2 = \left( \frac{\partial P}{\partial \rho}\right)_S = \frac{c^2}{3} \left.\frac{\partial \rho_\gamma}{\partial(\rho_\gamma + \rho_{\rm bar})}\right|_S = \frac{c^2}{3}\left[1 + \left(\frac{\partial \rho_{\rm bar}}{\partial \rho_\gamma}\right)_S \right]^{-1}\tag{2}
$$
We need to calculate $(\partial \rho_{\rm bar}/\partial \rho_\gamma)_S$. And to do that we can use the fact that $\rho_{\rm bar}\sim a^{-3}$ and $\rho_{\gamma}\sim a^{-4}$ so 
$$
\frac{\partial \rho_\gamma}{\rho_\gamma} = -4 \frac{\partial a}{a} ~~~\mbox{and}~~~\frac{\partial \rho_{\rm bar}}{\rho_{\rm bar}} = -3 \frac{\partial a}{a}~~~\Rightarrow~~~ \frac{\partial \rho_{\rm bar}}{\partial \rho_\gamma} = \frac{3}{4}\frac{\rho_{\rm bar}}{\rho_\gamma} \tag{3}
$$
If you replace (3) in (2) you will get (1)
