Additionally use a relatively simple square-and-multiply exponentiation.
The key realization is that x ** (y * z) is equal to (x ** y) ** z. We can use that to only require calculating integer powers of floating point numbers, but that can be done with the square-and-multiply algorithm.
We find that exp(-1.1e-9) ≈ 0.9999999989 and 2 ** -5.7327557121556496e-12 ≈ 0.9999999999960264, both as exact as f64 (confirmed with WolframAlpha).
The results of the supply curve differ only by less than 0.001%
Additionally use a relatively simple square-and-multiply exponentiation.
The key realization is that
x ** (y * z)
is equal to(x ** y) ** z
. We can use that to only require calculating integer powers of floating point numbers, but that can be done with the square-and-multiply algorithm.We find that
exp(-1.1e-9) ≈ 0.9999999989
and2 ** -5.7327557121556496e-12 ≈ 0.9999999999960264
, both as exact asf64
(confirmed with WolframAlpha).The results of the supply curve differ only by less than 0.001%
https://en.wikipedia.org/w/index.php?title=Exponentiation_by_squaring&oldid=1229001691#With_constant_auxiliary_memory