Consider a ray of light travelling between two points A and B on the $xy$ plane. Using the calculus of variations and Fermat's Principle we can derive equations which give the trajectory of a ray of light through a medium of given refractive index $n(y)$ by minimising,
\begin{equation}
T = \int n(y) \sqrt{1+{\Big(\frac{dy}{dx}\Big)}^2}dx
\end{equation}
and using the Euler-Lagrange equations we arrive quickly at an integral expression for the trajectory as
\begin{equation}
x = \int \frac{\alpha\> dy}{\sqrt{{n(y)^2-\alpha}^2}}
\end{equation}
with $\alpha$ as some arbitrary constant based on initial conditions.
Now consider the refractive index of the medium to be $\> n(y)= n_0 \cos(ky)$.
At this point I can't seem to progress; Is this integral solvable with this continuously varying index? Is this the correct approach or is there a more convenient way to find the trajectory?