As I was studying refraction, I began wondering what path would light take when entering a non-homogeneous transparent medium, i.e. a certain material in which the refraction index $n$ varies (smoothly) through space: $n=n(x,y,z)$.
My guess is that the path chosen (let's forget Feynman QED for the time being) could be the one which minimizes travel time, so here's the mathematical question:
Q: Given a differentialble non-negative scalar field $\phi:\mathbb{R}^2\longrightarrow\mathbb{R}^+$ and a smooth (or at least $\mathcal{C}^1$) curve $\gamma:[0,1]\longrightarrow\mathbb{R}^2$ such that $\gamma(0)=P$ and $\gamma(1)=Q$ with $P,Q\in\mathbb{R}^2$, how to determine the time it takes to travel from $P$ to $Q$ assuming that in every point $\gamma(\lambda)=(x(\lambda),y(\lambda))$ the modulus of the speed is $\phi(x(\lambda),y(\lambda))$ and that the direction of travel never changes (i.e. we go directly from $P$ to $Q$ without stopping or going back for blueberries)?
In other words I impose the condition that \begin{equation} \|\frac{d\gamma(\lambda(t))}{dt}\|=\phi(\gamma(\lambda)) \end{equation}
I am confused by the dependency of $\gamma$ on time, and am unsure about what parametrisation of $\gamma$ should fit the case. Should it be arc length? Does it even matter? I cannot think clearly for some reason. Thank you!
You just need to invoke Fermat's principle: light travels the trajectory which minimizes the total time. Let $\tau$ be the total time spent by the light when it goes from $P$ to $Q$ under the curve $\gamma(s) = (q^1(s),q^2(s))$, then:
$ \tau = \int_P^Q dt = \int_P^Q \frac{dl}{v} = \frac{1}{c}\int_P^Q n(\mathbf{r})dl = \int_P^Q n(\mathbf{r(s)})\sqrt{g_{ij}\dot q^i(s)\dot q^j(s)}ds, $
where $c$ is the speed of light in the vacuum, $v$ is the speed of the light in a media with refractive index $n(\mathbf{r})$, $l$ is a physical length and $s$ a parameter. You can take $s$ to be arc length, but it would be harder to solve the minimization problem since we must do it while constraining $\|\gamma'(s)\|=1$. Just use the Euler-Lagrange equations for the lagrangian
$ L(q^i,\dot q^i) = n(\mathbf{r})\sqrt{g_{ij}\dot q^i\dot q^j}. $
By solving the Euler-Lagrange equations for the generalized coordinates $q^i$, you obtain the curve $\gamma$ that describes the trajectory of the light in the non-homogeneous media (which is your primary concerning). Moreover, you can calculate the total time $\tau$ by resolving the above integral along the curve you just find. At the end, just replace $\|\gamma'(s)\|$ by $\phi(\gamma(s))$.
About the parameter, remember that the length of a curve (and, therefore, the total time) doesn't depend on the specific parameter choice. Just pay attention on the domain of it (knowing its geometrical/physical meaning usually helps).