What is the formula to predict lunar and solar eclipses accurately?
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$$