Two trains, 100 km apart, head straight at each other at 50 km/h each, so they close at 100 km/h. A fly sits on the nose of the left train. It flies at 150 km/h to the other train, touches the nose, turns round at once, flies back, and keeps going until the trains meet.
The statement has to be exact on three points, and the film says all three: the fly never rests, it turns round instantly, and it always flies at 150 km/h.
How far does the fly fly before the trains meet?
Write for the distance between the trains, and for their speeds, and for the fly's speed. The fly is faster than both trains, and . That is needed for the legs to exist. A leg towards the right-hand train ends before the trains meet only if , because the time it takes is and the trains meet after . The leg back needs .
This is the film's first route. Take the case the film uses, where the two trains go at the same speed . Say the gap between the noses is and the fly is about to fly at the right-hand train.
The fly and that nose close on each other at , so the leg takes hours, and the fly covers
For the film that fraction is , three quarters of the gap.
In the same time the two trains close per hour over hours, so the gap after the leg is
For the film that ratio is : each new gap is half the one before. The fly now stands on the right-hand nose and flies back, and by symmetry the same two facts hold for every leg, in either direction.
So the legs form a geometric series. The first leg is and each is the fraction of the one before. Because , the partial sums are and they converge to
since . With the film's numbers the first leg is 75 km and the ratio is 0.5, so the sum is 75 / (1 - 1/2) = 150 km, and is the combined speed of the trains: this is the claim.
This is the film's second route. The trains are 100 km apart and close at 50 + 50 = 100 km/h, so they meet after exactly 1 hour, at 50 km from either start. The fly never rests, so it flies for that whole hour at 150 km/h:
Nothing about the bounces enters: not how many, nor how long, nor where.
The two routes are not two calculations that happen to agree. Each leg has a duration , and during it two things happen: the fly flies , and the trains close the gap by . Add up the first legs and let be the time they took. Then
The first line says the fly's distance is always its speed times the time it has been flying. That is the clock route, written at every stage and not only at the end. The second line says the gap is the original gap minus what the trains have closed. Now the gap goes to nothing, because over every pair of legs it is multiplied by a number below one (see "Different speeds for the two trains" below for the factors), so and the distance flown goes to . The series and the clock are the same limit.
For the film, and the gap after legs is km, so the distance flown after legs is and it never quite reaches 150 in any finite number of legs.
There is a leg for every , and yet the whole flight lasts an hour. The legs take hours, and a list of positive times can add up to a finite number if it shrinks fast enough: , from below, with left over after terms. This is the old puzzle of Zeno, in which the runner must first cover half the distance and then half of what is left, and the resolution is that infinitely many steps may have a finite total.
So the fly turns infinitely often before the hour is up, and there is no "last leg" and no time after the hour in which anything remains to be done. In the model the fly is a point, it turns without taking any time, and at the end of the hour the fly and both noses are at the same place, 50 km. The question the puzzle asks (how far before the trains meet) is answered by the limit.
The film's first eight legs, with the fly flying right on odd legs and left on even legs. The fly ends each leg on a nose, and the last column is where.
| Leg | Gap | Time (h) | Fly flies | Total so far | Gap after | Fly ends at |
|---|---|---|---|---|---|---|
| 1 | 100 | 1/2 | 75 | 75 | 50 | 75 |
| 2 | 50 | 1/4 | 37.5 | 112.5 | 25 | 37.5 |
| 3 | 25 | 1/8 | 18.75 | 131.25 | 12.5 | 56.25 |
| 4 | 12.5 | 1/16 | 9.375 | 140.625 | 6.25 | 46.875 |
| 5 | 6.25 | 1/32 | 4.6875 | 145.3125 | 3.125 | 51.5625 |
| 6 | 3.125 | 1/64 | 2.34375 | 147.65625 | 1.5625 | 49.21875 |
| 7 | 1.5625 | 1/128 | 1.171875 | 148.828125 | 0.78125 | 50.390625 |
| 8 | 0.78125 | 1/256 | 0.5859375 | 149.4140625 | 0.390625 | 49.8046875 |
Every leg closes at 200 km/h, the fly's 150 plus the oncoming train's 50, so the time is the gap over 200. The fly's end points spiral in on the meeting point: each is half as far from 50 km as the one before, on the other side. The first leg ends at 75, 0.75 of the way along, and the next ends at 37.5, then 56.25.
The question beat freezes the film at 0.8 hours. Leg 3 began at 0.75 hours with the fly at 37.5 km, flying right at 150 km/h, so after a further 0.8 − 0.75 = 0.05 hours it is at 37.5 + 150 × 0.05 = 45 km. The trains are at 40 km and 60 km. The fly has flown 120 km so far, and the clock gets that without any legs at all: 150 × 0.8 = 120.
Let the trains go at different speeds. The derivation of route one goes through for each leg separately. A leg towards the right-hand train multiplies the gap by , and a leg back towards the left-hand train by . These are different, so the legs no longer have a single ratio. They alternate: every second leg repeats the pattern, and the gap after every pair of legs is multiplied by
which is below one, so the legs still run out. The series is now two interleaved geometric series, harder to sum and harder to see, but the argument of the previous section did not use equal speeds. The answer is still .
The film uses 50 and 50 for exactly this reason. The story the puzzle is told with has 60 and 40 km/h, and the answer is the same 150 km. But the first leg is = 78.947 km, and the first four legs are 78.947, 33.835, 19.588, 8.395 km: not a tidy number, and no single ratio between them.
Everything scales. Double the distance and the answer doubles, since it is the fly's speed times the time the trains take. A faster fly flies further in the same hour. A slower fly (still faster than the trains) flies less in it. The answer depends on the fly's speed, the distance and the trains' combined speed, and not on how they share it.
scripts/trains.mjs asserts the claims below, in exact fractions unless a float is the point, before it writes maths.json, and this page is built from that file.
What a script cannot do is add infinitely many legs. It checks a few dozen legs exactly and 60 in floats, and what makes the limit follow is the argument above: the gap after legs is a known number that goes to nothing, and the distance flown is always .
The trains still meet after 1 hour, so it is 100 km/h × 1 hour = 100 km. In legs: and the first leg is km, so the sum is km.
They meet after 2 hours and the fly flies 150 × 2 = 300 km. Every length in the table is doubled and every time is doubled too, as the first leg is , which scales with . The ratios, 0.75 and 0.5, do not change.
After legs the gap is km. A metre is 0.001 km, so we need . Since is too small and is enough, it takes 17 legs. The time after 17 legs is hours, a hair under the full hour, and the distance flown is within km of 150.
Each leg ends on the nose it was flying at, and that nose has not yet reached the middle. The first leg ends at 75, which is 75 − 50 = 25 past the middle, and the second at 37.5, which is 12.5 short of it. The two noses are always level with each other about the middle, each half the gap away from 50 km. The fly lands on the right-hand nose, then the left, then the right, and the gap halves each time, so each end is half as far from the middle as the last, on the other side.