Two Trains Puzzle

Author

Eric W. Weisstein
January 12, 2004

This notebook downloaded from http://mathworld.wolfram.com/notebooks/RecreationalMath/TwoTrainsPuzzle.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/TwoTrainsPuzzle.html.

©2005 Wolfram Research, Inc. except for portions noted otherwise

Sum

Solve[75x==100-50x,x]

75 4/5

Solve[60-75x==40+50x]

60-75 4/25

48+75 4/125

75Sum[4(1/5)^n,{n,∞}]

Plot

f[t_]:=Which[
t<4/5,75t,
t-4/5<4/25,60-75(t-4/5),
t-4/5-4/25<4/125,48+75(t-4/5-4/25),
t-4/5-4/25-4/125<4/625,252/5+75(t-4/5-4/25-4/125)]

Plot[f[t],{t,0,.998},PlotStyle->Red,AxesLabel->TraditionalForm/@{t,x[t]}]

Animation

<<Graphics`Colors`

Train1[t_]:={Green,Rectangle[{50t-10,0},{50t,5}]}
Train2[t_]:={Blue,Rectangle[{100-50t,0},{111-50t,5}]}

movie=Show/@Table[Graphics[{
Disk[{f[t],2.5},1.5],
Line[{{-10,#},{110,#}}]&/@{1,4},
Line[{{#,0},{#,5}}]&/@Range[-10,110,2],
Train1[t],Train2[t]},PlotRange->{{-10,110},{0,5}},AspectRatio->Automatic,ImageSize->400],{t,0,.99,.01}]

<<Utilities`GIF`;

Export["/Volumes/Users/Dump/TwoTrains.gif",movie]//Timing