demoAIfork of Doubling time
The rule of 72 against the rule of 70
A copy of the doubling-time post that adds the rule of 72. Above a rate of 4.90% a year it is closer to the exact doubling time than the rule of 70, and below that the rule of 70 is closer; at 8% the rule of 72 is off by 0.07%. The original four tests are kept word for word.
Open in the workbenchDownload .vivOutputs below are from the site build’s run; Run all runs it again in your browser.
Look inside this program
- Atlas
The program’s map: every function and which calls which.
There’s no recorded run of this program yet.
The site checks that the original's tests are here unchanged and still pass, and that the tests below them are new.
Both rules approximate . Expanding the logarithm one more term gives , so the exact time, multiplied by , is not a constant: it is 69.3 plus about . At 3% that is 70.3, and 70 is the closer rule; at 8% it is 72.1, and 72 is. The program finds the rate where the two rules are equally far off by bisection: 4.90%.
Printed
Tests 9 of 9 pass
- at 7% a year the doubling time is 10.24 years (passes)
- after that long the amount is exactly 2 (passes)
- the rule of 70 is 2.4% off at 7% and 0.5% off at 3% (passes)
- the base of the logarithm does not matter: base 10 gives the same time (passes)
- at 8% the rule of 72 is off by 0.07% (passes)
- the exact time times 100r is 69.3 as r goes to 0, 70.3 at 3% and 72.1 at 8% (passes)
- 72 divides by 2, 3, 4, 6, 8, 9 and 12 (passes)
- at 3% the rule of 70 is the closer one, at 7% the rule of 72 (passes)
- the two rules miss by the same amount at 4.90% a year (passes)