Solution (source code)

= Solution

With equal allocation and true alternative rates $\lambda_T,\lambda_C$, the asymptotic variance is
$$
V_A=\frac2N\left(\frac1{\lambda_T}+\frac1{\lambda_C}\right).
$$
The normal approximation requires $|\log RR_A|/\sqrt{V_A}\geq z_{1-\alpha/2}+z_{1-\beta}$. Hence
$$
N=\frac{2(z_{1-\alpha/2}+z_{1-\beta})^2}
{(\log RR_A)^2}
\left(\frac1{\lambda_T}+\frac1{\lambda_C}\right),
$$
rounded upward. Writing $\lambda_T=RR_A\lambda_C$ expresses it using a specified control rate and the target rate ratio.