An illustration of the steam engine with Walschaert gear system on rail tracks. The piston moves the…