*Problem:*

Suppose you are in the middle of a desert ( point *A* ) and you want to
get to the town ( point *B* ) as fast as possible. Of course you can go
straight from *A* to *B*, but you cannot move too fast in the desert.
Going to the road first ( point *S* ) and hitching a ride there might
be a better choice. So here is the problem: How to choose point *S* so as
to minimize the time *T* it takes to get from *A* to *B*?

*Solution:*

The town *B* is *q* miles north and *p* miles east from *A*. You can go *v* mph on the
desert and *u* mph on the road ( *v*<*u* ). Let *x* be the distance from *S* to *B*.
Below you can experiment with various parameters.

You can change the position of *A* and *S* by "dragging" them with the mouse
or by changing *p*, *q* or *x*. On the right you can see a graph of the time
*T* with respect to *x*. Clicking on "Optimize" will give you the best
location of *S*.
Now let us solve the problem. We can express the time *T* as

where |*AS*| is the distance from *A* to *S* in miles and |*SB*| is the
distance from *S* to *B*. It is easy to see that

So finally

Our task is to find the absolute minimum of *T*(*x*) on [0,*p*]. First
we will find all critical points of *T*.

So now all we have to do is to test the value of *T* at 0, *p* and
at *x*_{0} ( provided that 0<*x*_{0}<*p* - sometimes *T*(*x*) has a local extremum
outside [0,*p*] ).

This page and the Java applet were written by Marek Szapiel.