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?

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

\begin{displaymath}T=\frac{\vert AS\vert}{v}+\frac{\vert SB\vert}{u}

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

\begin{displaymath}\vert AS\vert=\sqrt{q^2+(p-x)^2}\qquad\mbox{and}\qquad \vert SB\vert=x

So finally

\mbox{for }0\leqslant x\leqslant p

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


\begin{displaymath}T^\prime(x)=0\quad\iff\quad \frac{1}{u}=\frac{p-x}{v\sqrt{q^2+(p-x)^2}}


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

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