Saturday, 28 November 2020

Velociraptor pursuit

Today, we are going to solve the second question of this xkcd: https://xkcd.com/135/

xkcd 135

You’re at the centre of a 20m equilateral triangle with a raptor at each corner. The top raptor has a wounded leg and is limited to a top speed of 10 m/s.
The raptors will run toward you. At what angle should you run to maximize the time you stay alive?
(It is assumed that you have a speed of 6m/s and the unwounded velociraptor has a top speed of 25 m/s, from the first question). We are also removing the fact that the velociraptors and you have to speed up, and assume they are going at full speed at the start.

Pursuit curve

First, we are going to take a look at the following problem:

Assume a velociraptor starts running in your direction with a speed of kk times you speed, while you start at point (Ax,Ay)(A_x, A_y) running in the yy direction, what is the distance you can run?
According to wikipedia, the yy coordinate of the capture point is limxAxy(x)=12(Ay+Ax2+Ay21VtVd+AyAx2+Ay21+VtVd)\lim _{x\to A_{x}}y(x)={\frac {1}{2}}\left({\frac {A_{y}+{\sqrt {A_{x}^{2}+A_{y}^{2}}}}{1-{\frac {V_{t}}{V_{d}}}}}+{\frac {A_{y}-{\sqrt {A_{x}^{2}+A_{y}^{2}}}}{1+{\frac {V_{t}}{V_{d}}}}}\right)
Thus the distance ran is
d=12(Ay+Ax2+Ay21VtVd+AyAx2+Ay21+VtVd)Ayd = {\frac {1}{2}}\left({\frac {A_{y}+{\sqrt {A_{x}^{2}+A_{y}^{2}}}}{1-{\frac {V_{t}}{V_{d}}}}}+{\frac {A_{y}-{\sqrt {A_{x}^{2}+A_{y}^{2}}}}{1+{\frac {V_{t}}{V_{d}}}}}\right) - A_y
If we swap VtVd\frac {V_{t}}{V_{d}} by kk and AxA_x by Rcos(α)R\cos(\alpha) and AyA_y by Rsin(α)R\sin(\alpha) we get:

d=12(Rsin(α)+R1k+Rsin(α)R1+k)Rsin(α)=12(Rsin(α)+R)(1+k)+(Rsin(α)R)(1k)1k2Rsin(α)=Rsin(α)+R+Rsin(α)k+Rk+Rsin(α)RRsin(α)k+Rk22k2Rsin(α)=Rsin(α)+Rk1k2Rsin(α)=R(sin(α)+ksin(α)+k2sin(α)1k2)=Rk(1+ksin(α)1k2)\begin{aligned}d &= {\frac {1}{2}}\left({\frac {R\sin(\alpha)+R}{1-k}}+{\frac {R\sin(\alpha)-R}{1+k}}\right) - R\sin(\alpha)\\ &= {\frac {1}{2}}{\frac {(R\sin(\alpha)+R)(1+k)+(R\sin(\alpha)-R)(1-k)}{1-k^2}} - R\sin(\alpha)\\ &= {\frac {R\sin(\alpha)+R+R\sin(\alpha)k+Rk+R\sin(\alpha)-R-R\sin(\alpha)k+Rk}{2-2k^2}} - R\sin(\alpha)\\ &= {\frac {R\sin(\alpha)+Rk}{1-k^2}} - R\sin(\alpha)\\ &= R\left({\frac {\sin(\alpha)+k- \sin(\alpha)+k^2\sin(\alpha)}{1-k^2}} \right)\\ &= Rk\left({\frac {1+k\sin(\alpha)}{1-k^2}} \right)\\\end{aligned}

The time you can stay alive is relative to the distance you can run, as you can run at constant speed. If the angle you run at is θ\theta, the time you stay alive in total is the minimal time you stay alive considering each individual raptor.
So the minimal of these three expressions:
Rk(1kcos(α+2π/3)1k2)Rk\left({\frac {1-k\cos(\alpha+2\pi/3)}{1-k^2}} \right)
Rk(1kcos(α+4π/3)1k2)Rk\left({\frac {1-k\cos(\alpha+4\pi/3)}{1-k^2}} \right)
Rκ(1κcos(α)1κ2)R\kappa\left({\frac {1-\kappa\cos(\alpha)}{1-\kappa^2}} \right)

Where κ\kappa is your speed over the speed of the wounded velociraptor 6/106/10 and kk is the speed of a healthy velociraptor over your speed 6/256/25. Plotting the survival time for each velociraptor gives us the following figure.
velociraptor
We get a rather surprising result. The bottom velociraptors can catch up with us before the top one, independent of the angle, so we can ignore it. This also means that the optimal strategy is running towards the wounded velociraptor.