World-wide price for generating 1BTC Can we find an algorithm to compute the average price (as energy consumption) of 1 BTC being generated if we know: hash rate, difficulty, energy price?
The parameters you need to calculate this are:

E - the mining efficiency, measured in MHash/J. Data on this for various hardware is available in Mining hardware comparison (though this take into account only the card's power and not of the system it is in). Or you can calculate it for a given system by dividing the total hashrate (in MHash/s) by the power consumed (in W).

c - the cost of electricity, measured in $/KWh.

B - the bitcoin reward per block.

D - the difficulty.

The cost to generate 1 BTC is:

c*D/(838*B*E)

For example, if E=2, c=0.1, B=50 and D=1,500,000, this is
0.1*1500000/(838*50*2) = $1.79

The 838 "magic number" comes from the various unit conversion factors - 2^32 hashes per difficulty-1 hash, 3,600,000 Joules per Kilowatt-hour, 1,000,000 Hashes per MHash.