In regards to my earlier guess;
Tech Price = (Research Cost in Gold/Number Of Civs That Have Discovered It)
I have done some research
and found that this is not the relationship at all. At first, I tried looking at patterns in tech. price, but this was much too complex to derive a formula without prior knowledge. So, I looked through my notes and saw something odd. Research cost (I was at 0% research) for a specific tech got less as I met more civs. This led me to wonder what the definition of Research cost could be. I set up a test map, 60% water Pangea and 8 civs, so I can meet all the civs quickly, regent and standard size so there are no modifiers. I log research cost of the five available techs every turn and pump out settlers and warriors to find the other civs. Naturally I am not researching the techs myself as I want the total cost.
A pattern starts to emerge; research cost for a particular tech falls every time I meet a civ that has that tech. I buy no techs, but just explore until I find all the civs. I'd post the results here, but I don't know how to insert tables and it would probably just take up unneccesary space. Anyway, after analysis of the results I derived the general formula for any specific tech:
Research Cost = 0.9^N * Map Modifier * COST
Where; N = number of civs on my diplomacy screen that have discovered that tech
COST = the value for tech cost as written in the civilopedia
Map Modifiers are as follows:
16 : Tiny
20 : Small
24 : Standard
32 : Large
40 : Huge
If the result of the formula is a decimal then it is rounded to the nearest whole number.
And that is it. No difficulty modifier and no devaluation per turn. The formula is not exactly right all the time, but is usually within 5%. I think this may be due to computer rounding at some point, though I might have missed something.
I doubt that there will be a separate number of civs component in the tech price formula as well, so the formula at the top can be disregarded. And now that I've got a more or less accurate research cost formula, it should be easier to work out the tech price one.
Also can someone try this formula with later era techs, as I only had a chance to try it with ancient era.