Solution (source code)

= Solution

The <angles> in the PDF are measured from the vertical normal to the interface. The horizontal displacements of the two path segments are $d_1\tan\theta$ and $d_2\tan\phi$, while their <lengths> are $d_1\sec\theta$ and $d_2\sec\phi$. Thus the geometric constraint and travel <time> are
$$
g(\theta,\phi)=d_1\tan\theta+d_2\tan\phi=D,\qquad T(\theta,\phi)=\frac{2d_1\sec\theta+\sqrt2d_2\sec\phi}{c}.
$$
The <Lagrange multiplier> equations $\nabla T=\lambda\nabla g$ give
$$
\frac{2d_1}{c}\sec\theta\tan\theta=\lambda d_1\sec^2\theta,\qquad\frac{\sqrt2d_2}{c}\sec\phi\tan\phi=\lambda d_2\sec^2\phi.
$$
Cancelling the positive geometric factors gives $\lambda=2\sin\theta/c=\sqrt2\sin\phi/c$, hence
$$
\boxed{\sin\phi=\sqrt2\sin\theta.}
$$
This is <Snell's law>, $\sin\theta/(c/2)=\sin\phi/(c/\sqrt2)$. The relation depends only on the ratio of the two <speeds>, so changing $D,d_1,d_2$ leaves the relation unchanged; it changes which <angles> satisfy it together with the geometric constraint.

For a minimum check, let $u$ be the horizontal distance to the crossing <point>. Then
$$
T(u)=\frac2c\sqrt{u^2+d_1^2}+\frac{\sqrt2}{c}\sqrt{(D-u)^2+d_2^2},
$$
and
$$
T''(u)=\frac{2d_1^2}{c(u^2+d_1^2)^{3/2}}+\frac{\sqrt2d_2^2}{c((D-u)^2+d_2^2)^{3/2}}>0.
$$
Thus the travel <time> is a <strictly convex function> of $u$, and its <stationary point> is the unique global minimum. For positive $D,d_1,d_2$, $T'(0)<0<T'(D)$, placing the crossing between the two endpoint projections.