If there is a density function or refractive index function (continous) , can i find out the path of the light just solving Euler's equation

?

where is defined as the total time for the light travelling from O to (a , y(a))

Since F is independent of x the equation leads to another equation :

then