What is the formula to predict lunar and solar eclipses accurately? A number of ancient civilizations had devised methods to predict exact dates and times of such eclipses, marking them as important events.
Hence I assume the predictions were based on calculations, which should be quite easy to do now.
So what is the exact formula to predict the exact date and time(this is optional, but desirable) of lunar and solar eclipses?
Also how to calculate if the solar eclipse will be visible from a particular location or not?
The NASA sites have some very useful resources for this I will list them below:

Lunar Eclipses

This Link has an index for all lunar eclipses from -1999 to +3000, predominantly a statistics page but also has this page that contains how to calculate when lunar eclipses are. 

There is more than one formula depending on which time frame you are trying to look in.

This is the formula for eclipses between the year 2005 and 2050:


  $$\Delta T = 62.92 + 0.32217 * t + 0.005589 * t^2$$
  
  Where:   $$y = year + (month - 0.5)/12$$  $$t = y - 2000$$


Solar Eclipses

This Link has an index like above but for all of the solar eclipses from -1999 to +3000. 

This link has the formula for calculating solar eclipses. This is the formula for between 2005 and 2050:


  $$\Delta T = 62.92 + 0.32217 * t + 0.005589 * t^2$$
  
  Where:  $$y = year + (month - 0.5)/12$$  $$t = y - 2000$$