Solution (source code)

= Solution

Regard the <refraction angle> as a function of the <angle of incidence>, $\beta=\arcsin(\sin\alpha/n)$. <Implicit differentiation> of <Snell's law> gives $\beta'=\cos\alpha/(n\cos\beta)$. Differentiating the <deviation angle> gives $\delta'=2-4\beta'$. An interior <stationary point> therefore satisfies
$$
\boxed{\cos\alpha=\frac n2\cos\beta,\qquad A=2.}
$$
The <stationary deviation of a primary rainbow ray> is a minimum: differentiating $\cos\alpha=n\cos\beta\,\beta'$ again and using <Snell's law> gives $\beta''=\tan\beta((\beta')^2-1)$. At the <stationary point>, $\beta'=1/2$, and hence $\delta''=-4\beta''=3\tan\beta>0$ for a positive interior <refraction angle>. This minimum is responsible for the concentration of emerging <light rays> near the primary <rainbow> direction.