A swimmer crosses a pool of width b by swimming in a straight line from (0, 0) to (2b, b) as shown in the figure below.

(a) Let f be a function defined as the y-coordinate of the long side of the pool that is nearest the swimmer at any given time during the swimmer's path across the pool. Determine the function f.

This question is a fill in the blank one so I know the answer is in a piecewise format:

$\displaystyle f(x)=\left\{\begin{array}{cc}0,&\mbox{ if }

0\leq x<b\\b, & \mbox{ if } b<x\leq 2b\end{array}\right.$

(b) Let g be the minimum distance between the swimmer and the long sides of the pool. Determine the function g. This one is also fill in the blank over the same intervals.

$\displaystyle f(x)=\left\{\begin{array}{cc}\frac{x}{2},&\mbox{ if }

0\leq x<b\\b-\frac{x}{2}, & \mbox{ if } b<x\leq 2b\end{array}\right.$

I don't see why this isn't a simple geometry problem if the swimmer swam in a straight line like the model, in which case wouldn't the function be sqrt(3x^2)? I'm not looking for the answers to problem, just to understand what I'm supposed to be doing.