The formula can be found in my espionage article:
http://forums.civfanatics.com/showthread.php?t=97042&page=1
The part you are looking for:
dist - distance from his capital to your nearest city
pop - size of capital
level - level of settlement, 1 for town, 2 for city and 3 for metropol
base - 20 for unmodded game
Cost: dist*level + base + pop
Note that the price depends on distance to
your nearest city, not your capital.