A friend showed me that (at least on the Google Chrome console) the following statement outputs true:
1/Math.pow(0.9999999999999999, Number.MAX_SAFE_INTEGER) === Math.E
And indeed, 1/Math.pow(0.9999999999999999, Number.MAX_SAFE_INTEGER)
is 2.718281828459045
.
This can't be a coincidence ?!
Can someone explain what is going on behind the scenes to make this work?
According to wolfram alpha , the correct value should be approximately 1/0.40628
, which is approximately equal to 2.4613566998129373
- very far from Math.E
(I assume that wolframalpha is more accurate in its calculations than javascript, but I could be wrong).
Any explanation would be appreciated.
Bonus: What is the true approximate mathematical meaning of this expression, interesting? I found this:
n = 0.0000000000000001 (1 - n)^MAX_INT = 1 + (MAX_INT choose 2) * n + (MAX_INT choose 3) * n^2 + ... + n^MAX_INT
but I donβt know how to bring it closer.
I tested the above expression in wolfram alpha and got 2.46
.
source share