Freight Train

The engineer of a train which is moving at a speed sees a freight train on the same track, at a distance d ahead of him.
The freight train is moving in the same direction, but with a slower speed . He puts on the brakes and gives his train a constant deceleration .
Show that:
If , there will be no collision.
If , there will be a collision.
(It is a good idea to plot a qualitative graph of x versus t for each train.)