# Q: If two trains move towards each other at certain velocities, and a fly flies between them at a certain constant speed, how much distance will the fly cover before they crash?

The brain teaser comes in a many variations. For example:

Trains A and B, 700 miles apart, are heading toward each other on a straight piece of track. Train A is going 85 mph while train B is going 55 mph. At the same moment, a bee that flies 110 mph is sitting on the nose of train A and begins flying toward train B. When it reaches train B it makes an instantaneous reversal of direction and flies back toward train A. It continues to change direction every time it runs into a train until both trains and the bee meet in a spectacular crash. What total distance did the bee fly before the big collision?

Mathematician: The difficult way to solve this problem is to figure out how much distance the bee (or fly) traveled before turning around each time it approached a train, and then sum these distances together. The easy way to solve it is simply to figure out how long it took the trains to crash, and then calculate how far the bee, which travels at a constant speed, must have gone during this amount of time.

More specifically: The bee always travels at the same speed V. If we can figure out how much time, T, the bee flew before the trains collided with each other, then the total distance D it flew will just be V T, the product of the velocity and time. We know V, so all that remains is to figure out T. To do this, we just need to calculate how long it takes for the trains to crash. If the first train has velocity v1 and the second v2, and the distance between them initially is d, then the time T before the crash will just be d/(v1+v2), which is equivalent to the amount of time that it takes a train going velocity v1+v2 to travel the distance d. The total distance traveled by the bee is given by:

D = V d / (v1+v2)

= (700 miles)  * (110 mph)/((55 mph)+(85 mph))

= 550 miles

This entry was posted in -- By the Mathematician, Brain Teaser, Math. Bookmark the permalink.

### 11 Responses to Q: If two trains move towards each other at certain velocities, and a fly flies between them at a certain constant speed, how much distance will the fly cover before they crash?

1. toby says:

There’s a great story that someone posed this problem to John von Neumann, who popped the answer out in seconds. Neumann had an amazing ability to do complicated calculations in his head.

The questioner laughed and said “Ah, you spotted the short way to do it!”

Neumann just looked surprised “There’s a short way?”

2. Tim Anderson says:

How hard does it get if we give the fly a certain (nonzero) length and only allow it to subject itself to a maximum acceleration?

3. Mathematician says:

In that case, things would get quite a bit harder because we would have to keep track of all of the occasions that the fly approaches the train. We couldn’t just calculate the total time in order to do the calculation as we do in the constant velocity case.

4. matt says:

THANK YOU. this was the exact problem i was doing(different numbers) and having trouble on. you explained it perfectly. you are the reason why the internet is great.

5. Hi, I’ve been having trouble with word problems like this for a very long time, never really learned what I was supposed to in school I guess. Thank you for your explanation. 🙂 But, I’m confused, because at the bottom there is something wrong with how this is arranged, at least in my head.

D = V d / (v1+v2)

= (700 miles) * (110 mph)/((55 mph)+(85 mph))

= 550 miles

Shouldn’t this be = (110 mph) * (700 miles)/((85 mph)+(55 mph)) ? I mean, that’s the equation above written out with the available data, yes? Oh, and the Bee’s Velocity should have been labeled V3, IMHO, as the other velocities had numbers next to them too. V1 is train one, V2 is train two, V3 is the bee between them, yes? Ok, so, when I did it I used the following:

V1 = 85 mph
V2 = 55 mph
V3 = 110 mph
D1 = 700 miles **the original distance between the two starting points**
T = D1 / (V1+V2) = (700 miles) / ((85 mph) + (55 mph)) = 5 hours
D2 = V3 T = (110 mph) * (5 hours) = 550 miles

Does this not make sense to anyone but me? Am I just being stupid? Well, anyway, thank you very much for the math lesson, it’s been very helpful for me. 🙂

6. now if question asks about number of trips (forward and backward both) made by fly/bee, then suggest the solution !!

7. satwik pani says:

@aaron They are equivalent.

8. Daniel says:

Hi, so I solved the problem the easy way, then I started to wonder, what is the hard way? Is it calculus? Any way, here’s my attempt at the solution ‘the hard way’

I modeled the changes that occurred for each instance that the fly changes direction, and the distance between the train decreasing as

700-[(85(t)+55(t))] = 110(t) + (70-15(-1)^(n+1))(t)

where t is the time taken for the fly to reach each train starting from the train that is travelling at 55mph and heading towards the 85mph train, n starts from 0, so 0 being the first instance. Or in other words, the general equations I was equating to solve for t and then multiplying to find the distance traveled by the mosquito are were those two above.

I got them from the following data

700 = 110(t) + 85(t), t = 3.589, n = 0

distance between two trains is now 700 – 700-[1(85(3.589)+55(3.589))] = 197.435

197.435 = 110(t) + 55(t), t = 1.1965, n = 1

distance between two trains is now 700 – [(85(3.589+1.1965)+55(3.589+1.1965))] = 30.03

and then this would continue to some n and total t (which we know is 5 from the easy method). Actually just notice my left equation doesn’t account for adding the old t to the new t, but anyway, I would then have my equations and let n go to infinity and solve for t, correct? If there’s another way, i’m interested in knowing please!

9. Daniel says:

After a lot of wolfram, I ended up with something like this but the problem is that i need a sequence that does 0,1,1,1,1,1,1,1,1… for the left side, as it should be 700 – 0 for n = 0

700 – [85(700/((110 + 70-15(-1)^(n+1))))+55(700/((110 + 70-15(-1)^(n+1))))] = 110(t)+(70-15(-1)^(n+1))(t), n = 0

10. Daniel says:

Sorry, in that last post, that n = 0 after the equation shouldn’t be there

11. David Hoitsma says:

〖Let t〗_n be the time it takes the fly for the nth trip. Let v be the speed of the fly,v_i,the speed of train i
and d,the original distance between the trains.
Then T=∑_(n=1)^∞▒t_n is the total time that the fly flies.
Without loss of generality, assume the fly is flying towards train 2 at the (n+1)st step.
We have then
(v+v_2)t_(n+1)=d – (v_1+v_2 )*(t_1+⋯+t_n ) (1)
Let n→∞ in equation (1), 0=d-(v_1+v_2 ) ∑_(n=1)^∞▒t_n .
Thus, T=d/(v_1+v_2 ) and the total distance the fly flies is D=vd/(v_1+v_2 ) .