Walking in a random direction

I walk $$\pi$$ km in one direction followed by $$\pi$$ km in another direction. In expectation how far am I now from my starting location? Both directions are chosen uniformly at random between $$0^{\circ}$$ and $$360^{\circ}$$.

P.S. The answer may surprise you.

• On a Euclidean plane? Or on a sphere? Or on a torus? Or… Feb 4 at 7:55
• On the plane ... Feb 4 at 10:56

Start at the origin $$(0,0)$$. If the two directions are $$t$$ and $$u$$, the ending location is $$\pi(\cos t+\cos u, \sin t+\sin u)$$ and the distance from the origin is $$\pi\sqrt{(\cos t+\cos u)^2+(\sin t+\sin u)^2} = \pi \sqrt{2+2\cos(t-u)}.$$ So the expected distance from the origin is $$\int_0^{2\pi} \int_0^{2\pi} \frac{\pi \sqrt{2+2\cos(t-u)}}{(2\pi)^2} \mathrm{d}t\, \mathrm{d}u = 4.$$

• Yep you got it! Feb 2 at 15:49
• Wow a solution without integer programming! ;) Feb 3 at 8:53
• @DmitryKamenetsky I was not expecting integer programming, and in fact a double integration is very intuitive.
– iBug
Feb 4 at 13:40
• @Dragongeek Yes, $2\pi$ and $0$ are the extreme values of the distribution, and the expected value $4$ is between them. Feb 4 at 20:03
• @Dragongeek Makes sense intuitively. After the first walk, you're a distance pi from the origin. From there, over half of the angles will send you even further away, so on average, you wind up a bit further away than pi. Feb 5 at 17:31

If we consider the angle between the two walks to be $$2\alpha$$, in which $$0\le\alpha<\pi/2$$ (since the case for $$\pi/2\le\alpha<\pi$$ is equivalent), then the distance between the two points is $$2\pi\sin\alpha$$. Therefore, taking the integral of that in the range yields $$\pi$$. Finally, we divide by $$\pi/2$$, which is our range, to get the expected value of $$2$$.

• I recall seeing this as a way to estimate $\pi$. Perhaps it is the needle-on-floor approximation? Feb 2 at 15:47
• This is the nicest and easiest way to do the integration, but there must be a factor 2 missing somewhere. I think your integral should yield $2\pi$ rather than $\pi$. Feb 2 at 15:52
• I agree that 4 makes more sense Feb 2 at 16:00
• $[-2\pi \cos \alpha]_0^{\pi/2}=2\pi$ Feb 2 at 16:03

Let the smaller angle between the two walks be $$\alpha$$, where $$0\le\alpha\le\pi.$$ Using the law of cosines, the distance from where you started is $$\sqrt{\pi^2+\pi^2-2\pi^2\cos\alpha}$$. Taking the integral of this, we get $$\frac{1}{\pi}\int^\pi_0 \sqrt{\pi^2+\pi^2-2\pi^2\cos\alpha}d\alpha=4.$$ So the expected value of $$\sqrt{\pi^2+\pi^2-2\pi^2\cos\alpha}$$ is $$4$$

• I got a hateful downvote, so I fixed my solution. Feb 4 at 22:58