Solution (source code)

= Solution

The integrand $f=n(x)\sqrt{1+(y')^2}$ has no explicit dependence on $y$, so part (i) gives
$$
\frac{n(x)y'}{\sqrt{1+(y')^2}}=c.
$$
For positive <refractive index> and a regular graph with $n(x)>|c|$, squaring and then restoring the sign of $y'$ yields
$$
\boxed{\frac{dy}{dx}=\frac{c}{\sqrt{n(x)^2-c^2}}.}
$$
It is the continuous-medium version of <Snell's law>, expressing conserved horizontal optical momentum. The <Euler-Lagrange equation> establishes stationarity; on a monotone-height segment, convexity of the integrand in $y'$ also gives a minimum among graphs with fixed endpoints.