Solution (source code)

= Solution

Subtracting the baryon equation from the cold-dark-matter equation cancels their common gravitational source and gives the <baryon--cold-dark-matter relative density mode>
$$
\boxed{\ddot D+2H\dot D=0},
\qquad D=\delta_c-\delta_b.
$$
Because the background fractions $\bar\rho_c/\bar\rho_m$ and $\bar\rho_b/\bar\rho_m$ are constant after recombination, their weighted sum gives
$$
\boxed{\ddot\delta_m+2H\dot\delta_m
-4\pi G\bar\rho_m\delta_m=0}.
$$
During matter domination, $a\propto t^{2/3}$. The first equation gives $a^2\dot D=\text{constant}$ and hence
$$
\boxed{D=D_0+D_1a^{-1/2}}.
$$
The <cosmic-time matter density modes> give
$$
\boxed{\delta_m=Aa+Ba^{-3/2}}.
$$
Solving the definitions for the individual contrasts,
$$
\delta_c=\delta_m+\frac{\bar\rho_b}{\bar\rho_m}D,
\qquad
\delta_b=\delta_m-\frac{\bar\rho_c}{\bar\rho_m}D,
$$
so
$$
\frac{\delta_c}{\delta_b}
=\frac{\bar\rho_m\delta_m+\bar\rho_bD}
{\bar\rho_m\delta_m-\bar\rho_cD}
\longrightarrow\boxed{1}.
$$
Thus $\boxed{f=1}$. Both species feel the same gravitational potential after baryon pressure becomes negligible; the growing total mode overtakes the constant relative mode, so baryons catch up with cold dark matter.