Solution (source code)

= Solution

For comoving galaxies their relative comoving vector $\boldsymbol\chi$ is constant, and the physical displacement is $\mathbf r(t)=a(t)\boldsymbol\chi$, where $a$ is the <scale factor>. Differentiating gives the <Hubble law>
$$
\boxed{\mathbf v=H\mathbf r,\qquad H=\frac{\dot a}{a}}.
$$
<Peculiar velocity> relative to this comoving frame is excluded in this relation.

Transport a wave crest between neighbouring comoving observers separated by a small physical distance $d\ell$. Their recession speed is $H\,d\ell$, while the light travel time is $dt=d\ell/c$ to first order. The local <Doppler shift> therefore changes its wavelength by $d\lambda/\lambda=H\,dt$. Multiplying these infinitesimal shifts along the ray, or integrating their logarithms, yields
$$
\log\frac{\lambda_0}{\lambda_e}
=\int_{t_e}^{t_0}H(t)\,dt
=\log\frac{a(t_0)}{a(t_e)},
\qquad \boxed{1+z=\frac{a(t_0)}{a(t_e)}}.
$$
The use of the local first-order Doppler law is exact in the limit of infinitesimal steps: the accumulated second-order errors tend to zero. A single special-relativistic recession velocity assigned to widely separated galaxies would not justify this <cosmological redshift> relation.