# An interesting differential equations problem

Suppose we have four ants, initially at rest, at the four corners of a square centered at the origin. They start walking clockwise, each ant walking directly toward the one in front of him. Suppose also that each ant walks with unit velocity, derive a differential equation that describes the trajectories.

### Thought:

Here is the situation of the problem

After some time $$t$$, the ants are now at points $$E,F,G,H$$. If we denote by $$\mathbf{r(t)}$$ the position of ant at $$A$$, we know $$\mathbf{r(0)} = (1,1)$$ and after some $$t$$, at point $$E$$, we have $$\mathbf{r(t)} = (x(t),y(t)) = E$$. We are given that

$$\frac{ y - 1 }{x - 1 } = 1$$

Also, using the arclength formula, we know the path of ant $$A$$ is

$$\int\limits_0^t \sqrt{ (x')^2 + (y')^2 } dt$$

Am I on the right track?

• "We are given that $(y-1)/(x-1)=1$" Are we? // By the way this is known as the mice problem.
– user856
Commented Dec 12, 2016 at 12:36
• i think you will see this or a problem similar to this worked in the text differential equation by bateman.
– abel
Commented Dec 12, 2016 at 19:03
• In case you missed the significance of the earlier comment, note that $(y−1)/(x−1)=1$ implies $x=y$ and $x\neq 1.$ Commented Dec 12, 2016 at 19:44

here is my try. let us look for a symmetric solution. so i will assume the ants at $re^{i\theta}= z, iz, -z, -iz$ the differential equation satisfied by the ant at $z$ is $$\frac{d}{dt}\left(re^{i\theta}\right) = e^{i (\theta + 3\pi/4)} .$$ this can be written as $$\frac{d r}{dt} = -\frac 1 {\sqrt 2}, \ \frac{d \theta}{d t} = \frac 1{r\sqrt 2} \mbox{ with the initial conditions } r = \sqrt 2, \theta = \pi/4.$$

this has solution $$r = \sqrt 2 - \frac t {\sqrt 2}, \theta = \pi/4 + \ln\left( \frac 2{ 2-t}\right), 0 \le t < 2.$$

In general, the differential equation that each ant (indexed $i,$ and cyclic so that $n + 1$ is the same as $1$) follows is

$\frac{d\bf{r}_i}{dt} = v \frac{\bf{r}_{i+1} - \bf{r}_i}{||\bf{r}_{i+1} - \bf{r}_{i}||}$

where $v$ is the ant's speed and $||\cdot||$ denotes the vector length (2-norm).

As the other answer mentions, for this special case where the ants are arranged in a square, it is possible to set up simpler equations to find the trajectories.

Let $\,\boldsymbol{x}(t)$, $\boldsymbol{y}(t)$, $\boldsymbol{z}(t)$ and $\boldsymbol{w}(t)$ be the vectors describing the positions of the four ants, and let $$\boldsymbol{A} \,=\, (1,1), \,\, \boldsymbol{B} \,=\, (-1,1), \,\, \boldsymbol{\varGamma} \,=\, (-1,-1) \,\,\, \text{and} \,\,\, \boldsymbol{\varDelta} \,=\, (1,-1),$$ be their initial positions. As the first ant chases the second one, the velocity $\,\boldsymbol{x}'(t)\,$ of the first ant will have the same direction with the vector $\,\boldsymbol{y}(t)-\boldsymbol{x}(t),\,$ which connects the two ants, i.e., $$\,\boldsymbol{x}'(t)\,\varpropto\,\boldsymbol{y}(t)-\boldsymbol{x}(t),$$ and as its velocity is of unit norm, $\,\|\boldsymbol{x}'(t)\|=1,$ where $\,\|\cdot \|\,$ is the Eucidean norm in $\mathbb R^2$, then $$\,\boldsymbol{x}^\prime \,=\, \frac{\boldsymbol{y-x}}{\|\, \boldsymbol{y-x} \|}.$$

Similarly we obtain the equations of motion of the remaining three ants. We thus obtain the following system of ODEs: $$\boldsymbol{x}^\prime \,=\, \frac{\boldsymbol{y-x}}{\| \boldsymbol{y-x} \|}, \,\,\, \boldsymbol{y}^\prime \,=\, \frac{\boldsymbol{z-y}}{\| \boldsymbol{z-y} \|}, \,\,\, \boldsymbol{z}^\prime \,=\, \frac{\boldsymbol{w-z}}{\| \boldsymbol{w-z} \|}, \,\,\, \boldsymbol{w}^\prime \,=\, \frac{\boldsymbol{x-w}}{\| \boldsymbol{x-w} \|}, \tag{i}$$ with initial conditions $$\boldsymbol{x}(0)=\boldsymbol{A},\,\,\,\boldsymbol{y}(0)=\boldsymbol{B},\,\,\, \boldsymbol{z}(0)=\boldsymbol{\varGamma},\,\,\,\boldsymbol{w}(0)=\boldsymbol{\varDelta}. \tag{ii}$$ Equations $(i)$ and $(ii)$ form an initial value problem (IVP) of a nonlinear $8\!\times\!8$ system of ODEs. If the vectors $\boldsymbol{x}(t)$, $\boldsymbol{y}(t)$, $\boldsymbol{z}(t)$ and $\boldsymbol{w}(t)$ satisfy our IVP and \begin{equation*} U \,=\, \left(\! \begin{array}{rr} 0 & -1 \\ 1 & 0 \end{array} \!\right)\!, \end{equation*} the orthogonal matrix, rotation by $\pi/2$, then so do the vectors $U\boldsymbol{w}(t)$, $U\boldsymbol{x}(t)$, $U\boldsymbol{y}(t)$ and $U\boldsymbol{z}(t)$. Global uniqueness of the solutions of our IVP implies that $$\boldsymbol{y}\,=\,U\boldsymbol{x},\,\,\,\, \boldsymbol{z} \,=\, U\boldsymbol{y},\,\,\,\, \boldsymbol{w} \,=\, U\boldsymbol{z} \,\,\,\,\,\,\text{and}\,\,\,\,\,\, \boldsymbol{x}\,=\,U\boldsymbol{w}.$$ This symmetry reduces $\mathrm{(i)-(ii)}$, from an IVP of an $8\times 8$ system, to one of a $2\times 2$ system $$\boldsymbol{x}^\prime\,=\, \frac{{U}\boldsymbol{x}-\boldsymbol{x}} {\|U\boldsymbol{x}-\boldsymbol{x}\|}, \quad \boldsymbol{x}(0) \,=\,\boldsymbol{A}\,=\,(1,1). \tag{1}$$ Let $\boldsymbol{\varphi}$ be the solution of (1). Then $\boldsymbol{\varphi}$ shall also satisfy $$\boldsymbol{\varphi}^\prime(t) \, = \, \alpha(t) \bigl(U\boldsymbol{\varphi}(t)-\boldsymbol{\varphi}(t)\bigr) \, = \, \beta^\prime(t)(U-{\mathcal I})\boldsymbol{\varphi}(t), \tag{2}$$ where $$\alpha(t)\,=\, \| U\boldsymbol{\varphi}(t)-\boldsymbol{\varphi}(t) \|^{-1} \qquad\text{and}\qquad \beta(t)\,=\,\int_0^t\alpha(s)\,ds.$$ Hence $$\boldsymbol{\varphi}(t)\,=\, \mathrm{e}^{\beta(t){(U-{\mathcal I})}}\boldsymbol{\varphi}(0),$$ where ${\mathcal I}$ is the unit $2\!\times\! 2$ matrix.

Here we used the fact that if $\,\boldsymbol{w}'=f(t)B\boldsymbol{w},\,$ where $\boldsymbol{w}$ is an $n-$vector, $f$ a scalar function and $B$ a constant $n\times n$ matrix, then $\,\boldsymbol{w}(t) =\mathrm{e}^{(\int_0^t f(s)\,ds)B}\boldsymbol{w}(0).$

We also have that $$\mathrm{e}^{t(U-{\mathcal I})} \,=\, \mathrm{e}^{-t{\mathcal I}}\mathrm{e}^{tU} \,=\, \mathrm{e}^{-t}\mathrm{e}^{tU} \,=\, \left(\! \begin{array}{rr} \mathrm{e}^{-t}\cos t & -\mathrm{e}^{-t} \sin t \\ \mathrm{e}^{-t}\sin t & \mathrm{e}^{-t}\cos t \end{array} \!\right)\!,$$ and consequently \begin{align*} \boldsymbol{\varphi}(t) =\mathrm{e}^{-\beta(t)} \left(\! \begin{array}{rr} \cos \beta(t) & -\sin \beta(t) \\ \sin \beta(t) & \cos \beta(t) \end{array} \!\right) \left(\! \begin{array}{r} 1 \\ 1 \end{array} \!\right) =\mathrm{e}^{-\beta(t)} \big(\cos\beta(t)-\sin\beta(t),\cos\beta(t)+\sin\beta(t)\big). \end{align*} Also $$(U-{\mathcal I}) \boldsymbol{\varphi}(t)= \left(\!\!\begin{array}{rr} -1 & -1 \\ 1 & -1 \end{array}\!\right) \boldsymbol{\varphi}(t) \,=\, -2\mathrm{e}^{-\beta(t)} \bigl( \cos \beta(t), \sin\beta(t)\bigr),$$ and therefore, $$\big\| (U-{\mathcal I}) \, \boldsymbol{\varphi}(t) \big\| = 2\mathrm{e}^{-\beta(t)}. \tag{3}$$ Since $\,\| \boldsymbol{\varphi}^\prime(t) \| =1$, then combining (2) and (3) we obtain \begin{align} 1=\big\| \boldsymbol{\varphi}^\prime(t) \big\| =\big\|\beta^\prime(t)(U-{\mathcal I})\boldsymbol{\varphi}(t)\big\| =2\,\mathrm{e}^{-\beta(t)}\beta'(t). \end{align} Integrating the above in the interval $[0,t]$ we obtain that \begin{equation*} \mathrm{e}^{-\beta(t)}\,=\,1-\frac{t}{2}, \end{equation*} since $\,\beta(0)=0$. Thus, \begin{equation*} \beta(t)\,=\,-\log\left(1-\frac{t}{2}\right). \end{equation*} Hence $$\big\| \boldsymbol{\varphi}(t)-\boldsymbol{\chi}(t) \big\| \,=\, \big\| (U-{\mathcal I})\,\boldsymbol{\varphi}(t) \big\|=2\mathrm{e}^{-\beta(t)} =2-t.$$ Thus, the four ants, at any given moment $t$, before converging to the centre of the square, they lie on the vertices on a rotating and shrinking square of side $$\mu(t)=\big\| \boldsymbol{\varphi}(t)-\boldsymbol{\chi}(t) \big\|=2-t,$$ where $\,\boldsymbol{\chi}(t)$ is the position of the next ant. Note that the shrinking rate is constant ($d\ell/dt=1$), while the rotation is described by the angle $$\beta(t)\,=\,-\log\left(1-\frac{t}{2}\right),$$ tends to infinity, as $t$ tends to the time of convergence $T=2$. Until the convergence in the center, each ant will have covered distance \begin{equation*} s = \int_0^{2} \! \| \boldsymbol{x}^\prime(t) \|\,dt =2, \end{equation*} i.e., each ant covers distance equal to the side of the square, before they all meet in the center of the square. We also obtain the trajectories of the ants \begin{align*} \boldsymbol{\varphi}(t)&=\frac{2-t}{\sqrt{2}} \bigl( \cos(\beta(t)-\pi/4),\sin(\beta(t)-\pi/4) \bigr) \\ &=\frac{2-t}{\sqrt{2}} \bigg( \cos\Big(\log\Big(1-\frac t2\Big)+\frac{\pi}{4}\Big), -\sin\Big(\log\Big(1-\frac t2\Big)+\frac{\pi}{4}\Big) \bigg). \end{align*} Observe that the ant will have made infinitely many rounds around the center of the square before they converge there.

• Very nice. Also: shouldn't $(2)$ be $\alpha (t)$ instead of ${1\over{\alpha(t)}}$ ? Commented Dec 15, 2016 at 22:09
• @RutgerMoody You are right. Thanx! Commented Dec 16, 2016 at 10:47

You could formulate a differential equation for each ant, but you can also use the symmetry of the problem. Namely the positions of each ant has rotational symmetry. If we define the position of the first ant as $\begin{bmatrix}x & y\end{bmatrix}^T$ relative to the origin, then the second ant has a position rotated by 90° clockwise, which gives $\begin{bmatrix}y & -x\end{bmatrix}^T$, the third ant will be at $\begin{bmatrix}-x & -y\end{bmatrix}^T$ and the forth ant will be at $\begin{bmatrix}-y & x\end{bmatrix}^T$.

Now the first ant is walking towards the second ant with unit speed. So the velocity of the first ant (denoted by $\vec{v}_1$) can be written as the vector pointing from ant one (denoted with $\vec{p}_1$) to ant two (denoted with $\vec{p}_2$), which has a length of one, which can be obtained by dividing the vector by its length,

$$\vec{p}_2 - \vec{p}_1 = \begin{bmatrix}y & -x\end{bmatrix}^T - \begin{bmatrix}x & y\end{bmatrix}^T = \begin{bmatrix}y-x & -x-y\end{bmatrix}^T, \tag{1}$$

$$\vec{v}_1 = \frac{\vec{p}_2 - \vec{p}_1}{\|\vec{p}_2 - \vec{p}_1\|} = \frac{\begin{bmatrix}y-x & -x-y\end{bmatrix}^T}{\sqrt{(y-x)^2 + (-x-y)^2}} = \frac{\begin{bmatrix}y-x & -x-y\end{bmatrix}^T}{\sqrt{2\,(x^2+y^2)}}. \tag{2}$$

The velocity of the first ant is the same as the time derivative of its position, therefore the expression for $\vec{v}_1$ can also be used to formulate the differential equation,

$$\frac{d}{dt}\begin{bmatrix}x \\ y\end{bmatrix} = \frac{1}{\sqrt{2\, (x^2 + y^2)}} \begin{bmatrix}y-x \\ -x-y\end{bmatrix}. \tag{3}$$

Here's a start to deriving the differential equations:

• Let $\vec{r}_1(t)$ be the position of ant number 1 and $\vec{r}_2(t)$ be the position of ant number 2.
• a unit vector pointing from ant number 1 to ant number 2 would be: $\frac{\vec{r}_2(t)-\vec{r}_1(t)}{||\vec{r}_2(t)-\vec{r}_1(t)||}$

This is supposed to be the velocity of ant number 1, so we have:

$\frac{d\vec{r}_1}{dt}=\frac{\vec{r}_2(t)-\vec{r}_1(t)}{||\vec{r}_2(t)-\vec{r}_1(t)||}$

You can find the differential equations for the positions of the other ants the same way.

I found one similar problem to your question. And in that link its explained very nicely.