# Solved ChallengeSocial distancing problem

#### MarkFL

Staff member
Hello everyone! This problem was posted on another site (I am paraphrasing):

A and B are initially 12 feet apart, and they wish to swap positions. A moves directly towards B's initial position without regard for social distancing, while B wishes to maintain a minimum distance of 6 ft. from A. Both move at the same constant speed/. What is the minimum distance B must travel?

I have worked on this for some 5 days now, to no avail. I have filled pages of calculations, all leading to a huge intractable mess. I would be interested in seeing your thoughts on this extremely interesting yet difficult problem. #### Klaas van Aarsen

##### MHB Seeker
Staff member
Nice problem that relates directly to our current world wide predicament.
What to do if someone approaches you head on when you really want to maintain the recommended social distance. I have no actual solution, just some thoughts and a TikZ graph.
I believe B should move the first 6 feet in a straight line at an angle of 60 degrees.
I can prove that is optimal.
Then B should move to stay at exactly 6 feet distance, until they can move straight to the opposite position.
Finally B should of course move in a straight line to the opposite position.

However the corresponding curve of the stay-at-6-feet phase is the solution of a differential equation that does not seem solvable in closed form. The best I think I can do is to solve it numerically.

Just for fun, here's a diagram of the first phase.
I've put B at the origin where they have A incoming.

\begin{tikzpicture}[
scale=1,
>=stealth,
declare function={
angleB(\d) = acos((\d^2+(12-\d)^2-6^2)/(2*\d*(12-\d)));
}
]
\foreach \d in {5,5.5,...,7} {
\fill[help lines] ({12-\d},0) circle (.03);
\draw[help lines] ({12-\d},0) circle (6);
\draw[help lines] (0,0) -- ({acos((\d^2+(12-\d)^2-6^2)/(2*\d*(12-\d)))}:\d);
\fill[help lines] ({angleB(\d)}:\d) circle (.03) node[above left] {\d};
};
\def\d{6}
\begin{scoped}
\draw[red] ({12-\d},0) circle (6) -- ({12-\d-1},0);
\fill[red] (12,0) circle (.06) node[above right] {A};
\fill[red] ({12-\d},0) circle (.06) node[above] {A};
\draw[->, red, ultra thick] ({12},0) -- ({12-1},0);
\draw[->, red, ultra thick] ({12-\d},0) -- ({12-\d-1},0);
\end{scoped}
\begin{scoped}
\draw[blue] (0,0) -- ({angleB(\d)}:\d);
\fill[blue] (0,0) circle (.06) node[above left] {B};
\fill[blue] ({angleB(\d)}:\d) circle (.06) node[below right] {B};
\draw[->, blue, ultra thick] (0,0) -- ({angleB(\d)}:1);
\draw[->, blue, ultra thick] ({angleB(\d)}:\d) -- +({angleB((\d+1))}:1);
\end{scoped}
\end{tikzpicture}

For the record, I think explaining the problem to the person in question works better than evasion.
And shout, put an obstacle in between, and/or show you're angry if it happens too fast or if they are not listening. #### MarkFL

Staff member
Nice problem that relates directly to our current world wide predicament.
What to do if someone approaches you head on when you really want to maintain the recommended social distance. I have no actual solution, just some thoughts and a TikZ graph.
I believe B should move the first 6 feet in a straight line at an angle of 60 degrees.
I can prove that is optimal.
Then B should move to stay at exactly 6 feet distance, until they can move straight to the opposite position.
Finally B should of course move in a straight line to the opposite position.

However the corresponding curve of the stay-at-6-feet phase is the solution of a differential equation that does not seem solvable in closed form. The best I think I can do is to solve it numerically.

Just for fun, here's a diagram of the first phase.
I've put B at the origin where they have A incoming.

\begin{tikzpicture}[
scale=1,
>=stealth,
declare function={
angleB(\d) = acos((\d^2+(12-\d)^2-6^2)/(2*\d*(12-\d)));
}
]
\foreach \d in {5,5.5,...,7} {
\fill[help lines] ({12-\d},0) circle (.03);
\draw[help lines] ({12-\d},0) circle (6);
\draw[help lines] (0,0) -- ({acos((\d^2+(12-\d)^2-6^2)/(2*\d*(12-\d)))}:\d);
\fill[help lines] ({angleB(\d)}:\d) circle (.03) node[above left] {\d};
};
\def\d{6}
\begin{scoped}
\draw[red] ({12-\d},0) circle (6) -- ({12-\d-1},0);
\fill[red] (12,0) circle (.06) node[above right] {A};
\fill[red] ({12-\d},0) circle (.06) node[above] {A};
\draw[->, red, ultra thick] ({12},0) -- ({12-1},0);
\draw[->, red, ultra thick] ({12-\d},0) -- ({12-\d-1},0);
\end{scoped}
\begin{scoped}
\draw[blue] (0,0) -- ({angleB(\d)}:\d);
\fill[blue] (0,0) circle (.06) node[above left] {B};
\fill[blue] ({angleB(\d)}:\d) circle (.06) node[below right] {B};
\draw[->, blue, ultra thick] (0,0) -- ({angleB(\d)}:1);
\draw[->, blue, ultra thick] ({angleB(\d)}:\d) -- +({angleB((\d+1))}:1);
\end{scoped}
\end{tikzpicture}

For the record, I think explaining the problem to the person in question works better than evasion.
And shout, put an obstacle in between, and/or show you're angry if it happens too fast or if they are not listening. Hello, Klaas! It sounds like we came to the same conclusion for this problem. Here is my first post on the other site in response to the problem:

I would use coordinate geometry, and put A initially at $$(12,0)$$ and B at the origin. Without loss of generality we can let their speeds be 1 unit of distance per 1 unit of time.

For the first leg of B's path, let's let that path be described parametrically by the line:

$$\displaystyle \left\langle \frac{1}{\sqrt{a^2+1}}t,\frac{a}{\sqrt{a^2+1}}t \right\rangle$$

A's location is on the line:

$$\displaystyle \langle 12-t,0\rangle$$

The square of distance $$D$$ between A and B is then:

$$\displaystyle D^2=\left(\frac{1}{\sqrt{a^2+1}}t-(12-t)\right)^2+\left(\frac{a}{\sqrt{a^2+1}}t\right)^2$$

Use of differential calculus reveals that the minimum distance is

$$\displaystyle D_{\min}=72\left(1-\frac{1}{\sqrt{a^2+1}}\right)$$

We want this to be 36 units, hence:

$$\displaystyle 72\left(1-\frac{1}{\sqrt{a^2+1}}\right)=36$$

And taking the positive root, we obtain:

$$\displaystyle a=\sqrt{3}$$

This minimum occurs then for:

$$\displaystyle 6^2=\left(\frac{3}{2}t-12\right)^2+\left(\frac{\sqrt{3}}{2}t\right)^2$$

$$\displaystyle 48=3(t-8)^2+t^2$$

$$\displaystyle t=6$$

And so B has traveled 6 units of distance. Here's a live graph of this first leg of the journey:

Beyond this point, I am thinking B should cannot walk along the moving circumference of A's position without simply being pushed back along a horizontal line. It seems to me B should continue the linear trajectory until reaching the line $$y=6$$, or for:

$$\displaystyle 0\le t\le\frac{12}{\sqrt{3}}$$

Then B should travel some distance long this horizontal line until the moment it can begin a linear trajectory towards the final destination being tangent to the moving circle as it was during the first leg of the journey.

I will leave you to work with that for now, and revisit this topic later. After some reflection I next posted this:

The more I think about it, the more I have doubt about whether what I posted above is on the right track. Once point B moves beyond the tangent point, it rises above the circle, which means there is some part of the upward component of the velocity function that should be utilized to move the point forward instead. The slope of the trajectory should match that of the moving circle.

I'm going to have to ponder this some more...
Some time later I posted this:

I'm still working on this...I have approximated what I think the path up to $$y=6$$ should look like here:

I'm continuing to work with some rather difficult differential equations in the meantime.
This is the work I did, but did not post because I don't think it's correct:

We have let A so far move along the $$x$$-axis and B move along the line $$y=\sqrt{3}x$$ until both have moved a distance of 6 units.

During this next phase of the journey A is at the point:

$$\displaystyle (6-t,0)$$

And B is at the point:

$$\displaystyle (x,y)$$

The line normal to B's path can be given by:

$$\displaystyle y=-\frac{dx}{dy}(x-(6-t))$$

$$\displaystyle \frac{dy}{dx}=\frac{6-t-x}{y}$$

Since B moves $$t$$ units of distance in that amount of time, we may write:

$$\displaystyle t=\int_0^x \sqrt{1+\left(y'(u) \right)^2}\,du$$

And so this implies:

$$\displaystyle 6-x-y\frac{dy}{dx}=\int_0^x \sqrt{1+\left(y'(u) \right)^2}\,du$$

Differentiating with respect to $$x$$, we obtain:

$$\displaystyle -\left(1+\left(\frac{dy}{dx}\right)^2+y\frac{d^2y}{dx^2}\right)=\sqrt{1+\left(\frac{dy}{dx}\right)^2}$$

Let:

$$\displaystyle u=1+\left(\frac{dy}{dx}\right)^2\implies \frac{du}{dx}=2\frac{dy}{dx}\frac{d^2y}{dx^2}\implies \frac{d^2y}{dx^2}=\frac{1}{2}\frac{du}{dy}$$

Now we have:

$$\displaystyle -\left(u+\frac{1}{2}y\frac{du}{dy}\right)=\sqrt{u}$$

Solving this ODE, we obtain:

$$\displaystyle u=\left(\frac{c_1-y}{y}\right)^2$$

Recall, we must have:

$$\displaystyle \left(\frac{dx}{dt}\right)^2+\left(\frac{dy}{dt}\right)^2=1\implies 1+\left(\frac{dy}{dx}\right)^2=\left(\frac{dt}{dx}\right)^2$$

$$\displaystyle \frac{dx}{dt}=\frac{y}{c_1-y}$$

$$\displaystyle \left(\frac{dy}{dt}\right)^2=1-\left(\frac{y}{c_1-y}\right)^2=\frac{c_1(c_1-2y)}{(c_1-y)^2}$$

$$\displaystyle \frac{dy}{dt}=\frac{\sqrt{c_1(c_1-2y)}}{c_1-y}$$

$$\displaystyle \frac{dy}{dx}=\frac{\sqrt{c_1(c_1-2y)}}{y}$$

$$\displaystyle \int \frac{y}{\sqrt{c_1(c_1-2y)}}\,dy=\int\,dx$$

$$\displaystyle -\frac{1}{3\sqrt{c_1}}(c_1+y)\sqrt{c_1-2y}=x+c_2$$

Now to determine the parameters.

$$\displaystyle c_1=3(2+\sqrt{3}),\,c_2=-(1+2\sqrt{3})$$

Hence:

$$\displaystyle -\frac{1}{3\sqrt{3(2+\sqrt{3})}}(3(2+\sqrt{3})+y)\sqrt{3(2+\sqrt{3})-2y}=x-(1+2\sqrt{3})$$

Let's look now at the parametric equations, specifically:

$$\displaystyle \frac{dy}{dt}=\frac{\sqrt{c_1(c_1-2y)}}{c_1-y}$$

$$\displaystyle \frac{y-2c_1}{3\sqrt{c_1}}\sqrt{c_1-2y}=t+c_2$$

Ugh. Okay, for the 2nd leg of the journey, let's try:

$$\displaystyle x(t)=6-t+6\cos\left(\frac{2\pi}{3}-f(t)\right)$$

$$\displaystyle y(t)=6\sin\left(\frac{2\pi}{3}-f(t)\right)$$

Considering speed, we require:

$$\displaystyle \left(-1-\sin\left(\frac{2\pi}{3}-f(t)\right)(-f'(t))\right)^2+\left(\cos\left(\frac{2\pi}{3}-f(t)\right)(-f'(t))\right)^2=1$$

$$\displaystyle \left(1-\sin\left(\frac{2\pi}{3}-f(t)\right)f'(t))\right)^2+\left(\cos\left(\frac{2\pi}{3}-f(t)\right)f'(t)\right)^2=1$$

$$\displaystyle f'(t)=2\sin\left(\frac{2\pi}{3}-f(t)\right)$$

$$\displaystyle -\artanh\left(\frac{1}{2}\left(1-\sqrt{3}\tan\left(\frac{f(t)}{2}\right)\right)\right)=t+c_1$$

$$\displaystyle f(t)=2\arctan\left(\frac{1+2\tanh(t+c_1)}{\sqrt{3}}\right)$$

$$\displaystyle c_1=-\artanh\left(\frac{1}{2}\right)$$

$$\displaystyle f(t)=2\arctan\left(\frac{1+2\tanh\left(t-\artanh\left(\frac{1}{2}\right)\right)}{\sqrt{3}}\right)$$

When I tried the resulting parametric equations, it was obvious B was moving far too quickly, and it was at that point I threw in the towel. #### Klaas van Aarsen

##### MHB Seeker
Staff member
Following up, I came up with this complete path for B with an approximate length of 17.5 feet.

\begin{tikzpicture}[
scale=1,
>=stealth,
declare function={
anglePhi(\t) = 2*atan(exp(2*((\t)-6)/6)/sqrt(3));
}
]
\foreach \d in {0,0.5,...,4.5} {
\fill[blue] ({\d/2},{\d*sqrt(3)/2}) circle (.06);
};
\foreach \d in {5,5.5,...,6} {
\fill[help lines] ({12-\d},0) circle (.03);
\draw[help lines] ({12-\d},0) circle (6);
\fill[blue] ({\d/2},{\d*sqrt(3)/2}) circle (.06);
};
\foreach \d in {6,6.5,...,8} {
\fill[help lines] ({12-\d},0) circle (.03);
\draw[help lines] ({12-\d},0) circle (6);
\draw[blue] ({12-\d-6*cos(anglePhi(\d))},{6*sin(anglePhi(\d))})
-- ({12-(\d+0.5)-6*cos(anglePhi(\d+0.5))},{6*sin(anglePhi(\d+0.5))});
\fill[blue] ({12-\d-6*cos(anglePhi(\d))},{6*sin(anglePhi(\d))}) circle (.06);
};
\def\dtwo{8.5}
\def\dthree{17.5}
\def\x2{12-\dtwo-6*cos(anglePhi(\dtwo))}
\def\y2{6*sin(anglePhi(\dtwo))}
\def\dx2{cos(atan(\y2/(12-\x2))}
\def\dy2{sin(atan(\y2/(12-\x2))}
\draw[blue] ({\x2},{\y2}) -- (12,0);
\foreach \d in {8.5,9,...,9.5} {
\fill[help lines] ({12-\d},0) circle (.03);
\draw[help lines] ({12-\d},0) circle (6);
\fill[blue] ({\x2 + (\d-\dtwo)*\dx2},{\y2 + (\d-\dtwo)*\dy2}) circle (0.06);
};
\foreach \d in {10,10.5,...,17.5} {
\fill[blue] ({\x2 + (\d-\dtwo)*\dx2},{\y2 + (\d-\dtwo)*\dy2}) circle (0.06);
};
\def\d1{6}
\begin{scoped}
\draw[red] ({12-\d1},0) circle (6);
\draw[red] ({12-\dtwo},0) circle (6);
\fill[red] (12,0) circle (.06) node[below right] {A};
\fill[red] ({12-\d1},0) circle (.06) node[above] {\d1};
\fill[red] ({12-\dtwo},0) circle (.06) node[above] {\dtwo};
\fill[red] (0,0) circle (.06) node[above left] {12};
\draw[->, red, ultra thick] ({12},0) -- ({12-1},0);
\end{scoped}
\begin{scoped}
\draw[blue] (0,0) -- (60:\d1);
\fill[blue] (0,0) circle (.06) node[below left] {B};
\fill[blue] (60:\d1) circle (.06) node[above left] {\d1};
\fill[blue] ({12-\dtwo-6*cos(anglePhi(\dtwo))},{6*sin(anglePhi(\dtwo))}) circle (.06) node[above right] {\dtwo};
\fill[blue] (12,0) node[above right] {\dthree};
\draw[->, blue, ultra thick] (0,0) -- (60:1);
\end{scoped}
\end{tikzpicture}

In particular I found that the stay-at-6-feet phase follows the curve
$$\begin{cases}x(t)=12 - vt - 6\cos(\phi(t)) \\ y(t) = 6\sin(\phi(t))\end{cases}$$
with $x(0)=6\cos(60^\circ)$ and $y(0)=6\sin(60^\circ)$, and where $\phi(t)$ is the angle where B is from the perspective of A.
It is given by:
$$\phi(t)=2\arctan\left(\frac 1{\sqrt 3} e^{2vt/6}\right)$$

Sorry, I'm currently too lazy to write down the derivation.

#### MarkFL

Staff member
Following up, I came up with this complete path for B with an approximate length of 17.5 feet.

\begin{tikzpicture}[
scale=1,
>=stealth,
declare function={
anglePhi(\t) = 2*atan(exp(2*((\t)-6)/6)/sqrt(3));
}
]
\foreach \d in {0,0.5,...,4.5} {
\fill[blue] ({\d/2},{\d*sqrt(3)/2}) circle (.06);
};
\foreach \d in {5,5.5,...,6} {
\fill[help lines] ({12-\d},0) circle (.03);
\draw[help lines] ({12-\d},0) circle (6);
\fill[blue] ({\d/2},{\d*sqrt(3)/2}) circle (.06);
};
\foreach \d in {6,6.5,...,8} {
\fill[help lines] ({12-\d},0) circle (.03);
\draw[help lines] ({12-\d},0) circle (6);
\draw[blue] ({12-\d-6*cos(anglePhi(\d))},{6*sin(anglePhi(\d))})
-- ({12-(\d+0.5)-6*cos(anglePhi(\d+0.5))},{6*sin(anglePhi(\d+0.5))});
\fill[blue] ({12-\d-6*cos(anglePhi(\d))},{6*sin(anglePhi(\d))}) circle (.06);
};
\def\dtwo{8.5}
\def\dthree{17.5}
\def\x2{12-\dtwo-6*cos(anglePhi(\dtwo))}
\def\y2{6*sin(anglePhi(\dtwo))}
\def\dx2{cos(atan(\y2/(12-\x2))}
\def\dy2{sin(atan(\y2/(12-\x2))}
\draw[blue] ({\x2},{\y2}) -- (12,0);
\foreach \d in {8.5,9,...,9.5} {
\fill[help lines] ({12-\d},0) circle (.03);
\draw[help lines] ({12-\d},0) circle (6);
\fill[blue] ({\x2 + (\d-\dtwo)*\dx2},{\y2 + (\d-\dtwo)*\dy2}) circle (0.06);
};
\foreach \d in {10,10.5,...,17.5} {
\fill[blue] ({\x2 + (\d-\dtwo)*\dx2},{\y2 + (\d-\dtwo)*\dy2}) circle (0.06);
};
\def\d1{6}
\begin{scoped}
\draw[red] ({12-\d1},0) circle (6);
\draw[red] ({12-\dtwo},0) circle (6);
\fill[red] (12,0) circle (.06) node[below right] {A};
\fill[red] ({12-\d1},0) circle (.06) node[above] {\d1};
\fill[red] ({12-\dtwo},0) circle (.06) node[above] {\dtwo};
\fill[red] (0,0) circle (.06) node[above left] {12};
\draw[->, red, ultra thick] ({12},0) -- ({12-1},0);
\end{scoped}
\begin{scoped}
\draw[blue] (0,0) -- (60:\d1);
\fill[blue] (0,0) circle (.06) node[below left] {B};
\fill[blue] (60:\d1) circle (.06) node[above left] {\d1};
\fill[blue] ({12-\dtwo-6*cos(anglePhi(\dtwo))},{6*sin(anglePhi(\dtwo))}) circle (.06) node[above right] {\dtwo};
\fill[blue] (12,0) node[above right] {\dthree};
\draw[->, blue, ultra thick] (0,0) -- (60:1);
\end{scoped}
\end{tikzpicture}

In particular I found that the stay-at-6-feet phase follows the curve
$$\begin{cases}x(t)=12 - vt - 6\cos(\phi(t)) \\ y(t) = 6\sin(\phi(t))\end{cases}$$
with $x(0)=6\cos(60^\circ)$ and $y(0)=6\sin(60^\circ)$, and where $\phi(t)$ is the angle where B is from the perspective of A.
It is given by:
$$\phi(t)=2\arctan\left(\frac 1{\sqrt 3} e^{2vt/6}\right)$$

Sorry, I'm currently too lazy to write down the derivation.
Thank you Klaas! Looks like I slipped somewhere there. I have forwarded your results to the growing list of people I have engaged with this problem. A friend of mine on another site, not a math site, who uses AutoCAD in his work, estimated the "stay at 6 ft" path with 2 inch line segments and got about 17' 5".