Sub topic 10
Fermat's principle: reflection and refraction from least time
Earlier chapters gave you two rules: the law of reflection (θ₁ = θ₂) and Snell's law (n₁ sin θ₁ = n₂ sin θ₂). Both were stated as facts about angles. This chapter shows that one idea produces both rules: light travels between two points along a path whose travel time is stationary, which in most everyday cases means the shortest time.
I assume you know the following:
- Sine and inverse sine.
- Angles measured from the surface normal.
- The refractive index n = c / v.
- Basic derivatives. You need to know that a smooth function has zero slope at its minimum.
If calculus is rusty, the geometric argument for reflection and the numerical code below still work.
The principle
Fermat's principle says that a light ray going from point A to point B follows a path for which the travel time is stationary. Stationary means that a tiny change in the path changes the time only to second order. In the common case, the actual path is the one with the least time among nearby candidate paths.
Light in a medium of index n moves at speed v = c / n. A segment of length s therefore takes time t = s / v = n s / c. Summing over a path gives
T = (1/c) Σ nᵢ sᵢ
The sum Σ nᵢ sᵢ is the optical path length (OPL). Because c is constant, minimizing time is the same as minimizing OPL. In a single uniform medium n is fixed, so the least-time path is the shortest path, a straight line.
Deriving the law of reflection
Place a flat mirror along the x-axis. The source A is at (0, a) and the observer B is at (d, b), both above the mirror. The ray touches the mirror at a point P = (x, 0), where x is unknown.
The path length through P is
L(x) = √(x² + a²) + √((d − x)² + b²)
Both segments are in the same medium, so minimizing L minimizes the time. Set the derivative to zero:
dL/dx = x / √(x² + a²) − (d − x) / √((d − x)² + b²) = 0
Each fraction is the sine of an angle measured from the vertical, which is the mirror's normal. The first is sin θ₁ for the incoming segment, and the second is sin θ₂ for the outgoing segment. The condition becomes
sin θ₁ = sin θ₂, so θ₁ = θ₂
This is the law of reflection. Solving for x gives x = a d / (a + b), the point where a straight line from A to the mirror image of B (at (d, −b)) crosses the mirror. This is the "image method" you can use to draw reflected rays without any calculus.
Deriving Snell's law
Now put the interface along the x-axis. The medium above has index n₁ and contains A = (0, a). The medium below has index n₂ and contains B = (d, −b). The ray crosses the interface at P = (x, 0). The optical path length is
OPL(x) = n₁ √(x² + a²) + n₂ √((d − x)² + b²)
Differentiate and set the result to zero:
dOPL/dx = n₁ x / √(x² + a²) − n₂ (d − x) / √((d − x)² + b²) = 0
Again, each fraction is the sine of an angle from the normal:
n₁ sin θ₁ = n₂ sin θ₂
This is Snell's law. It follows from the condition that OPL is stationary with respect to where the ray crosses the boundary.
The reflection derivation is the same calculation with n₁ = n₂ and B on the same side as A. This is why the two laws look so similar.
The lifeguard picture
A lifeguard on a beach sees a swimmer in trouble. Running on sand is faster than swimming. The straight line to the swimmer is not the quickest route, because it spends too much time in the slow water. The best route runs farther along the sand and then enters the water at a steeper angle, closer to the normal. The route bends at the shoreline.
Light does the same thing. It travels slower in glass than in air, so the least-time path spends less distance in glass. Inside the slower medium the ray bends toward the normal, which is what Snell's law gives when n₂ > n₁.
Checking it numerically
You can verify the derivation by brute force. The code below searches for the crossing point x that minimizes the optical path length. It then compares n₁ sin θ₁ with n₂ sin θ₂ at that point.
The function is a sum of two convex terms, so it has a single minimum. A ternary search, which repeatedly discards the worse third of the interval, is enough to find it.
import math
def optical_path(x, a, b, d, n1, n2):
"""Optical path length from (0, a) to (x, 0) to (d, b or -b)."""
return n1 * math.hypot(x, a) + n2 * math.hypot(d - x, b)
def minimize(f, lo, hi, tol=1e-10):
"""Ternary search for the minimum of a convex function on [lo, hi]."""
while hi - lo > tol:
m1 = lo + (hi - lo) / 3
m2 = hi - (hi - lo) / 3
if f(m1) < f(m2):
hi = m2
else:
lo = m1
return (lo + hi) / 2
def analyze(a, b, d, n1, n2):
x = minimize(lambda t: optical_path(t, a, b, d, n1, n2), 0.0, d)
theta1 = math.atan2(x, a)
theta2 = math.atan2(d - x, b)
return x, math.degrees(theta1), math.degrees(theta2), n1 * math.sin(theta1), n2 * math.sin(theta2)
# Reflection: same medium (n1 = n2 = 1), source and observer both 1 unit from the mirror.
x, t1, t2, s1, s2 = analyze(a=1, b=1, d=2, n1=1.0, n2=1.0)
print(f"reflection: x={x:.4f}, theta1={t1:.2f}, theta2={t2:.2f}")
# Refraction: air (1.0) to glass (1.5).
x, t1, t2, s1, s2 = analyze(a=1, b=1, d=2, n1=1.0, n2=1.5)
print(f"refraction: x={x:.4f}, theta1={t1:.2f}, theta2={t2:.2f}")
print(f"n1 sin(theta1) = {s1:.4f}, n2 sin(theta2) = {s2:.4f}")The reflection case prints x = 1.0000 with both angles at 45.00°. The refraction case gives a crossing near x ≈ 1.36, with θ₁ near 53.7° and θ₂ near 32.5°. The two products n₁ sin θ₁ and n₂ sin θ₂ agree to the printed precision, which confirms that the minimum-time path obeys Snell's law. Notice also that θ₂ < θ₁, so the ray bends toward the normal in glass.
Why "stationary" and not "minimum"
Textbooks often say "least time," but the correct condition is that the first-order change in time is zero. Most of the time that point is a minimum. It does not have to be.
| Situation | Behavior of the time along the actual path |
|---|---|
| Flat mirror or flat refracting interface | Minimum |
| Elliptical mirror, source and observer at the two foci | All paths between the foci have equal time, so the time is constant |
| Curved mirror that bends more sharply than the ellipse through the same two points and the same contact point | Maximum |
| Reflection with an inflection or a saddle-shaped surface | Saddle point: a minimum in one direction, a maximum in another |
In every row, the derivative of the time with respect to a small shift of the path is zero. This is why the principle is also called the principle of stationary time.
Why light seems to "know" the best path
Light is a wave. Think of every possible path from A to B as contributing a small wave, with a phase set by the path's optical path length. Paths far from the stationary one have OPLs that change quickly from path to path. Their phases vary widely, and their contributions cancel. Paths near the stationary path all have nearly the same OPL, so their phases line up and add. The visible ray is the bundle of paths where this constructive adding happens.
This also explains a limit of the ray picture. A ray description works when the features of the setup (mirror size, slit width) are much larger than the wavelength. If an aperture is only a few wavelengths wide, the cancellation fails and light spreads out. That is diffraction, and Fermat's principle in its simple form does not describe it.
Consequences and uses
Fermat's principle gives more than a restatement of the two laws.
- Reversibility. If a path has stationary time from A to B, it also has the same time from B to A. So every ray path can be run backward. This is why a mirror lets you see someone's eyes if they can see yours.
- Focusing. A lens or mirror forms an image when every ray from a source point reaches the image point with the same optical path length. This is the same as the elliptical-mirror row in the table above. Designing a lens surface can start from this equal-OPL condition.
- Curved paths in graded media. If n changes smoothly with position, as in hot air above a road, the stationary-time path is a curve. The ray bends toward the region of higher index. A mirage is this effect: air near hot asphalt has a lower index, so rays from the sky curve upward into your eye.
- A check on derived rules. If a proposed rule disagrees with Fermat's principle, such as a ray taking a path that is not stationary, the rule is incomplete.
What the principle does not tell you
- How much light goes each way. At an interface, some light reflects and some refracts. Fermat's principle locates the directions of the two rays. It says nothing about their intensities. The Fresnel equations cover that, as the next chapter discusses.
- Total internal reflection. When n₁ sin θ₁ > n₂, no real angle θ₂ satisfies Snell's law, so there is no stationary refracted path. Only the reflected ray exists in the geometric picture.
- Which of several stationary paths is taken. Some setups have more than one stationary path, such as a ray reaching you directly and by a bounce. All of them can carry light. They are different rays, and they can interfere.
Exercise
A source is 3 m above a flat mirror and an observer is 5 m above it, with a horizontal separation of 8 m between them. Use the image method (a straight line from the source to the mirror image of the observer) to find where on the mirror the ray reflects, measured horizontally from the point below the source.
Show answer
The image of the observer is 5 m below the mirror, 8 m across horizontally. The straight line from the source to this image drops a total of 3 + 5 = 8 m over 8 m horizontally. It reaches the mirror after dropping 3 m, which is 3/8 of the way, so x = 8 × 3/8 = 3 m. This agrees with x = a d / (a + b) = 3 × 8 / (3 + 5) = 3 m. The angle from the normal is 45° on both sides, since 3 m across for 3 m up on the source side and 5 m across for 5 m up on the observer side.
Exercise
In the refraction derivation, the crossing point x satisfies n₁ x / √(x² + a²) = n₂ (d − x) / √((d − x)² + b²). If light goes from air (n₁ = 1.0) into water (n₂ = 1.33) and θ₁ = 40°, what is θ₂, and does the least-time path bend toward or away from the normal?
Show answer
Snell's law gives sin θ₂ = 1.0 × sin 40° / 1.33 = 0.6428 / 1.33 = 0.4833, so θ₂ ≈ 28.9°. Since θ₂ < θ₁, the ray bends toward the normal. This fits the least-time picture: water is the slower medium, so the best path shortens its distance in water.
Exercise
Explain why "light takes the shortest path" is wrong as a statement of Fermat's principle, using the air-to-glass example.
Show answer
A refracted ray bends at the interface, so its total length is greater than the straight line from A to B. It is still the faster route because it spends less distance in the slow medium (glass, v = c/1.5). The principle minimizes (or makes stationary) the time, which is proportional to the optical path length Σ n s, not the geometric length Σ s.