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.

Sunday, 22 November 2020

Rational regular polygons

Is it possible to create a regular polygon where all coordinates of vertices are rational numbers?

Equilateral triangle

Assume it is possible to create an equilateral triangle
If we call the points (x1,y1),(x2,y2),(x3,y3)(x_1,y_1),(x_2,y_2),(x_3,y_3) the surface area of the triangle is 12(x1y2+x2y3+x3y1x1y3x2y1x3y2)\frac{1}{2}(x_1y_2+x_2y_3+x_3y_1-x_1y_3-x_2y_1-x_3y_2)
But because the triangle is equilateral, the area also is:
12bh=123b2=32((x1x2)(y1y2))2\frac{1}{2} bh=\frac{1}{2}\sqrt{3}b^2=\frac{\sqrt{3}}{2} \left(\sqrt{(x_1-x_2)(y_1-y_2)}\right)^2
Putting both systems equal to eachother gives:
x1y2+x2y3+x3y1x1y3x2y1x3y2=3((x1x2)(y1y2))2x_1y_2+x_2y_3+x_3y_1-x_1y_3-x_2y_1-x_3y_2=\sqrt{3} \left(\sqrt{(x_1-x_2)(y_1-y_2)}\right)^2

x1y2+x2y3+x3y1x1y3x2y1x3y2(x1x2)(y1y2)=3\frac{x_1y_2+x_2y_3+x_3y_1-x_1y_3-x_2y_1-x_3y_2}{ \left|(x_1-x_2)(y_1-y_2)\right|}=\sqrt{3}

As the left side is rational and the right side is irrational, this lead to a contradiction, so at least one of the coordinate points has to be irrational.

All polygons

The technique in general is the same. The surface area of a regular polygon is 14s2ncotπ/n\frac{1}{4} s^2 n \cot{\pi/n}. As according to Pick’s theorem the area of a rational polygon is rational, cotπ/n\cot{\pi/n} has to be rational. The only solution to this is n=4n=4, so the only polygon that can be constructed with 4 rational points are squares.

Squares

Now that we know that it is possible to create a square with 4 rational points, we can ask ourselves the question, what about a square with 3, 2, 1 or zero rational points. 1 and 0 are trivially possible. But what about the others?
Assume you have a square with at least two rational points. We can translate our squares, so that one of our squares is located at (0,0)(0,0), and the other one at (p,q)(p,q). If those two points were adjacent, the other two points would be (q,p)(-q,p) and (pq,p+q)(p-q,p+q). Another symmetric possibility is (q,p)(q,-p) and (p+q,p+q)(p+q,-p+q). If the points are at the opposite side of the triangle, the other points are (p+q2,p+q2)\left(\frac{p+q}{2},\frac{-p+q}{2}\right) and (pq2,p+q2)\left(\frac{p-q}{2},\frac{p+q}{2}\right). All these points are rational, so it is a square has at least two rational points, it certainly has 4.

Expanding this property to other polygons will be done in a future blogpost