Refraction of light in medium Given that the plane $y=0$ separates the vacuum ($y>0$) from the optical medium ($y<0$), I would like to calculate the trajectory of a light ray starting at the point $(x_1,y_1)$ and ending in $(x_2,y_2)$ where $x_2>x_1$ and $y_1>0>y_2$. Specifically, I would like to find the point $(x,0)$ at which the light enters the medium. However, using Snell's law, I obtain an equation of fourth degree in $x$. Is there a smarter way of doing this?
 A: You're right - this sounds simple but its much trickier than it looks. Actually the quartic nature of the equation shouldn't be too surprising: ray tracing softares have to  use iterative ray aiming methods to get a ray to go through two fixed endpoints. It's not the standard problem to have fixed enpoints like this.
Your approach is sound but I can't simplify it either and Mathematica gives birth to a monster! I had more joy with the following approach:
Instead of $x$, make the length $\ell$ of the first ray segment (from the beginning point to the medium) your independent variable. Then Snell's law is:
$$\frac{1}{\ell} \sqrt{\ell^2-y_1^2}=\frac{n}{\ell_2}\,\sqrt{\ell_2^2-y_2^2}\quad\quad\quad(1)$$
where $\ell_2$ is the length of the second ray segment. The "width" of the problem $w = x_2-x_1$ is:
$$w = \sqrt{\ell^2-y_1^2} + \sqrt{\ell_2^2-y_2^2}\quad\quad\quad(2)$$
Now the total optical path length is $\ell + n\,\ell_2$, so it is tempting at this point to use Fermat's principle with this simple expression and minimize including constraint (2) with a Lagrange multiplier so that we get $1 + \lambda \partial_\ell w = n + \lambda \partial_{\ell_2} w = 0$ and solve for $\ell$ and $\ell_2$. This comes out easy enough: the trouble begins when you put your solutions back into (2) to solve for the Lagrange multiplier.
So, instead of using a Lagrange multiplier, I tried substituting (1) straight into (2), yielding:
$$w = \sqrt{\ell^2-y_1^2}\,\left(1+\frac{\ell_2}{n\,\ell}\right)\quad\quad\quad(3)$$
then solving (3) for $\ell_2$, thus deriving an expression for the total optical path length in terms of $\ell$ alone:
$$L = n\, \ell_2 + \ell = \ell\left(1-n^2+\frac{n^2\,w}{\sqrt{\ell^2-y_1^2}}\right)$$
and then solving ${\rm d}_\ell L = 0$. This is still a fairly thorny quartic, but with one positive real root, which is:
$$\ell = \sqrt{\frac{\left(n^2-1\right)^2 y_1^2+\sqrt[3]{n^4
   \left(n^2-1\right)^4 w^2 y_1^4}}{\left(n^2-1\right)^2}}$$
whence:
$$x = \frac{(n\,y_1)^{\frac{2}{3}}\,w^{\frac{1}{3}}}{(n^2-1)^{\frac{1}{3}}} + x_1 = \frac{(n\,y_1)^{\frac{2}{3}}\,(x_2-x_1)^{\frac{1}{3}}}{(n^2-1)^{\frac{1}{3}}} + x_1$$
A: Well, why not use Fermat's principle to solve it, by calculating the optical distance
 (s x N) between the start and end points, and solving for a minimum  ??
