Minimizing the distance between two boats. the source of this problem is Stewart's Essential Calculus (Early Transcendentals) 2nd ed.

A boat leaves a dock at 2:00PM and travels due south at a speed of $20$ km/h. Another boat has been heading due east at $15$ km/h and reaches the same dock at 3:00 PM. I want to find at what time the two boats were closest together. 

My plan of approach is to find the positions of the boats at any time $t$, and minimize the square of the distance between them.  For the boat traveling due east, its position could be written as $(f(t), 0)$ and for the one due south, $(0, g(t))$.  My difficulty lies in determining what $f(t)$ and $g(t)$ are. I'd appreciate it if someone could assist.  Thanks.
 A: Hint: You are given the derivatives of your functions!

Let $f(t), g(t)$ be defined as above. Let $d_{1}(t) := |f(t)|$ and $d_{2}(t) := |g(t)|$ The distance squared is $H(t) := d_{1}(t)^{2} + d_{2}(t)^{2}$. In this case, what you are given is $d_{1}'(t) = -15$ since the distance to the dock is decreasing and $d_{2}'(t) = 20$ for the "opposite" reason. This implies that $d_{1}(t) = -15t + c$ and $d_{2}(t) = 20t + d$ for some constants $c, d$. By putting $t = 0$, we see $d = 0$ and $c = 15$ (since it took exactly one hour to reach the dock). Now we got $H(t) = (-15t + 15)^{2} + (20t)^{2}$ and the task became a problem that you know how to solve!
A: First, draw a picture describing the starting position of the boats and the dock.  We know it takes 1hr for the green boat to reach the dock, so I've marked that distance as 1hr.  

We want the units of $f(t)$ and $g(t)$ to both be in kilometers, so let's start with writing down a function that gives the starting position for each when they're at $t=0$.
I'm using $f$ for the vertical boat, $g$ for the horizontal boat.
$$f(t) = 0 + \text{something to be added}$$
$$g(t) = -(1\text{ hr})\left(15 \frac{\text{km}}{\text{hr}}\right) +  \text{something to be added}$$
The constants give me my offset because they don't start at the same place.
See if you can figure out the rest.  If you can't, see (mouse-over) below:

Moving on, we need to figure out what that "something" is.  Well, we know $\text{distance} = \text{rate}\times\text{time}$, so let's try that:
$$f(t) = 0 -\left(20\frac{\text{km}}{\text{hr}}\right)t$$
$$g(t) = -(1\text{ hr})\left(15 \frac{\text{km}}{\text{hr}}\right) + \left(15\frac{\text{km}}{\text{hr}}\right)t$$
Why do we need the minus sign in $f$?  Well, it's because we're going south, which is in the negative $y$ direction.

