# Variation on circular lake problem

An escaped prisoner finds himself in the middle of a SQUARE swimming pool. The guard that is chasing him is at one of the corners of the pool. The guard can run faster than the prisoner can swim. The prisoner can run faster than the guard can run. The guard does not swim. Which direction should the prisoner swim in in order to maximize the likelihood that he will get away?

I don't think it's as easy as some are making it out to be. First draw a sketch, it is obvious that you should go in one of two directions. In my sketch, that's either downward (the way I drew) or rightward (going towards the right edge of the square). Both of those will produce the same result (it's symmetrical).

The time it takes to get to the side is proportional to the length ($t = \frac{1}{v}d$). The prisoner should go at a certain angle (again look at my sketch), $\theta$. This gives the length to the side (the hypotenuse) as:

$$l_{swimmer} = \frac{L}{\cos(\theta)}$$

where $L$ is half the length of the square and $\theta$ ranges from $0$ to $\frac{\pi}{4}$ radians ($\theta = 0$ means going straight down and $\theta = \frac{\pi}{4}$ means going towards the opposite corner).

Now, the length that the guard has to run is given by $3L + L\tan(\theta)$ ($2L$ from going down one full side, $L$, from going to the right half way, and then finally the extra length from the prisoner swimming at a diagonal).

So now there is a balance to be had. The longer you swim, the further the guard has to go, but he has more time to go that further distance. The shorter you swim, the shorter the guard has to go, but he has less time to go that distance. If everything were linear, then it wouldn't matter, but since it's not, there may be an optimum angle.

Let's assume that the prisoner swims at $1$ length/time and the guard runs at some value $v$ (so the guard runs $v$ times faster than the prisoner swims). The time it takes the guard to reach where the prisoner exited and the time it takes the prisoner to get to that point are given by:

$$t_{swimmer} = \frac{1}{\cos(\theta)}L \\ t_{runner} = \frac{3 + \tan(\theta)}{v}L$$

The prisoner escapes when it takes longer for the guard to get to the exit, that is when $t_{runner} > t_{swimmer}$. So we want the largest possible value of $t_{runner} - t_{swimmer}$ (a maximum):

$$\Delta t = \left(\frac{3 + \tan(\theta}{v} - \frac{1}{\cos(\theta}\right)L \\ f(\theta) = \frac{3 + \tan(\theta)}{v} - \frac{1}{\cos(\theta)} \\ f'(\theta) = \frac{\sec^2(\theta)}{v} - \sin(\theta)\sec^2(\theta) = \sec^2(\theta)\left(\frac{1}{v} - \sin(\theta)\right)$$

There are two critical points: 1) when $\sec^2(\theta)$ is undefined at $\theta = \frac{\pi}{2}$ and 2) when $\sin(\theta) = \frac{1}{v}$. The first is outside of our range (we only want up to $\theta = \frac{\pi}{4}$). This second is a local max and that's easy to see. $\sin(\theta)$ is initially zero (when $\theta = 0$), $sec^2(0) > 0$ and thus the derivative is initially positive. The sign switches when $\sin(\theta) = \frac{1}{v}$. Afterwards $\sin(\theta) > \frac{1}{v}$. Therefore at this critical point, the derivative's sign changes from positive (going up) to negative (going down) therefore this is a local max and likely the global max.

It's still informative to write out the boundary points anyway:

$$f(0) = \frac{3}{v} - 1 = \frac{3 - v}{v} \\ f\left(\frac{\pi}{4}\right) = \frac{3 + 1}{v} - \sqrt{2} = \frac{4 - v\sqrt{2}}{v}$$

Notice that $\lim_{v \rightarrow \infty} \theta = 0$ (the sine goes to zero as the angle goes to zero). Also note that the maximum speed for the guard, such that the prisoner goes directly to the bottom (or right) is $3 - v > 0 \rightarrow v < 3$ whereas the maximum speed for the guard such that the prisoner can get away if he swims to the diagonal is $4 - v\sqrt{2} > 0 \rightarrow v < \frac{4}{\sqrt{2}} < 3$.

The prisoner could just assume the guard runs at about 3 times the speed he can swim (if the guard runs much faster, the prisoner is doomed no matter what...see edit below) and thus he could head towards the bottom at an angle with the vertical of:

$$\sin(\theta_C) = \frac{1}{3} \rightarrow \theta_C \approx 19.47^\circ$$

edit: boundary case

There is a speed for which the optimal path is to go to the corner and that's when the guard runs slow. In fact, you can basically tell it's just when $\theta_C > \frac{\pi}{4}$ which occurs when $\sin(\theta_C) > \frac{1}{\sqrt{2}} \rightarrow \frac{1}{v} > \frac{1}{\sqrt{2}} \rightarrow v < \sqrt{2}$. So when the guard runs slower than $\sqrt{2}$ times as fast as the prisoner swims, you should just go to the opposite corner (although you would still get out if you went straight to the downward edge or at the above "optimum" angle).

edit: finding maximum speed of guard

The prisoner can get away if the guard goes faster than 3 times the speed the prisoner can swim. To find this, you would need to plug in the value of $\theta_C$ into $f(\theta)$ and set it equal to zero (at this optimum angle). So that at an optimum angle the guard and prisoner meet:

$$\sin(\theta_C) = \frac{1}{v}, \cos(\theta_C) = \frac{\sqrt{v^2 - 1}}{v}, \tan(\theta_C) = \frac{1}{\sqrt{v^2 - 1}} \\ f(\theta_C) = \frac{3 + \frac{1}{\sqrt{v^2 - 1}}}{v} - \frac{v}{\sqrt{v^2 - 1}} = \frac{3\sqrt{v^2 - 1}+1-v^2}{v\sqrt{v^2 - 1}} \\ 3\sqrt{v^2 - 1} + 1 - v^2 = 0 \rightarrow 3\sqrt{v^2 - 1} = v^2 - 1 \rightarrow \frac{3}{\sqrt{v^2 - 1}} = 1 \\ 9 = v^2 - 1 \rightarrow v = \sqrt{10} \approx 3.16 > 3$$

So if the guard runs faster than about $3.16$ times the speed that the prisoner swims, then the prisoner cannot escape. And at this maximum speed, the optimum (and only) angle of escape would be:

$$\sin(\theta) = \frac{1}{\sqrt{10}} \rightarrow \theta \approx 18.43^\circ$$

A Simpler Explanation

It is clear from the above picture that the largest possible $v$ value comes when $\sin(\theta) + 3\cos(\theta)$ achieves its maximum value--its amplitude: $v_{max} = \sqrt{1^2 + 3^2} = \sqrt{10}$. We can find this value $\theta_C$ by either rewriting $\sin(\theta) + 3\cos(\theta) = \sqrt{10}\cos(\theta - \theta_C)$ or by simply finding critical points from the derivative:

$$f'(\theta) = \cos(\theta) - 3\sin(\theta) \\ \frac{\sin(\theta_C)}{\cos(\theta_C)} = \tan(\theta_C) = \frac{1}{3}$$

This is not a special right triangle so simply find:

$$\theta_C = \tan^{-1}\left(\frac{1}{3}\right) \approx 18.43^\circ$$

Note that it's important that $\theta_C$ fall between $-45^\circ$ and $+45^\circ$ since these are the only angles where our figure is valid.

Assume that some pre-positioning is allowed. Assume that the square pool has a side $L$, and that the guard runs with unit velocity, while the swimmer swims with velocity $v$, $0<v<1$.

The swimmer, by mirroring any motion of the guard, can always position himself opposite the guard, while moving farther away from the center of the pool. That is, until he (the swimmer) finds himself on the edge of a square, with sides $Lv$, concentric with the larger square pool. Once this position is reached, all the swimmer's efforts are needed to mirror the guard, with no "extra" velocity to get any further away.

At this point, the swimmer should head straight towards the nearest edge. This will be a distance $\frac{L(1-v)}{2}$ away, covered at a velocity $v$, while the guard, no matter which way he turns, will have to run $2L$ at unit velocity to get to the swimmer's exit point. For escape, the time for the guard to reach exit point must be greater than the time for the swimmer to get there:$$\frac{2L}{1} > \frac{L(1-v)}{2v}$$ $$4v>1-v$$ $$v>0.2$$ So for any guard slower that $5X$ the swimmer, escape is possible.

The prisoner can always swim toward the point "diametrically opposed" to the guard's location. The point the prisoner will get out of the pool is then twice the side away from the guard. This only fails if the guard can run fast enough so that he keeps the prisoner from getting to the wall. To do that, the guard needs to run two sides before the prisoner swims half a side, so a factor of 4.

• Half a diagonal, no? The guard is at a vertex of the square. – colormegone Mar 27 '14 at 18:08
• @RecklessReckoner: I am presuming that the guard starts running toward the corner one way or the other. As the guard traverses the side, the swimmer can change course, always pointing away from the guard. So when the guard gets to the middle of a side, the swimmer can swim only half a side to get to the edge. – Ross Millikan Mar 27 '14 at 18:11
• Then we are reading the problem statement differently. I agree that the strategy is to see which side the guard decides to run along, then to swim to the center of the opposite side. – colormegone Mar 27 '14 at 18:12
• Most likely, and I'm not certain, but if the prisoner cannot swim straight out in one direction, then he probably cannot get out without being caught. So changing directions is just kind of like when two kids chase each other around a table--they can just keep avoiding each other, but they cannot escape. – Jared Mar 27 '14 at 19:01
• If you want to find the optimal path the swimmer should take, then this becomes a Calculus of Variations problem and I think a difficult one at that (although, again, I haven't really thought about that). I have just assumed the swimmer goes in a straight line. – Jared Mar 27 '14 at 19:03