# Solve the “two trains and a fly” problem the hard way

Few days ago, I was asked the following question:

There are $2$ cities. city $A$ and city $B$ with distance $d$=600km
There are $2$ trains with speed of $vt$ = 100km/h.
There is $1$ fly with speed of $vf$ = 300km/h.

The question:
Train 1 goes from city A to city B , while Train 2 goes in the opposite direction.(both start at the same time). the fly starts from train 1 and go to train 2 , than back to train 1 , than back to train 2...etc...

What is the distance that the fly passes till the trains cross each other ?

The answer is simple - it takes 3 hours for the train to cross -> fly was running 900km($300 \times 3$).

I was wondering on the "hard" way of solving this problem by actually calculating the distance the fly pass on each stage. It appears to be the sum of a (finite?) series of the distances.

Could you help me solve this problem the "hard way" ?

• Correction: One hour = 3600 seconds. So 3 hours = ? – Namaste Aug 12 '14 at 15:33
• There is a nice discussion of this well-known problem to be found here. – Stefan Mesken Aug 12 '14 at 15:34
• See "Related" column on the right. – user147263 Aug 12 '14 at 15:35
• Those are some seriously fast trains. – Fly by Night Aug 12 '14 at 15:36
• @FlybyNight So fast that I almost want to ask in which frame of reference the trains start simultaneously. – David H Aug 12 '14 at 15:43

If the trains are distance $d$ apart and the fly starts on one train then it takes $d/(vt+vf)=d/400$ hours for the fly to reach the other train, and at that time the trains are $(2 vt) d/400 = d/2$ km apart, the fly having flown $(3 d/4)$ km. So after each trip from train to train the trains close by half the distance, so the fly travels $3 d/4+3d/8+3d/16+\cdots$, or $3d/4 \sum_{n=0}^\infty 1/2^n$. Now, the series $\sum_{n=0}^\infty 1/2^n$ is a geometric series of the form $\sum_{n=0}^\infty \alpha^n$ which if $|\alpha|<1$ equals $1/(1-\alpha)$, or in our case 2. So in our case, as $d=600$ the fly travels $2 * 3 * 600 / 4 = 900$km.

The story of von Neumann saying that he summed the series, always struck me as a completely reasonable approach. If you stare at geometric series all day, it is easy to recognize this problem as a series problem, and it is not much more difficult than using the "trick". In a certain sense, the "trick" is implicit in the formula.

• The way I've always heard this anecdote, it was von Neumann who summed the series. I have heard many Norbert Wiener stories, but this wasn't among them. – David K Aug 13 '14 at 1:39
• @david You're probably right. – deinst Aug 13 '14 at 1:49

For the $n^\text{th}$ leg of the journey of the fly:

• let $t_n$ be the time taken
• at the start of this leg:

• the total distance already travelled by both trains is $\quad 2v_t\sum_{i=1}^{n-1}t_i$
• the distance between the fly and the opposite train is $\quad d-2v_t\sum_{i=1}^{n-1}t_i$

Using Speed $\times$ Time = Distance, we have

\begin{align} (v_t+v_f)t_n&=d-2v_t\sum_{i=1}^{n-1}t_i\\ 400t_n&=600-200\sum_{i=1}^{n-1}t_i\\ 2t_n&=3-\sum_{i=1}^{n-1}t_i\\ \end{align}

Subtracting consecutive terms gives \begin{align}2(t_n-t_{n-1})&=-t_{n-1}\\ t_n&=\frac 12 t_{n-1}\end{align} which is a geometric series.

Hence $$t_n=\left(\frac 1{2^{n-1}} \right)t_1=\frac 32 \left(\frac 1{2^{n-1}} \right)=\frac 3{2^n}$$ and distance covered by the fly on the $n^{\text{th}}$ leg is $$s_n=300t_n=\frac {900}{2^n}$$

Total distance travelled by fly, \begin{align}S&=s_1+s_2+...+s_n+...\\ &=450+225+...+\frac {900}{2^n}+...\\ &=900\sum_{i=1}^{n}\frac 1{2^i} \\ &=900\end{align}