11 October 2021

# Your evil DCDA twin (08/10/21 Riddler Classic)

Original puzzle

Shrink the problem (eww who even measures in feet) and work in the complex plane such that you start at $(-1-i)$ moving in the positive real axis, your twin starts at $(1+i)$ and the lamppost is at the origin. Let $A(t)$ and $B(t)=x(t)+iy(t)$ be you and your twin's locations respectively.

To solve this problem rigorously, we break your run down into two stages:

1. Before you pass the $A(t)=-i$ mark (ie. halfway), which we define as occurring at $t=0$. In this step, we shall show that $y(0)$ must be within the range $[0,2]$.
2. After you pass the $A(0)=-i$ mark. In this step, we show that $y(0)=2$ is the initial value that leads to a maximum twin-lamp distance at the end of the run.

To preview the final answer, the maximum possible final twin-lamp distance is $\boxed{2\sqrt{2}}$. One possible path leading to this result is the following:

### Stage 1: Before $t=0$

Suppose you run at a constant speed over the range $t\in[-1,0]$. Thus we have $A(t)=t-i$ and $|A(t)|=1$. Recall the twin's position $B(t)=x(t)+iy(t)$, with the constraint of $$x(t)=-ty(t)$$

which is the equation of the line that passes through $A(t)$ and the origin.

Substituting $x=-ty$ and differentiating $B(t)$ gives $$\dot{B}(t)=(-y-t\dot{y},\; \dot{y})$$

and we also know, given $|\dot{B}(t)|=2$:

\begin{align*}4&=|\dot{B}(t)|^2\\&=(y+t\dot{y})^2+\dot{y}^2\\&=(1+t^2)\dot{y}^2+2t\dot{y}y+y^2\\\therefore \dot{y}&=\frac{-ty\pm\sqrt{4t^2+(4-y^2)}}{1+t^2}\end{align*}

This is the differential equation governing the twin's movement, with the corresponding $x$-velocity given by $\dot{x}=-y-t\dot{y}$.

The critical piece of information is this:  $y$ cannot be greater than $2$ at $t=0$. This is because otherwise, the stuff under the square root will be negative, yielding no valid solution for $\dot{y}$. Physically, this means that at $t=0$, if the evil twin is further than 2 out from the lamppost, then they cannot run fast enough to stay hidden by the lamppost.

So, the only possible values for $y(0)$ are within the range $[0,2]$, if the twin is to complete the run.

An interesting fact that doesn't actually contribute to the proof at large is that if $y$ ever exceeds $2$, then both the positive and negative root solutions in $\dot{y}$ result in $\dot{y}>0$ for $t\in[-1,0]$.

To see why, note that the negative root solution above (which is the smaller solution) results in $\dot{y}=0$ if $y=2$ and $t<0$. Examining the numerator, increasing $y$ means that $(-ty)$ increases while $\Big(-\sqrt{4t^2+(4-y^2)}\Big)$ also increases. Hence $\dot{y}>0$ if $y>2$ and $t\in[-1,0]$.

The implication of this is that actually, if the twin is to complete the run, $y(t)$ can never exceed $2$ for all $t\in[-1,0]$. Otherwise, the $y$-coordinate will increase, eventually violating the constraint we found above for $y(0)\in[0,2]$. As I said, this fact does not actually help us complete the proof, but is interesting to note.

### Stage 2: After $t=0$

In Stage 1, we had you running at a constant linear speed. However, in Stage 2, we'll have you running at a constant angular speed around the origin. We'll need an alternate parameterisation for $A$ and $B$ in this case. For instance, we can use the following: $$A(t)=\sec(t)\cdot e^{i(t-\pi/2)}$$

for the new $t\in[0,\frac{\pi}{4}]$. Equivalently, we can redefine $B(t)$, noting that the twin must have an identical angular speed in order to stay hidden: $$B(t)=r(t)\cdot e^{i(t+\pi/2)}$$

for some magnitude function $r(t)$. This means that $y(t)=r(t)\sin(t+\frac{\pi}{2})$. At $t=0$, this reduces simply to $y(0)=r(0)$, and so $r(0)\in[0,2]$ as was concluded from Stage 1.

Now, the linear speed of $A(t)$ in this new parameterisation is given by \begin{align*}\dot{A}(t)&=\sec(t)\cdot e^{i(t-\pi/2)}\cdot (1+i\tan(t))\\&=A(t)\cdot(1+i\tan(t))\\\therefore|\dot{A}(t)|&=|A(t)|\cdot\sqrt{1+\tan^2(t)}\\&=\sec(t)\cdot\sqrt{\sec^2(t)}\\&=\sec^2(t)\end{align*}

which means your twin's speed is $|\dot{B}(t)|=2\sec^2(t)$ as they are twice as fast linearly. Now, we can directly differentiate $B(t)$ as \begin{align*}\dot{B}(t)&=(\dot{r}^2+ir^2)\cdot e^{i(t+\pi/2)}\\\therefore |\dot{B}(t)|^2 &= \dot{r}^2+r^2\end{align*}

and so equating the two expressions for $|\dot{B}(t)|$ yields the definining equation of motion for the twin: \begin{align*} \dot{r}^2+r^2&=4\sec^4(t)\\\therefore \dot{r}&=\sqrt{4\sec^4(t)-r^2}\end{align*}

Note that only the positive square-root solution is retained here, because the puzzle as a whole asks us to maximise the value of $r(\frac{\pi}{4})$, which means we want $\dot{r}(t)>0$.

So, in order to maximise $r(\frac{\pi}{4})$, we must check all the possible initial values of $r(0)\in[0,2]$ to see which initial value yields the maximal $r(\frac{\pi}{4})$. While we suspect that maximising $r(0)$ should also maximise $r(\frac{\pi}{4})$, I don't quite know how to prove this properly. Instead, we need to use some computing software to evaluate the differential equation numerically for various initial values, as the DE likely has no closed-form solution for arbitrary initial values (if a closed-form solution does exist, please let me know!)

As we can clearly see, the initial value of $r(0)=2$ yields the maximal value of $r(\frac{\pi}{4})$. In fact, the specific initial value $r(0)=2$ actually does lead to a closed-form solution! Indeed, $r(0)=2$ means $$r(t)=2\sec(t)$$which can be easily confirmed by substituting into the above differential equation.

Thus, the maximal twin distance is reached if $r(0)=2$ and $$B(t)=2\sec(t)e^{i(t+\pi/2)}$$

but this is simply the straight line that runs along the line $y(t)=2$. This is because \begin{align*}y(t)&=2\sec(t)\sin(t+\pi/2)\\&=2\sec(t)\cos(t)\\&=2\end{align*}

And so we have the maximum $\boxed{r\Big(\frac{\pi}{4}\Big)=2\sec\Big(\frac{\pi}{4}\Big)=2\sqrt{2}}$

### Final solution

All this kerfuffle means we now know the recipe to maximising the twin-lamp distance at the end of the run. We simply need to do the following:

1. Ensure the twin reaches $B(0)=2i$ at $t=0$. It does not matter how the twin reaches this point from the starting point. The twin has flexibility here due to the fact that at almost all times, there are two valid directions in which to run as a result of the positive and negative square root solutions as defined in Stage 1. The only constraint is that the twin must never exceed $y=2$.
2. Once the twin reaches $B(0)=2i$, they should stay on the $y=2i$ line until the run is finished.

Here are three possible paths that all maximise the end-run twin-lamp distance according to the above recipe. Note that while their initial paths are different, they all must meet at $B(0)=2i$:

As always, thanks for the puzzle Zach!