Solution (source code)

= Solution

For a flat universe containing only the stated fluid, the <cosmological continuity equation> is $\dot\rho+3H(\rho+P)=0$. A constant <equation-of-state parameter> $w$ therefore gives $\rho=\rho_0(a/a_0)^{-3(1+w)}$. Combine this with the <Friedmann equation> $H^2=8\pi G\rho/3$ to find
$$
\dot H=-\frac32(1+w)H^2.
$$
On the expanding branch, specifying $H(t_0)=H_0>0$ yields
$$
\boxed{H(t)=\frac{H_0}{1+\frac32(1+w)H_0(t-t_0)},\qquad
\rho(t)=\frac{3H(t)^2}{8\pi G},\qquad q=-\frac{\ddot a}{aH^2}=\frac{1+3w}{2}.}
$$
The solution is used only where its denominator is positive. For $w\ne-1$, integration also gives
$$
\frac{a(t)}{a_0}=\left[1+\frac32(1+w)H_0(t-t_0)\right]^{2/[3(1+w)]}.
$$
For $w>-1$, choosing the zero of time at the initial singularity gives $H=2/[3(1+w)t]$ and $\rho=1/[6\pi G(1+w)^2t^2]$. For $w=-1$, $H=H_0$, $\rho$ is constant and $a=a_0e^{H_0(t-t_0)}$. For $w<-1$, the displayed initial-value solution instead grows towards a future finite-time singularity; it is not the ordinary positive-time Big Bang branch. With positive density, \b[accelerated expansion requires $w<-1/3$.]