Solution (source code)

= Solution

Assume $c(y)>0$ is differentiable along the ray, with sufficient regularity for the following variation, and fix the endpoints. <Fermat principle> makes the travel time stationary:
$$
T[y]=\int\frac{\sqrt{1+y'^2}}{c(y)}\,dx.
$$
For the variational <integrand> $f=\sqrt{1+y'^2}/c$, the <Euler-Lagrange equation> is
$$
\frac{d}{dx}\left[\frac{y'}{c\sqrt{1+y'^2}}\right]+\frac{c'}{c^2}\sqrt{1+y'^2}=0.
$$
Expanding the <derivative> and multiplying by $c^2(1+y'^2)^{3/2}$ gives
$$
c y''-c'y'^2(1+y'^2)+c'(1+y'^2)^2=0,
$$
and therefore
$$
\boxed{c(y)y''+c'(y)(1+y'^2)=0.}
$$
Equivalently, the <Beltrami identity> gives $1/[c(y)\sqrt{1+y'^2}]=\text{constant}$. Mere continuity of $c$, as stated in the wording, does not by itself justify the appearance of $c'$; the displayed classical ray equation requires this additional differentiability.