# Determining the path of a light ray

Let's consider a ray in the plane $xy$. Let the refractive index be defined in any point of the plane with the function $n(x,y)$.

In time $t=0$ the ray is located in coordinates $(x_0, y_0)$ and its direction makes the angle $\alpha_0$ with the $OX$ axis.

What is the path of the ray as a function $y(x)$? Can we determine the path as a function $y(t), x(t)$

Example values: $x_0 = 7, y_0 = 10, \alpha_0 = \frac \pi 4,~~ n(x,y) = x^2 + y^2+3$

You need to learn about the Eikonal equation and the equivalent ray path equation, which I talk about in my answer to the question Physics SE question "Ray tracing in a inhomogeneous media", and, if you need to know how it comes as the *slowly varying envelope approximation" from Maxwell's Equations, I talk about this in my answer to the question , "Optics: Derivation of $\nabla n=\mathrm{d}_s n(s) \hat{u}(s)$".

Basically the equation you need is describes the the parametric equation for the position vector $\vec{r}(s)$ (where $s$ is a parameter for the path traced out by $\vec{r}:\mathbb{R}\to\mathbb{R}^3$) and it is:

$$\frac{\mathrm{d}}{\mathrm{d}\,s}\left(n\left( \mathbf{r}\left(s\right)\right)\,\frac{\mathrm{d}}{\mathrm{d}\,s} \mathbf{r}\left(s\right)\right) = \left.\nabla n\left( \mathbf{r}\right)\right|_{\mathbf{r}\left(s\right)}\tag{1}$$

where $n$ is the refractive index as a function of the position $\vec{r}(s)$. This is equivalent to Snell's law and Fermat's principle of least time. If $s$ is the pathlength along the curve, then $\mathrm{d}_s\vec{r}(s)$ reduces to the unit vector tangent to the path.

In your case, we're confined to a 2D plane, so you'll use two equations for $x(s)$ and $y(s)$ and $\nabla n = 2(x(s), y(s))$. So you need to subsitute these expressions into (1) and see how you fare. You'll get two coupled DEs for $x(s)$ and $y(s)$, which you should be able to eliminate $s$ from.