Fermat's Principle

The original statement of Fermat's principle was, "The actual path between two points taken by a beam of light is the one which is traversed in the least time." Snell's law and the law of reflection follow directly from this statement. It may be reformulated slightly in terms of optical path length as "Light, in going between two points, traverses the route having the smallest optical path length." In its original form however, Fermat's principle is somewhat incomplete and even slightly in error. Its modern form is "A light ray, in going between two points, must traverse as optical path length which is stationary with respect to variations of the path." In this formulation, the paths may be maxima, minima, or saddle points.
In the animation the various possible paths between the source ( Red dot ) and destination ( blue dot ) are shown. The path that takes the least time is marked out. The angles if measured are such that they satisfy the Snell's law and the law of reflection
Source and destination positions can be changed by dragging.
Graph is a plot of time taken by the particle (y axis) and the number of the particle (x axis) counted from left to right. It would be interesting to notice the changes in graph by dragging source postition or destination position away/towards the relecting/refracting surface.Graph is dynamicaly scaled to fit in to the available space.