Message305894
There is no two-argument libm `log`. Two-argument log(x, base) is implemented as log(x) / log(base). log(base) adds an error.
>>> import math
>>> math.log(2**31, 2)
31.000000000000004
Since two-argument log() doesn't correspond a C function, I think we are free to use more precise implementation.
We could correct also two-argument logarithms with other bases. For example:
def prec_log(x, y):
a = math.log(x, y)
return a + math.log(x / math.pow(y, a), y)
>>> math.log(3**20, 3)
19.999999999999996
>>> prec_log(3**20, 3)
20.0 |
|
Date |
User |
Action |
Args |
2017-11-08 19:48:52 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, rhettinger, mark.dickinson, stutzbach |
2017-11-08 19:48:52 | serhiy.storchaka | set | messageid: <1510170532.78.0.213398074469.issue31980@psf.upfronthosting.co.za> |
2017-11-08 19:48:52 | serhiy.storchaka | link | issue31980 messages |
2017-11-08 19:48:52 | serhiy.storchaka | create | |
|