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

More from Optics & Light

Other simulators in this category — or see all 44.

View category →
NewSchool

Chromatic Aberration

Cauchy n(λ); thin-lens f(λ); paraxial rays R/G/B.

Launch Simulator
School

Diffraction

Single and double slit with interference patterns.

Launch Simulator
Kids

Color Mixing

Additive (RGB) and subtractive (CMY) interactive color mixing.

Launch Simulator
NewSchool

Polarization (Malus)

Two polarizers. Rotate θ, see I = I₁ cos²θ and extinction.

Launch Simulator
NewUniversity / research

Birefringence (Calcite sketch)

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

Launch Simulator
NewUniversity / research

Holography (Recording principle)

Toy 2D interference |E_ref + E_obj|²: fringes encode phase; readout diffraction not simulated.

Launch Simulator
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

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

Live graphs

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

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.