A pig runs from one corner of a square pen toward the gate at an adjacent corner while the farmer, starting...
analysis/pig.and.farmer New
New entry, edited from material collected for the archive and not yet in a released version.
Problem
A pig runs from one corner of a square pen toward the gate at an adjacent corner while the farmer, starting at the opposite corner, always runs straight at the pig. How fast must the farmer run? There is a square pig pen with a gate in one corner. There is a farmer at the opposite corner and a pig in one of the other two. The gate is left open and the pig runs with constant velocity towards it. If the farmer runs directly at the pig (also with constant velocity), how fast must he run?
Show solution
When the solution to this problem was first presented on this forum,
the author stated that he/she did not have a closed form solution for
the path of the farmer. Well, I think I have one so here goes...
Put the pig at (0,0) and the farmer at (1,0) at time t = 0 and have the
pig run towards (0,1). If the pig has velocity 'a' then the pigs
position is (0,at). Let the farmer's position be given by x(t) and
y(t) and his speed by 'b'. Since the farmer goes directly towards the
pig:
dy/dx = (at - y)/(0 - x) = (y - at)/x
or xy' = y - at
Since x(t) is monotonic, we can think of t as a function of x -- t(x).
Thus
Dx ( xy' = y - at ) => y' + xy" = y' - a(dt/dx) or xy" = -a(dt/dx)
Now, considering the farmer's path... ds^2 = dx^2 + dy^2 and
ds = - sqrt(1 + y'^2) dx
Now, dt/dx = (dt/ds)(ds/dx). ds/dt = b so...
dt/dx = (-1/b)sqrt(1 + y'^2)
Plugging into our Dx equation, we get:
xy" = (a/b)sqrt(1 + y'^2) let (a/b) = k, the relative speed of
the pig to the farmer.
let P = dy/dx = y'. Then dP/dx = P' = y".
So our equation becomes...
xP' = k sqrt(1 + P^2) or (x^2)(P'^2) = (k^2)(1 + P^2)
If we solve this DE for P, we can integrate and find the path the
farmer takes.
Suppose P(x) = A x^q + B x^r
Then P'(x) = A q x^(q-1) + B r x^(r-1)
Also:
P(x)^2 = A^2x^2q + 2ABx^(q+r) + B^2x^2r and
P'(x)^2 = (Aq)^2x^(2q-2) + 2ABqrx^(q+r-2) + (Br)^2x^(2r-2)
So our equation now becomes:
(Aq)^2x^2q + 2ABqrx^(q+r) + (Br)^2x^2r =
= 2k^2ABx^(q+r) + (Ak)^2x^2q + (Bk)^2x^2r + k^2
Equating like terms, we find:
q = -r = k and P(x) = A x^k + B x^(-k)
P'(x) = kAx^(k-1) - kBx^(-k-1)
Comparing the x^(q+r) terms from before, we get:
-2ABk^2 = k^2 + 2ABk^2 or AB = -1/4 so B = -1/4A
Now, y'(1) = P(1) = 0 = A - 1/4A or A = 1/2 (thus B = -1/2) and
dy/dx = P(x) = 1/2[x^k - x^(-k)]
Integrating, we get:
y(x) = (1/2)[x^(1+k)/(1+k) - x^(1-k)/(1-k)] + C
Our initial conditions give y(0) = 1 and y(1) = 0 so
C = 1 and -2 = 1/(1+k) - 1/(1-k)
Solving for k gives k^2 + k - 1 = 0 or k = [-1 + sqrt(5)]/2
And there we are... the farmer's path is described explicitly as
y(x) = (1/2)[x^(1+k)/(1+k) - x^(1-k)/(1-k)] + 1 where k is the g.r.
(<1)
-- Matt <mroozee@math.uci.edu>
[ Editor: so the pig's speed is k = 0.618... times the farmer's: the
farmer must run 1/k = (1+sqrt(5))/2 = 1.618... times as fast as the
pig to reach it at the gate. The earlier solution referred to above was not found in
the collected postings. ]