# Just driving around

I drove in a straight line for 10km in one direction then 20km in another direction and then 30km in another direction. Assume the Earth is flat. The three directions are not necessarily distinct from each other and may be at any angle (not just cardinal). What is the most likely (in mode) straight-line distance from my final location to my starting point? Bonus: what about most likely distance in expectation?

Here is my approach as the answer as

40

Here is the first condition where we drive in a straight line for 10 km and then another direction for 20 km. (|AB|=10)

The red lines are just examples among infinitively possible conditions on the the circle where you can go from;

where |BC| and |BD| are equal to 20 whereas |AB| is equal to 10.

we can formulate the distance from C and D to A, to find the distance for the first condition by using simple geometric rules;

$$\sqrt{a^2+b^2+2\cdot a\cdot b\cdot \cos {\measuredangle }}$$

which is the formula if you know two lengths and the angle in between them to find the opposite length, so with the values we have it will be;

$$|CA|=\sqrt{10^2+20^2+2\cdot 10\cdot 20\cdot \cos {\measuredangle_1 }}$$

where $$\measuredangle_1$$ changes from 0 to 180 or 360 (from 180 to 360 would be symmetric so it is not important)

and $$\measuredangle_1$$ is then angle between |BC| and |BA|.

Since we move 30km more, it makes everything more complicated;

so after defining C point where is just a point over 20km circle, we need to make another circle with the radius of 30km and statistically we need to have that circle for every point on 20km circle which makes the things a bit harder.

So the problem becomes all lengths over 30km circle to the A, such as |DA| and |EA|. But how can we formulate this?

To do that, let's draw something like below;

We know how to calculate |CA| already, but we need to find |EA| to solve the original problem as below just like what we did for the previous case;

$$|EA|=\sqrt{|CA|^2+30^2+2\cdot |CA|\cdot 30\cdot \cos {\measuredangle_2 }}$$

where $$\measuredangle_2$$ changes from 0 to 360.

so the problem becomes something like this;

What is the most frequent length |EA| where $$\measuredangle_2$$ changes from 0 to 360 and $$\measuredangle_1$$ changes from 0 to 180

where the formula is

$$|EA|=\sqrt{1400+400\cdot \cos {\measuredangle_1 }+60\cdot \sqrt{500+400\cdot \cos {\measuredangle_1 }}\cdot \cos {\measuredangle_2 }}$$

to do that, I simply used excel and python code to solve it and the result becomes;

$$40$$

and expected value (python code) which is the average of all possible conditions is around

$$34.4$$

and here is the graphical representation of the $$|EA|$$

where x and z axes are angles, y axis is $$|EA|$$.

• Well done! This is correct. I really like the diagrams, especially the 3D one. Do you have an intuitive explanation as to why the expected mode comes out to be a nice round number? Feb 11 at 6:34

The following is no mathematical solution, but a visualization with a lot of random angles:

The top graph shows 100'000 endpoints of the sum of 3 straight lines (10,20,30 km) having 3 random angles (0-360°). The angles are equally distributed between 0° and 360°.

The bottom graph shows a histogram of the distances from the origin put into bins having a width of 0.1.

So, the most likely straight-line distance from the origin seems to be:

~40 km

• why 3 angles? the first angle does not matter.
– Oray
Feb 10 at 21:13
• @Oray right, for the distance it doesn't matter, but for the absolute position (first plot) it matters. Feb 10 at 21:56
• Very nice plots. Thank you! Feb 11 at 6:36