PhysSandbox
Classical MechanicsWaves & SoundElectricity & MagnetismOptics & LightGravity & OrbitsLabs
🌙Astronomy & The Sky🌡️Thermodynamics🌍Biophysics, Fluids & Geoscience📐Math Visualization🔧Engineering🧪Chemistry

Related simulators

Continue with similar topics in this category — or all 50 in Optics & Light.

View category →
NewSchool

Rainbow in a Droplet

Launch Simulator

Snell in a sphere: primary (1× internal reflection ~42°) and secondary (2× ~51°, reversed spectrum); scan b/R and n.

School

Total Internal Reflection

Launch Simulator

Find the critical angle. Fiber optics analogy.

NewSchool

Rayleigh Sky (blue)

Launch Simulator

Scattered intensity ∝ λ⁻⁴; compare blue vs red and qualitative sky gradient.

FeaturedSchool

Refraction

Launch Simulator

Light crossing boundaries. Snell's law with angle measurements.

NewUniversity / research

Birefringence (Calcite sketch)

Launch Simulator

Two scalar Snell paths for n_o and n_e — double refraction cartoon (not full optic-axis walk-off).

NewSchool

Prism & Dispersion

Launch Simulator

White light through a prism creating a rainbow spectrum.

PhysSandbox

Interactive physics, chemistry, and engineering simulators for students, teachers, and curious minds.

Physics

  • Classical Mechanics
  • Waves & Sound
  • Electricity & Magnetism

Science

  • Optics & Light
  • Gravity & Orbits
  • Astronomy & The Sky

More

  • Thermodynamics
  • Biophysics, Fluids & Geoscience
  • Math Visualization
  • Engineering
  • Chemistry

© 2026 PhysSandbox. Free interactive science simulators.

PrivacyTermsContact
Home/Optics & Light/Fermat's Principle

Fermat's Principle

OPL = n₁AP+n₂PB vs hit point; minimum = Snell path.

Media

1
1.45
0.05

Optical path length OPL = n₁ AP + n₂ PB for a point P on the flat interface. Fermat’s principle of stationary time gives the same path as Snell’s law: n₁ sin θ₁ = n₂ sin θ₂.

Shortcuts

  • •Drag n sliders and P; compare OPL to the Fermat minimum
  • •Use snap to land on the Snell path

Measured values

OPL (your P)0.72946rel.
OPL (Fermat)0.72914rel.
sin θₜ / sin θᵢ at min0.6891
n₁/n₂0.6897

Live graphs

About this model

Fermat's principle of extremal optical path length states that light rays between two points follow paths for which the travel time is stationary—usually a minimum—compared to neighboring paths. In homogeneous media this yields straight rays; at interfaces it yields Snell's law when refraction lowers overall time; in graded-index media rays bend toward regions of higher refractive index where phase velocity is lower. The simulator visualizes comparing candidate paths and accumulated optical path length n·s or time ∫ (n/c) ds, reinforcing the link between wavefronts (Huygens) and rays (Fermat). Idealizations use geometric optics, ignoring diffraction when apertures are comparable to wavelength, and assuming isotropic n. Students reconcile Fermat with reversibility of rays and connect the principle to variational formulations used across physics.

Who it's for: Undergraduate optics students after Snell's law who want a unifying variational viewpoint before wave optics dominates.

Key terms

  • Fermat's principle
  • Optical path length
  • Snell's law
  • Refraction
  • Stationary time
  • Ray optics
  • Reversibility
  • Index of refraction

How it works

Between two fixed points in different homogeneous media separated by a plane interface, the physically realized ray is the one that makes the optical path length n₁ℓ₁ + n₂ℓ₂ stationary (a minimum here). Varying the breakpoint P on the interface traces a smooth OPL curve whose minimum coincides with Snell’s law.

Key equations

OPL = n₁ |AP| + n₂ |PB| → min over P on interface
⇒ n₁ sin θᵢ = n₂ sin θₜ

Frequently asked questions

Is the path always the shortest time?
Stationary can mean minimum, maximum, or saddle in exotic layouts; reflection and standard refraction cases are typically minima.
How does this relate to Huygens' construction?
Wavefronts evolve so that equal-phase surfaces remain consistent with constructive interference; rays are the normals to those fronts. Fermat's principle picks the same rays in the short-wavelength limit.
Why can't Fermat explain a single-slit diffraction pattern?
Diffraction needs wave superposition across the aperture. Geometric ray limits miss interference structure when λ is not negligible.
Does general relativity change Fermat's principle?
In curved spacetime light follows null geodesics; a generalized Fermat principle still describes stationary arrival times in an effective optical metric.