Brachistochrone on a hemispherical ramp (source code)

= Brachistochrone on a hemispherical ramp
{title2=$\phi'^2=C^2\cos\theta/[\sin^2\theta(\sin^2\theta-C^2\cos\theta)]$}

Measure polar angle $\theta$ from the downward vertical on the lower hemisphere of radius $R$. A particle released from rest at the rim and sliding without energy loss has speed $\sqrt{2gR\cos\theta}$. The spherical <arc length> along $\phi=\phi(\theta)$ is $R\sqrt{1+\sin^2\theta\,\phi'^2}|d\theta|$. Thus its <travel time> has integrand proportional to $\sqrt{(1+\sin^2\theta\,\phi'^2)/\cos\theta}$. Since the azimuth is a <cyclic coordinate>, the <Euler-Lagrange equation> gives
$$
\frac{\sin^2\theta\,\phi'}{\sqrt{\cos\theta}\sqrt{1+\sin^2\theta\,\phi'^2}}=C.
$$
Solving for $\phi'^2$ gives the displayed <first integral> on a segment where $\theta$ is a valid path parameter. For finite $C$, approaching the rim $\theta\uparrow\pi/2$ gives $\phi'\to0$. Thus a regular stationary path begins along the meridian toward the bottom. This is an initial direction condition; a path joining other rim points can turn before reaching the bottom. Monotone segments use positive $|d\theta|$ in the time integral, and a turning point requires another path parameter or a split into segments.