Snell's law
To find out the optimal path of light, we must first assume that \( A=(a,b) \) lies over the \(x\)-axis and that \( B=(c,d) \) lies below the \(x\)-axis, as depicted in the image below:
To minimize the travel time from \(A\) to \(B\), we need to find the point \(C=(x,0)\) on the \(x\)-axis. We assume that the velocity on the \(x\)-axis is \(v_{1}\), while below the \(x\)-axis it is \(v_{2}\). Since we can derive time from velocity, we seek the point \(C\) that satisfies this condition.
$$\mathrm{time = \frac{distance}{velocity}},$$
so the travel time is
$$T\left( x \right) = \frac{\sqrt{\left(x - a\right)^{2} + b^{2}}}{v_{1}} + \frac{\sqrt{\left(x - c\right)^{2} + d^{2}}}{v_{2}}.$$
If we calculate the derivative and set it equal to \( 0 \), we have
$$\frac{\frac{1}{2}\left[ \left( x - a \right)^{2} + b^{2} \right]^{-1/2} \cdot 2\left( x - a \right)}{v_{1}} + \frac{\frac{1}{2}\left[ \left( x - c \right)^{2} + d^{2} \right]^{-1/2} \cdot 2\left( x - c \right)}{v_{2}} = 0.$$
Which can be rewritten as
$$\frac{x - a}{v_{1}\sqrt{\left( x - a \right)^{2} + b^{2}}} + \frac{x - c}{v_{2}\sqrt{\left( x - c \right)^{2} + d^{2}}} = 0.$$
But we can notice in the previous image
$$ \begin{split} \sin\theta_{1} &= \frac{x - a}{\sqrt{\left(x - a\right)^{2} + b^{2}}} \\ \sin\theta_{2} &= \frac{c - x}{\sqrt{\left(x - c\right)^{2} + d^{2}}} \end{split} $$
that way we can rewrite the above equation as
$$\frac{\sin\theta_{1}}{v_{1}} - \frac{\sin\theta_{2}}{v_{2}} = 0$$
equivalently it is
$$\frac{\sin\theta_{1}}{\sin\theta_{2}} = \frac{v_{1}}{v_{2}},$$
which is the Snell's Law.
Instructions
Move the green slider to change angle of incidence, move the black sliders to change the refractive indices. Being \(n_{1}\) that of the upper part and \(n_{2}\) that of the lower part.