Solution (source code)

= Solution

The <age of an FLRW universe> at an epoch is the elapsed <cosmic time> since the <Big Bang>, not the lookback time from today. For positive matter and positive <cosmological constant>, integrating $dt=da/\dot a$ gives
$$
t(a)=\frac1{H_0}\int_0^a\frac{\sqrt{a'}\,da'}
{\sqrt{\Omega_{m,0}+\Omega_{\Lambda,0}a'^3}}.
$$
Put $u=\sqrt{\Omega_{\Lambda,0}/\Omega_{m,0}}\,a'^{3/2}$; then $du=(3/2)\sqrt{\Omega_{\Lambda,0}/\Omega_{m,0}}\sqrt{a'}\,da'$. The integral becomes the <age of a flat matter-Lambda universe>:
$$
t(a)=\frac{2}{3H_0\sqrt{\Omega_{\Lambda,0}}}
\int_0^{\sqrt{\Omega_{\Lambda,0}/\Omega_{m,0}}\,a^{3/2}}
\frac{du}{\sqrt{1+u^2}}
=\frac{2\operatorname{arsinh}\!\left(\sqrt{\Omega_{\Lambda,0}/\Omega_{m,0}}\,a^{3/2}\right)}
{3H_0\sqrt{\Omega_{\Lambda,0}}}.
$$
Choose $0<\theta<\pi/2$ such that $\tan\theta=\sqrt{\Omega_{m,0}/\Omega_{\Lambda,0}}\,a^{-3/2}$. The upper-limit value of $u$ is $\cot\theta$, and
$$
\operatorname{arsinh}(\cot\theta)
=\log(\cot\theta+\csc\theta)
=\log\frac{1+\cos\theta}{\sin\theta}.
$$
Consequently
$$
\boxed{t(z)=\frac{2}{3H_0\sqrt{\Omega_{\Lambda,0}}}
\log\frac{1+\cos\theta}{\sin\theta},
\qquad \tan\theta=\sqrt{\frac{\Omega_{m,0}}{\Omega_{\Lambda,0}}}(1+z)^{3/2}.}
$$
The integration constant is fixed by $t\to0$ as $z\to\infty$, where $\theta\to\pi/2$. Equivalently, differentiating $u=\cot\theta$ changes the last integral to $-\int d\theta/\sin\theta$, recovering the supplied trigonometric identity. The formula assumes positive $\Omega_{\Lambda,0}$ and $\Omega_{m,0}$; its zero-vacuum limit is regular even though this parametrization is singular.