Astronomers first have to work out the orbital mechanics of how the Earth and Moon orbit the Sun under the influences of the gravitational fields of these three bodies. From Newton's laws of motion, they mathematically solve for the motions of these bodies in three dimensional space taking into account the fact that these bodies have finite size and are not perfect spheres, and that the Earth and Moon are not homogeneous bodies. From careful observations, they then feed into these complex equations the current positions and speeds of the Earth and Moon, and then program the computer to 'integrate' these equations forward or backward in time to construct ephemerides of the relative positions of the Moon and Sun as seen from the vantage point of the Earth. Eclipses are specific configurations of these bodies which can be identified in the computer runs and captured. Current eclipse forecasts are accurate to less than a minute in time over a time span of hundreds of years.