# 32 analysis/dog.p

```A body of soldiers form a 50m-by-50m square ABCD on the parade ground.
In a unit of time, they march forward 50m in formation to take up the
position DCEF. The army's mascot, a small dog, is standing next to its
handler at location A. When the
B----C----E                  soldiers start marching, the dog
|    |    |   forward-->     begins to run around the moving
A----D----F                  body in a clockwise direction,
keeping as close to it as possible.
When one unit of time has elapsed, the dog has made one complete
circuit and has got back to its handler, who is now at location D. (We
can assume the dog runs at a constant speed and does not delay when
turning the corners.)
```

How far does the dog travel?

analysis/dog.s

Let L be the side of the square, 50m, and let D be the distance the
dog travels.

Let v1 be the soldiers' marching speed and v2 be the speed of the dog.
Then v1 = L / (1 time unit) and v2 = v1*D/L.

Let t1, t2, t3, t4 be the time the dog takes to traverse each side of
the square, in order. Find t1 through t4 in terms of L and D and solve
t1+t2+t3+t4 = 1 time unit.

While the dog runs along the back edge of the square in time t1, the
soldiers advance a distance d=t1*v1, so the dog has to cover a distance
sqrt(L^2 + (t1*v1)^2), which takes a time t1=sqrt(L^2 + (t1*v1)^2)/v2.
Solving for t1 gives t1=L/sqrt(v2^2 - v1^2).

The rest of the times are t2 = L/(v2-v1), t3 = t1, and t4 = L/(v2+v1).

In t1+t2+t3+t4, eliminate v2 by using v2=v1*D/L and eliminate v1 by
using v1=L/(1 time unit), obtaining

2 L (D + sqrt(D^2-L^2)) / (D^2 - L^2) = 1

which can be turned into

D^4 - 4LD^3 - 2L^2D^2 + 4L^3D + 5L^4 = 0

which has a root D = 4.18113L = 209.056m.

Continue to: