Simple question related to Snell's law There are two media and they are stacked vertically like the figure below.
Medium 1 - height : h, refractive index : $n_1$
Medium 2 - height : h, refractive index : $n_2$
A laser beam travels through these media from the left-top corner with the initital incident angle $\theta_1$.
Is it possible to analytically determine the horizontal distance the laser beam moves forward when it reaches the bottom?
*$\theta_2$ can't be included in the answer.

 A: I belive the answer is given by $$ d = h [\tan \theta_1 + \tan \theta_2]$$ each term giving you thee horizontal distance travelled for each medium.
Now, according to Snell's law $$\frac{\sin \theta_1}{\sin \theta_2} = \frac{n_1}{n_2}$$ so $$\theta_2 = \arcsin \left(\sin \theta_1 \cdot \frac{n2}{n1}\right)$$ and upon substituing $$ d = h \left[\tan \theta_1 + \tan \,\arcsin \left(\sin \theta_1 \cdot \frac{n2}{n1}\right)\right] $$
A: You can also use Fermat's Principle of Least Time. The Index of Refraction of a medium is the ratio of the speed of light in a vacuum to the speed of light in the medium. So a light beam will travel a distance $d$ in $\frac{nd}{c}$ seconds, where $n$ is the index of refraction and $c$ is the speed of light in a vacuum.
There is a constraint on the vertical distance traveled. You can have one variable to represent the horizontal length from the wall where the media meet, and another to represent the horizontal distance of the final point. Apply the pythagorean to figure out the lengths as a function of those two variables. 
Lagrange multipliers should give a relation between the two variables. Once you know the one in the middle, you know the one on the far side and vice versa. 
