# The Ant Problem

1. Mar 7, 2013

### Arkuski

Suppose there is an ant at each of the four corners of a square with side length 1, such that (0,0) and (1,1) are at opposite corners of the square. The ant at (0,0) is facing the ant at (1,0) is facing the ant at (1,1) and so forth. Each ant will choose its path such that it is always facing the ant in front of it. If you can imagine this situation, the ants should all meet at the center of the square. Assume the ants are traveling at some constant velocity 1 as well.

This situation can be described as a system of differential equations. Each ant travels in a path that is identical to some rotation of the other paths. For example, the path that ant (1,0) takes is a 90 degree counter-clockwise rotation of the path that ant (0,0) takes. Therefore, if ant (0,0) travels on path $(x(t),y(t))$, then ant (1,0) travels on path $(1-y(t),x(t))$. At any given point in time, ant (0,0) will be facing ant (1,0) such that $\frac{y'(t)}{x'(t)}=\frac{x(t)-y(t)}{1-x(t)-y(t)}$. Let's go ahead and state the entire system as it applies to ant (0,0):

$x'(t)^2+y'(t)^2=1$: Implies that velocity is constant
$\frac{y'(t)}{x'(t)}=\frac{x(t)-y(t)}{1-x(t)-y(t)}$
$x(0)=0$
$y(0)=0$
$x'(0)=1$
$y'(0)=0$

If anyone knows how to attack a problem like this please share your insight!

Last edited: Mar 8, 2013
2. Mar 7, 2013

### phinds

I don't know the math but I know the answer is a logarithmic spiral (well, 4 of them).

Maybe if you work it backwards in polar coordinates, with all 4 starting at the origin and moving away from each other, that will do it for you.

3. Mar 7, 2013

### Mute

The equation $\frac{y'(t)}{x'(t)}=\frac{1-x(t)-y(t)}{x(t)-y(t)}$ blows up at t=0 because x(0) = y(0) = 0, while x'(0) = 1. The LHS and RHS thus don't seem to agree at t=0. Is there a mistake in the equation?

Last edited: Mar 7, 2013
4. Mar 8, 2013

### Arkuski

Mute I fixed it. It was flipped

5. Mar 8, 2013

### Vargo

This will be far simpler to work out in polar coordinates. Why dont' you work out formulas for r'(t) and theta'(t) ?

If you want to convert back to rectangular in the end, then x(t)=r(t)cos(\theta(t))...

EDIT: Just to clarify, in polar coordinates your origin should be the center of the square, not the initial point of one of the ants.

Last edited: Mar 8, 2013
6. Mar 10, 2013

### Staff: Mentor

Square the second equation and combine it with the first to obtain:

$$y'=\frac{x-y}{\sqrt{(1-x-y)^2+(x-y)^2}}$$
$$x'=\frac{(1-x-y)}{\sqrt{(1-x-y)^2+(x-y)^2}}$$

This coupled pair of ODE's looks like a fairly straightforward system to solve analytically.

Last edited: Mar 11, 2013
7. Mar 11, 2013

### Vargo

Ok in polar coordinates, set up the origin as the center of the square. After any amount of time the ants will still form a square with the same center. So you can draw the velocity vector of which points inward at a forty five degree angle with the radial direction. And its length is 1. using the radial component, r' = const. Using the angular component, (rtheta)' = const. You just find the constants from looking at the simple diagram, and then solve for r(t) and then solve for theta(t). ezpz.

8. Mar 11, 2013

### Staff: Mentor

Here's some more ezpz. Substitute:
$$x=\frac{1}{2}-X$$
$$y=\frac{1}{2}-Y$$
$$d\xi={\sqrt{(1-x-y)^2+(x-y)^2}}dt$$
to obtain:
$$\frac{dX}{d\xi}=-X-Y$$
$$\frac{dY}{d\xi}=X-Y$$

Initial condition: $$X=Y=\frac{1}{2}$$

9. Mar 14, 2013

### HallsofIvy

Which is the same as
$$\frac{dY}{dX}= -\frac{X- Y}{X+ Y}$$
Y(1/2)= 1/2.

10. Mar 14, 2013

### Staff: Mentor

Hi HallsofIvy,
I haven't been able to solve the trajectory equation analytically when expressed in this form, although, of course, that doesn't mean that it can't be done. On the other hand, the analytic solution to the pair of parametric coupled ODEs that I gave is very straightforward. Have you been able to solve the single ODE analytically? I haven't been able to work my analytic solution parameterized in terms of $\xi$ into a form that eliminates $\xi$.

Chet

11. Mar 14, 2013

### bigfooted

This is a rational equation, and also an Abel equation of the second kind.
The solution can be obtained implicitly as:
$-\frac{1}{2}\ln(\frac{x^2+y^2}{x^2})-\arctan(\frac{y}{x})-\ln(x) = C$

Better stick to the decoupled system, which is easier to solve because it's linear, just decouple and solve individually:
$x(t)=e^{-t}(c_1\sin(t)+c_2\cos(t)), y(t)=e^{-t}(c_2\sin(t)-c_1\cos(t))$

edit: (oops, sorry for giving it away!)

12. Mar 18, 2013

### mikeph

I came across a similar problem with 3 ants about 10 years ago, and spent hours and hours on it before forgetting about it. This just reminded me about it!

Looking at the maths involved it seems I had no chance. :rofl:

13. Mar 18, 2013

### Vargo

Bigfoot, your solution is incorrect. The trajectory should have constant speed and yours decays exponentially. The solution should reach the origin in finite time.

Also, the equation that Halls wrote down is an example of a first order homogeneous equation. So you could solve it using another change of variables. u =Y/X. Perhaps that is what bigfoot did to get his implicit solution. Still, I agree with Chester, solutions in terms of t are much clearer here.

http://en.wikipedia.org/wiki/Homogeneous_differential_equation#Homogeneous_functions

14. Mar 19, 2013

### Staff: Mentor

I disagree, regarding Bigfoot's solution. It looks OK to me. He simply inadvertently used t as the parametric variable, rather than my $\xi$ (and used x and y instead of my X and Y). You can easily find the relationship between t and $\xi$ once you know the solution for X and Y. I think you will find that when t is infinite, $\xi$ is equal to unity.

Chet

15. Mar 19, 2013

### Vargo

Oh I see. You're right of course. I saw the t and my mind forgot about the change of variables.