Google Classroom
GeoGebraGeoGebra Classroom

The Fly and Trains problem

This activity belongs to the GeoGebra book The Domain of the Time. Constant speed motion frequently appears in many pursuit or encounter problems involving two moving objects. Although textbooks often solve them as systems of two equations with two unknowns (the distance traveled and the time taken to meet), a simple reasoning based on the relativity of motion (Galileo's relativity with respect to the reference frame) is enough. For an observer on one of the moving objects, the object they're on remains stationary, while the other moves with the difference (vectorial, that is, considering the direction of each) of the speeds of both. Using this reasoning, it’s easy to deduce the time of the encounter. Perhaps the most famous example of this type of problem is the one involving a fly and two trains: Two trains are on the same track, 100 km apart, moving towards each other at 50 km/h each. A fly starts from the front of one train and flies toward the other at 75 km/h. Upon reaching the other train, the fly turns around and flies back toward the first train, continuing this back-and-forth motion. How many kilometers does the fly travel before being squashed in the collision of the two trains?
  • Comment: Naturally, this statement, like many others in mathematics, falls into the category of "thought experiments" and shouldn't be judged with "common sense" (since when do flies fly at a constant speed without erratic movements? At 75 km/h, more than 10 times their normal speed? What strange motive drives the fly to make those absurd back-and-forth trips? Are both train conductors blind and don’t stop upon seeing the other train? How are these data known, does the fly carry a lightweight GPS? Etc.).
The fame of this problem stems from the fact that when it was proposed to the great mathematician John von Neumann (1903–1957, "Johnny" to his friends), replacing the trains with bicycles, he immediately gave the correct answer. "Oh, you’ve heard the trick before," said the disappointed questioner. "What trick?" asked Johnny, confused, "I simply summed the infinite series." In a quick mental calculation, Johnny determined the length of the first segment the fly traveled (75t = 100 − 50t, where t = 4/5, and thus length1 = 75 × 4/5 = 60 km). In that time (4/5 hour), each train would have traveled 40 km, leaving only 20 km between them, or 1/5 of the original separation. Therefore, the lengths the fly travels form a decreasing geometric progression, with a ratio of 1/5 and a first term of 60. The sum of the infinite terms of this series is 60/(1−1/5) = 75 km. The alternative, the "trick," much simpler, involves shifting the focus from space to time. From the perspective of one of the trains, the other train is approaching at 100 km/h, so they will collide in 1 hour after covering the 100 km separation. Thus, the fly will be flying for 1 hour. At a speed of 75 km/h, the fly will have traveled 75 km. Let’s note that since the speed is expressed in km/h, we choose kilometers as the unit of distance in the simulation. However, as we don't want to wait an hour for the experiment to be completed, we scale the time (1:180), so that each second of execution represents 3 minutes of "real" time. Naturally, scaling time also means scaling the error introduced in the simulation.
  • Note: In the construction, it’s evident that the locomotives are not to scale.
SCRIPT FOR SLIDER anima # Calculate the elapsed seconds dt; add one second if t1(1) < tt SetValue(tt, t1(1)) SetValue(t1, First(GetTime(), 3)) SetValue(dt, (t1(1) < tt) + (t1(1) − tt)/1000) # Move the fly M (at speed v) and the trains (at speed vTrain) SetValue(M, M + dt v) SetValue(Train1, Train1 + dt vTrain) SetValue(Train2, Train2 - dt vTrain) # Set the boundaries of each movement SetValue(v, If(x(M - Train1) < 0, (abs(v), 0), x(Train2 - M) < 0, -(abs(v), 0), v)) StartAnimation(anima, x(Train2 - Train1) > 0) Author of the activity and GeoGebra construction: Rafael Losada.