Path of a light ray in a medium of varying refractive index [closed]

How do we get the equation for the path of a light ray in a medium of varying refractive index.

I can draw a rough sketch, but don't know how do we get the exact curve.

I encountered this while doing a problem:

A ray of light travelling in air makes a grazing incidence on a rectangular slab of transparent medium with one vertex at the origin & (sides along x and y axes.)

The refractive index of the material varies as $N=2x$. The path of the light ray is given by?

(The ray makes a grazing incidence nearly parallel to x axis from -ve to +ve x axis but just enough to enter the first quadrant; where the slab lies.)

-

closed as off-topic by NowIGetToLearnWhatAHeadIs, MAFIA36790, Kyle Kanos, ACuriousMind, Qmechanic♦Oct 3 '15 at 18:56

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "Homework-like questions should ask about a specific physics concept and show some effort to work through the problem. We want our questions to be useful to the broader community, and to future users. See our meta site for more guidance on how to edit your question to make it better" – NowIGetToLearnWhatAHeadIs, MAFIA36790, Kyle Kanos, ACuriousMind, Qmechanic
If this question can be reworded to fit the rules in the help center, please edit the question.

Just use snell's law, that is, $\mu \,\sin\theta$=constant, where $\mu$ denotes the refractive index and $\theta$ is the angle between the ray and the normal between a generic point and the point of incidence.The rest is math, you need to express $\sin\theta$ in terms of the slope at that point and solve the resulting differential equation.