Snell’s Law

We are going to derive Snell’s Law based on the Principle of Least Time, using the Equation class.

The following schematic (thanks to https://www.physicslab.org) illustrates the geometric quantities mentioned above.

image

Let:

  • \(a, \, h, \, x, \, y\): geometric distances.

  • \(\theta_{1}, \, \theta_{2}\): angle of the ray of light with respect to the normal in medium 1 and 2.

  • \(d_{1}, \, d_{2}\): length travelled by light in medium 1 and 2.

  • \(v_{1}, \, v_{2}\): speed of ligth in medium 1 and 2.

  • \(t_{1}, \, t_{2}\): time of travel in medium 1 and 2.

  • \(n_{1}, \, n_{2}\): index of refraction in medium 1 and 2.

  • \(c\): speed of light in vacuum.

Note the definition of index of refraction:

\[v = \frac{c}{n}\]

where \(v\) is the velocity, \(c\) is the speed of light, \(n\) is the index of refraction.

[1]:
from sympy import *
from sympy_equation import Eqn, split_two_terms_add

a, h, x, y, d1, d2, theta1, theta2 = symbols("a, h, x, y, d1, d2, theta1, theta2", real=True, positive=True)
v1, v2, t1, t2, c, n1, n2 = symbols("v1, v2, t1, t2, c, n1, n2", real=True, positive=True)

From the schematic:

[2]:
eq1 = Eqn(d1, sqrt(x**2 + h**2))
eq1
[2]:
$\displaystyle d_{1} = \sqrt{h^{2} + x^{2}}$
[3]:
eq2 = Eqn(d2, sqrt((a - x)**2 + y**2))
eq2
[3]:
$\displaystyle d_{2} = \sqrt{y^{2} + \left(a - x\right)^{2}}$

Also:

[4]:
eq3 = Eqn(d1 * cos(pi - pi/2 - theta1), x)
eq3
[4]:
$\displaystyle d_{1} \sin{\left(\theta_{1} \right)} = x$
[5]:
eq4 = Eqn(d2 * sin(theta2), a - x)
eq4
[5]:
$\displaystyle d_{2} \sin{\left(\theta_{2} \right)} = a - x$

From these last two equations we can easily solve for the angles:

[6]:
eq3 = (eq3 / d1).subs(eq1)
eq3
[6]:
$\displaystyle \sin{\left(\theta_{1} \right)} = \frac{x}{\sqrt{h^{2} + x^{2}}}$
[7]:
eq4 = (eq4 / d2).subs(eq2)
eq4
[7]:
$\displaystyle \sin{\left(\theta_{2} \right)} = \frac{a - x}{\sqrt{y^{2} + \left(a - x\right)^{2}}}$

We also know the relationship between distance, speed and time:

[8]:
eq5 = Eqn(d1, v1 * t1)
eq6 = Eqn(d2, v2 * t2)

Then, we can easily solve for the time it takes the ray of light to travel each medium:

[9]:
eq7 = (eq5 / v1).swap.subs(eq1)
eq7
[9]:
$\displaystyle t_{1} = \frac{\sqrt{h^{2} + x^{2}}}{v_{1}}$
[10]:
eq8 = (eq6 / v2).swap.subs(eq2)
eq8
[10]:
$\displaystyle t_{2} = \frac{\sqrt{y^{2} + \left(a - x\right)^{2}}}{v_{2}}$

The total time it takes the light to travel trough both mediums is:

[11]:
total_time = (eq7 + eq8)
total_time
[11]:
$\displaystyle t_{1} + t_{2} = \frac{\sqrt{y^{2} + \left(a - x\right)^{2}}}{v_{2}} + \frac{\sqrt{h^{2} + x^{2}}}{v_{1}}$

Fermat’s Principle, also known as the Principle of Least Time, states that the path taken by a ray between two given points is the path that can be traveled in the least time. So, we minimize the total time:

[12]:
minimized = Eqn(total_time.rhs.diff(x), 0)
minimized
[12]:
$\displaystyle \frac{- a + x}{v_{2} \sqrt{y^{2} + \left(a - x\right)^{2}}} + \frac{x}{v_{1} \sqrt{h^{2} + x^{2}}} = 0$

We can easily recognize the terms of this addition as the ones shown in the RHS of eq3, eq4. There is a small problem though: the first term on the LHS has the sign swapped in comparison to eq4. Let’s separate the terms of this addition on both sides:

[13]:
minimized = split_two_terms_add(minimized).simplify()
minimized
[13]:
$\displaystyle \frac{x}{v_{1} \sqrt{h^{2} + x^{2}}} = \frac{a - x}{v_{2} \sqrt{y^{2} + \left(a - x\right)^{2}}}$

Now we can perform the substitutions in order to show the dependancy on the angles:

[14]:
minimized = minimized.subs(eq4.swap).subs(eq3.swap)
minimized
[14]:
$\displaystyle \frac{\sin{\left(\theta_{1} \right)}}{v_{1}} = \frac{\sin{\left(\theta_{2} \right)}}{v_{2}}$

Then, we replace the velocities in order to visualize the indices of refraction:

[15]:
idx_of_refrac = lambda n, v, c: Eqn(v, c / n)
minimized = minimized.subs(idx_of_refrac(n1, v1, c), idx_of_refrac(n2, v2, c))
minimized
[15]:
$\displaystyle \frac{n_{1} \sin{\left(\theta_{1} \right)}}{c} = \frac{n_{2} \sin{\left(\theta_{2} \right)}}{c}$
[16]:
snell = minimized * c
snell
[16]:
$\displaystyle n_{1} \sin{\left(\theta_{1} \right)} = n_{2} \sin{\left(\theta_{2} \right)}$
[ ]: