# How difficulty variation is technically linked to time take for the block discovery?

Can anybody explain to me technically in units about the time relation to difficulty variation in bitcoin mining e.g. if a block is discovered in 10 minutes, does T = 10 minutes? or T = 20160 minutes and then as Difficulty is inversely proportional to the time taken. How it can be formulated to proper time and difficulty relation evaluation.

The purpose of difficulty variation is to maintain a consistent block time.

Let's say you have a network, and you want a 10 minute block time. You are the only miner. The process of mining can be thought of as rolling a die. For simplicity, let us assume it takes you five minutes to roll a dice once.

Now, we need to set our difficulty such that you find a valid solution roughly every ten minutes. In ten minutes, you will be able to roll the die twice (since it takes 5 minutes to roll once). Thus, we need half the rolls to give a valid result, and set our difficulty to <=3 (since you have a 1/2 chance of getting a number less than or equal to 3 on any roll).

If you do this 2016 times, you will, on average, find a block every 10 minutes.

Now, let's say a friend joins you, and can also roll a die once every 5 minutes. Now, suddenly, we are trying 4 solutions per ten minutes instead of 2. This would result in a block being found every 5 minutes, on average.

After 2016 blocks, Bitcoin nodes will look at the average time taken to find a block over the last 2016 blocks. Once they see that this is 5 minutes instead of 10, they will increase the difficulty by lowering the target. In our case, with two people mining, this would make the difficulty 1.5 instead of 3.

Now, with die, you cannot actually have that much control. There are only six possibilities, which makes your difficulty jump more than you need.

With bitcoin, the blockhash is essentially a 256 bit number, and can store 2^256 values. This allows for fairly precise difficulty adjustments.

• Can I have some mathematical calculations for this? Aug 3 '18 at 15:46