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?


2 Answers 2


Here is my approach as the answer as


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

enter image description here

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;

enter image description here

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;

enter image description here

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;


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


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

enter image description here

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

  • $\begingroup$ 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? $\endgroup$ Feb 11 at 6:34

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

enter image description here

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.