# 4 Bugs chasing each other differential equation

This is from a problem seminar and I need help figuring out the solution.

Four bugs, $A,B,C,D$ are initially placed at the corners of a unit square. From a given initial moment, all four crawl simultaneously at one and the same speed $s>0$, $A$ towards $B$, $B$ towards $C$, $C$ towards $D$, and $D$ towards $A$, with each heading at every instant along the line joining it with its target.

Find a system of differential equations describing the trajectory of $A$.

Do the bugs eventually all meet at the center of the square? If so, how long did it take?

My attempt so far: $\def\grad{\mathbf\nabla}$ $\newcommand{\norm}[1]{\left\Vert #1 \right\Vert}$ Call ${\vec x}_1,{\vec x}_2,{\vec x}_3,{\vec x}_4$ the positions in the plane of $A,B,C,D$ respectively. Then $$\grad {\vec x}_1 = \frac{{\vec x}_2-{\vec x}_1}{\norm{{\vec x}_2-{\vec x}_1}}s$$ $$\grad {\vec x}_2 = \frac{{\vec x}_3-{\vec x}_2}{\norm{{\vec x}_3-{\vec x}_2}}s$$

$$\grad {\vec x}_3 = \frac{{\vec x}_4-{\vec x}_3}{\norm{{\vec x}_4-{\vec x}_3}}s$$

$$\grad {\vec x}_4 = \frac{{\vec x}_1-{\vec x}_4}{\norm{{\vec x}_1-{\vec x}_4}}s$$

with ${\vec x}_1(0) = (0,0),\ {\vec x}_2(0) = (0,1),\ {\vec x}_3(0) = (1,1),\ {\vec x}_4(0) = (1,0)$.

I have noticed that the sum of the gradients is 0, but I don't know if that is helpful or not. Can someone help me figure this problem out?

-
This is related and has a nice animation in one of the answers: math.stackexchange.com/questions/44896/… – joriki Nov 1 '11 at 8:43
Satisfied by an answer? – Did Jun 28 '12 at 12:22

Let the process take place in the square $|x|\leq 1$, $|y|\leq1$ of the complex $z$-plane. If $t\mapsto z(t)$ describes the movement of ant $A_0$ then the movement of the other ants is given by $$t\mapsto i^k\ z(t)\qquad(1\leq k\leq 3)\ .$$ By the given law of motion we have $$\dot z(t)\ =\ \lambda(t)\bigl(i\,z(t)-z(t)\bigr)$$ for some function $t\mapsto \lambda(t)>0$. As the velocity $v$ is given the factor $\lambda$ is determined by the condition $$v=|\dot z|=\lambda \sqrt{2}\,|z|\ .$$ Therefore $t\mapsto z(t)$ obeys the differential equation $$\dot z=v\ {i-1\over\sqrt{2}}\ {z\over|z|}\ .$$ We now write $z$ in the form $z(t)=r(t)\,e^{i\theta(t)}$, whereupon our differential equation becomes $$(\dot r + i r\dot\theta)e^{i\theta}\ =\ v\Bigl({i\over\sqrt{2}}-{1\over\sqrt{2}}\Bigr)\,e^{i\theta}\ .$$ Cancelling $e^{i\theta}$ and separating real and imaginary parts gives $$\dot r=-{v\over\sqrt{2}}\ ,\qquad \dot\theta ={v\over\sqrt{2}}\ {1\over r}\ ,$$ and we have the initial conditions $r(0)=\sqrt{2}$, $\ \theta(0)={\pi\over4}$.

We immediately get $$r(t)=\sqrt{2}\Bigl(1- {v\over 2}\ t\Bigr)\ ,$$ from which we deduce that the process is over after time $T:={2\over v}$. Using this we find via a second integration $$\theta(t)\ =\ {\pi\over4} +\log{1\over 1-{v\over2} t}\qquad(0\leq t<T)\ .$$ This shows that the ants turn ever faster around the origin towards the end of the process.

-

Hints: Assume the square is centered at zero and the affix of the position of $A$ at time $t$ is $r(t)\mathrm e^{\mathrm i\theta(t)}$. Then:

1. The affixes of the positions of $B$, $C$ and $D$ at time $t$ are $\mathrm ir(t)\mathrm e^{\mathrm i\theta(t)}$, $-r(t)\mathrm e^{\mathrm i\theta(t)}$ and $-\mathrm ir(t)\mathrm e^{\mathrm i\theta(t)}$ respectively.
2. Hence, for example, the line $AB$ has the direction of $(\mathrm i-1)\mathrm e^{\mathrm i\theta(t)}$.
3. At time $t$, the tangent of the curve that $A$ makes has the direction of $(r'(t)+\mathrm ir(t)\theta'(t))\mathrm e^{\mathrm i\theta(t)}$.
4. The square of the speed at time $t$ is $(r'(t))^2+(r(t)\theta'(t))^2$.

The steps of the proof are as follows. Points 2. and 3. combined yield a first order differential equation characterizing the motion of $A$, hence of $B$, $C$ and $D$ through point 1. Solving this yields $\theta(t)$ as a function of $r(t)$. Finally, point 4. determines $r(t)$.

-
What is an affix? – nullUser Oct 31 '11 at 22:57
The affix of the point $(x,y)$ in the plane is the complex number $x+\mathrm iy$. – Did Oct 31 '11 at 22:58
How do you make sure that the positions B,C,D remain as prescribed that is for instance B on $ir(t)e^{i\theta(t)}$? – user17090 Oct 31 '11 at 23:13
@Ali, from the rotational symmetry of the problem. The initial position and the dynamics are symmetric under the 90 degree rotation, so this will remain the case for all later times. – zyx Oct 31 '11 at 23:32
Yes $(r'(t)+\mathrm i\theta'(t))\mathrm e^{\mathrm i\theta(t)}$ is the derivative of $re^{i\theta}$ with respect to $t$, but this makes it the tangent in polar coordinates, I need the tangent in rectangular coordinates. This is $i\frac{r'\sin\theta + r\cos\theta}{r'\cos\theta - r\sin\theta}$, no? And I can't see whether or not these are equal. – nullUser Nov 1 '11 at 0:16

I think I solved this. If bug 1 has coordinates $(x,y)$ then bug 2 has coordinates $(y,1-x)$ so since bug 1 moves into the direction of bug 2 the differential equation is

$$\frac{dy}{dx} = \frac{1-x-y}{y-x}.$$

Substitution of $x=p+1/2$ and $y=q+1/2$ leads to

$$\frac{dq}{dp}=\frac{p+q}{q-p}$$

and then with $f=q/p$ and $p=\exp(s)$ we get

$$\frac{df}{ds}=\frac{1+f^2}{1-f}$$

The solution starting at $(x,y)=(0,0)$ is the found through separation of variables

$$p = -\frac{\exp(\arctan(f)-\arctan(1))}{\sqrt{2(1+f^2)}}$$

from which as function of varying parameter $f$, $x$ and $y$ can be obtained.

-

From the previous result, changing to polar coordinates ( $p=r\cos(\Theta), q=r\sin(\Theta)$ ) one obtains a more transparent form of the solution:

$r= \exp(\Theta-5\cdot\frac{\pi}{4})/\sqrt{2}$

Letting theta decrease from zero to minus infinity, the path of the bug traced is seen to be be a logarithmic spiral.

A more elegant approach is perhaps using complex numbers. With the origin of the complex plane in the lower left corner of the square, and the two bugs are at $z$ and $i-iz$, the differential equation becomes

$\frac{dz}{dt} + (1+i)z = i$

for which the solution can be written immediately

$z = \frac{1+i}{2} (1-\exp(-(i+1)\cdot t))$ for $t\geq0$

which represents, of course, the same spiral. Since $|dz|=\exp(-t)dt$ it follows that total length of the path equals 1, the length of the side of the square.

-