Author

Topic: Testing my little math skills on Bitcoin halving formula (Read 285 times)

legendary
Activity: 2380
Merit: 5213
It could simply be a rounding error introduced by imprecise floating point arithmetic on the hardware.
OP calculated the sum of series 210,000*50/(2^x) from x=2 to x=32 and got 5249999.998 for that. That's correct with three decimal places precision. I just calculated that with python and got 5249999.997555278.

First I thought that by x=2 OP meant the second halving period.
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
After taking my time to perform this calculation, I discovered that the total value does not amount to 21M, but rather 20999999.92.
You did the calculations wrongly. For example, 5,250,000 BTC were generated in the second period. I don't know how you got the 5249999.998 BTC.
The total number of bitcoins will be finally 20999999.9769

It could simply be a rounding error introduced by imprecise floating point arithmetic on the hardware.
legendary
Activity: 4522
Merit: 3426
My Question:
1. What do you think about the part where I applied sum to infinity ?.

The sum to infinity is correct (though the Bitcoin Core code actually limits it to 64 epochs for practical reasons). However, the amount of each subsidy is truncated because it is an integer, and the amount goes to 0 after the 33rd epoch. That is why the actual maximum supply is slightly less than 21 million BTC.
Really glad I got the sum to infinity right. I think my calculator performed the truncation directly when I solved for the entire 33 halving directly, but the decimals were revealed when I took my time to calculate for each value for every halving year.

It is likely that the values were not exact because your calculator does not have sufficient precision to represent the values exactly.
full member
Activity: 238
Merit: 174
cout << "Bitcoin";
My Question:
1. What do you think about the part where I applied sum to infinity ?.

The sum to infinity is correct (though the Bitcoin Core code actually limits it to 64 epochs for practical reasons). However, the amount of each subsidy is truncated because it is an integer, and the amount goes to 0 after the 33rd epoch. That is why the actual maximum supply is slightly less than 21 million BTC.

Really glad I got the sum to infinity right. I think my calculator performed the truncation directly when I solved for the entire 33 halving directly, but the decimals were revealed when I took my time to calculate for each value for every halving year.
legendary
Activity: 4522
Merit: 3426
My Question:
1. What do you think about the part where I applied sum to infinity ?.

The sum to infinity is correct (though the Bitcoin Core code actually limits it to 64 epochs for practical reasons). However, the amount of each subsidy is truncated because it is an integer, and the amount goes to 0 after the 33rd epoch. That is why the actual maximum supply is slightly less than 21 million BTC.

In the end you arrive at the same result cause the 108 variable which appears twice cancels itself out. But using the first formula you can easily solve for the total supply. You also do not have to replace i with 1,2,3 and on, solving for each halving period, that invalidates the formula. Using it exactly as it is will give results for the entire 32 halvings we would have.

50 * 108 is important because of the truncation. The final division by 108 converts from satoshis to BTC.

BTW, in practical terms there are 33 halvings. The last sets the subsidy to 0.
copper member
Activity: 909
Merit: 2301
Quote
Over bitcoin's lifetime, Gold's emission much more resembles a fixed rate than an exponentially decreasing one.
You missed one important factor: altcoins. Each serious altcoin in the crypto world is just another abuse of 21 million coins limit. If you take the whole crypto market, and you find a point in time, where Bitcoin have for example 50% domination, then you can assume, that in practice, we have 42 million coins, but just half of them are handled off-chain.

And no, it is not like comparing gold with silver or cuprum, because you can copy-paste a lot of coins from one chain into another, and really "turn gold into lead" and vice versa. And it is more than just Escrow transactions, described by Satoshi. If you have opcodes like OP_CHECKSIGFROMSTACK, then you can handle signatures from other chains in a trustless way, and only one chain needs that feature, to successfully handle it on both sides.
legendary
Activity: 990
Merit: 1108
Quote from: hosseinimr93 link=topic=5497988.msg64137227#msg64137227
Visit this for accurate numbers:
https://en.bitcoin.it/wiki/Controlled_supply
That wikipage claims

Quote
This decreasing-supply algorithm was chosen because it approximates the rate at which commodities like gold are mined.
But this is what global gold production actually looks like:



Over bitcoin's lifetime, Gold's emission much more resembles a fixed rate than an exponentially decreasing one.

full member
Activity: 238
Merit: 174
cout << "Bitcoin";

I don't understand what's the use of calculating the sum from x=2 to x=32.

I was a little bit crazy about it Grin. I actually stated it that "it's unhealthy to take such a long step", but i actually enjoyed it  Grin.
legendary
Activity: 2380
Merit: 5213

I was referring to your paper where x=2 and I thought you meant the second period by x=2.
I don't understand what's the use of calculating the sum from x=2 to x=32.

21,000,000 is an integer and does not contain any decimal place. Like I said earlier, 21K is an estimated value.
Yes, 21,000,000 doesn't have any decimal point and I know that.
I was referring to the block rewards. For example, after the 10th halving, 0.048828125 BTC should be generated in each block and that will be rounded down to 0.04882812 BTC.

Visit this for accurate numbers:
https://en.bitcoin.it/wiki/Controlled_supply
full member
Activity: 238
Merit: 174
cout << "Bitcoin";
After taking my time to perform this calculation, I discovered that the total value does not amount to 21M, but rather 20999999.92.
You did the calculations wrongly. For example, 5,250,000 BTC were generated in the second period. I don't know how you got the 5249999.998 BTC.
The total number of bitcoins will be finally 20999999.9769



My Question:
1. What do you think about the part where I applied sum to infinity ?.
With doing do, the result would be 21,000,000 and that's not accurate. That's because we can't have more than 8 decimal places for each bitcoin.

21,000,000 is an integer and does not contain any decimal place. Like I said earlier, 21K is an estimated value.
legendary
Activity: 2380
Merit: 5213
After taking my time to perform this calculation, I discovered that the total value does not amount to 21M, but rather 20999999.92.
You did the calculations wrongly. For example, 5,250,000 BTC were generated in the second period. I don't know how you got the 5249999.998 BTC.
The total number of bitcoins will be finally 20999999.9769

My Question:
1. What do you think about the part where I applied sum to infinity ?.
With doing do, the result would be 21,000,000 and that's not accurate. That's because we can't have more than 8 decimal places for each bitcoin.
hero member
Activity: 644
Merit: 661
- Jay -
The image you see below is not different from what hugeblack shared in his reply yesterday
...
Yes, it is slightly different from the one hugeblack shared:

In the end you arrive at the same result cause the 108 variable which appears twice cancels itself out. But using the first formula you can easily solve for the total supply. You also do not have to replace i with 1,2,3 and on, solving for each halving period, that invalidates the formula. Using it exactly as it is will give results for the entire 32 halvings we would have.

- Jay -
full member
Activity: 238
Merit: 174
cout << "Bitcoin";
I came across hugeblack's reply https://bitcointalksearch.org/topic/m.64132796 on a thread yesterday, where he used a photo of Bitcoin halving formula as an illustration based on the question that was asked. I instantly got attracted to the formula, and was eager to perform the mathematical calculation of Bitcoin halving approximately every four years. It also turns out that this formula can also give the total supply value.

The image you see below is not different from what hugeblack shared in his reply yesterday. I will explain the key points in the formula below before moving further.

  • The value 2 represent the decreasing factor for every halving.
  • The value 10^8 represents the smallest unit of Bitcoin also known as Satoshi. E.g 0.0000012.
  • 210K is simply the number of blocks that needs to be mined before halving is triggered
  • 50 is the first amount of reward
  • the letter i below the sigma sign represents each halving. It must start with a value of 0 to 32, making the total halving to occur 33 times.

My aim was to get the total number of Bitcoin supply, but Inorder to achieve that, I will have to perform the calculation 33 times before arriving at my answer. For example, first trial will require me to replace i with 1, which will result to a value of 10500000 Bitcoin been mined for first halving year. Second trial, replacing i with 2, will result to 5249999.998 Bitcoin been mined for second halving year. I can continue to do this till my last trial which is by replacing i with 32, which will give 2.444721758×10^-3.

Trying to calculate all 33 values one after the other was so stressful and unhealthy, though I tried it. I had a thought to use other methods in carrying out the calculation, and my calculator came to mind. The images below are two different calculators that i used, which gave me an estimated value. I was able to compute the sigma sign, and also use x in place of i because my calculator does not have i.

https://www.talkimg.com/images/2024/05/27/LIwpP.jpeg


https://www.talkimg.com/images/2024/05/27/LIS3j.jpeg


I then challenged myself to perform the calculation on a paper, rather than inputting all values into the calculator to get a straight answer. The image below show my three steps.
  • Step 1 was just to evaluate by multiplying the number of blocks by the number of first reward, and then dividing both units of Bitcoin (10^8).
  • Step 2, I had to get rid of the sigma sign Since I already know that it is use to sum multiple terms. Sum of a geometric progression was used to replace the sigma sign, with a formula containing it's first term, common ratio and nth term.
  • Step 3, I finalized by getting my answer.


The image below is not that different from the one above. I had to draft this when I noticed that another solution can come from the one above. If you observe the image below, you noticed that I break down the Sum of a GP formula into two, which one part happens to be the formula for Sum to Infinity. If you compute your first term and common ratio, you will still get same 21M value as the one above, but I think this can only happen when 32 at the top of the sigma sign is changed to infinity . Unluckily for me, my calculator does not have an infinity sign, which makes it difficult to confirm.




I need to also share this. The 21M total supply is actually a calculator estimated value, and don't really follow the principles that governs the real formula itself. But that does not mean that the calculator is totally wrong. I discovered this when I decided to stress myself out, by calculating the entire halving values 33 times just by increasing my count by a factor of 1.


The image above was my rough work for each values of every halving. After taking my time to perform this calculation, I discovered that the total value does not amount to 21M, but rather 20999999.92. Each values represents the total amounts that can be mined for a particular mining period before another halving occurs.

Please note that after you've used the halving formula to get the first number of Bitcoins to be mined (10500000), any attempt to start dividing by a factor of 2 without using the proper formula, will give you a wrong value. You can try this by dividing 10500000/2, and also try it for others.

My Question:
1. What do you think about the part where I applied sum to infinity ?.

My calculations on this post are for fun purposes, but might be educational to someone. I am not certain 100% accurate, but I think racking my brain all day for Bitcoin math is quite interesting to me.
Jump to: