If I have an optical transparent slab with refractive index $n$ depending on the distance $x$ from the surface of the slab, the refractive index can be described by: $$n(x)=f(x)$$ where $f(x)$ is a generic function of $x$. so, we can write: $$\dfrac{dn(x)}{dx}=f'(x)$$ The snell law of refraction states: $$n_1\sin(\theta_1)=n_2\sin(\theta_2)$$ How can I write the equation of the ray tracing through the slab? Thanks


2 Answers 2


A complete treatment of your question (more than you ever wanted) is given here, especially section 2.1.1 "Differential equation of light rays in inhomogeneous media". Trying to extract the most useful expression from that dissertation, I believe that the equation you are looking for is:

$$\nabla \Phi a = \frac{2\pi}{\lambda}n(R)$$

$\Phi$ = phase
$R$ = position vector
$a$ = unit vector pointing along ray

With a bit of manipulation, that turns into

$$\frac{d}{ds}\left(n\frac{dR}{ds}\right) = \nabla n$$ (equation 2.1.8 in the above reference).

The factor $ds$ can be a bit tricky since it is pointing along the ray - if you want things in X,Y coordinates then you need to worry about the length of $ds$ when it is no longer at a small angle to the X axis - it becomes $\sqrt{dx^2+dy^2}$


You need to learn about the Eikonal equation and its implications. When the electromagnetic field vectors are locally plane waves, i.e. over length scales of several wavelengths and less they are well approximated by plane waves, then the phase of either $\vec{E}$ or $\vec{H}$ (or of $\vec{A}$ and $\phi$ in Lorenz gauge) can be approximated by one scalar field $\varphi(x,\,y,\,z)$ which fulfils the Eikonal equation:

$$\left|\nabla \varphi\right|^2 = \frac{\omega^2\,n(x,\,y,\,z)^2}{c^2}$$

where, of course, $n(x,\,y,\,z)$ describes your refractive index as a function of position. This equation can be shown to be equivalent to Fermat's principle of least time and also implies Snell's law across discontinuous interfaces. The ray paths are the flow lines (exponentiation) of the vector field defined by $\nabla\,\varphi$. Otherwise put: the rays always point along the direction of maximum rate of variation of $\varphi$, whilst the surfaces normal to the rays are the surfaces of constant $\varphi$, i.e. the phase fronts. A little fiddling with the Eikonal equation shows that the parametric equation for a ray path, i.e. $\vec{r}(s)$ as a function of the arclength $s$ along the path is defined by:

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

This is where you can take things up. You have $n(x,y,z)$ depends only on $x$, so $\nabla n$ will always be in the $\vec{x}$ direction. Everything stays on one plane; let this be the $x-z$ plane and the position of the point on the path is $(x(s),\,z(s))$. We thus get two nonlinear DEs which can be quite hard to solve:

$$\frac{{\rm d}\,n(x)}{{\rm d} s}\,\frac{{\rm d}\,x}{{\rm d} s} + n(x)\, \frac{{\rm d}^2 x}{{\rm d} s^2} = n^\prime(x)$$

$$\frac{{\rm d}\,n(x)}{{\rm d} s}\,\frac{{\rm d}\,z}{{\rm d} s} + n(x)\, \frac{{\rm d}^2 z}{{\rm d} s^2} = 0$$

so you generally need to make some approximation depending on what kind of ray you are dealing with. In fibre optics, for example, you may want to assume that the rays make small angles with the $z$ direction so that $s\approx z$, whence you would get:

$$\frac{{\rm d}\,n(x(z))}{{\rm d} z}\,\frac{{\rm d}\,x(z)}{{\rm d} z} + n(x)\, \frac{{\rm d}^2 x}{{\rm d} s^2} = n^\prime(x)$$

and then you would need to make further approximations depending on the fibre profile.

A good reference for all this is Born and Wolf, Principles of Optics, Chapter 4 or the first half of Snyder and Love, Optical Waveguide Theory.

  • $\begingroup$ Are there any commercial or open source software that you know of that can do this sort of thing? If I load in some sort of n(r) distribution and it can ray trace through? $\endgroup$
    – John M
    Commented Mar 11, 2017 at 21:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.