Optimization Water & Land Travel Snell's Law

The Setup

Here we have something traveling from point A to point B via a point P. We have a function f = w*(distance from A to P) + l *(distance from P to B). For example, w could be the rate of energy consumption over water and l the rate of energy consumption over land, or w could be the rate of speed over water and l the rate of speed over land, or w could be the rate of speed of light through air and l could be the rate of speed through water. Adjust the distances and rates via the sliders or input boxes. Move the point P to see different possibilities. The function f is graphed in the right window. The x-value of P and the corresponding value of f can be seen by the black point on the graph. Experiment with moving P around to try to minimize f. Check Optimal Solution to see the pint G where f is minimized. At this point an interesting relationship between angles occurs. This relationship is known as Snell's Law, which you chsee by checking Angles.