Tim Peters <[email protected]> added the comment:
CPython's log() builds on the platform C's libm facilities, and C simply
doesn't define primitives capable of producing a worst-case < 1 ulp error
2-argument log in reasonable time. Instead we have to build it out of two
separate log operations, and a division. Each of those 3 operations can suffer
its own rounding errors, which may, overall, cancel out, or build on each
other. There's no error bound we can guarantee, although "< 2 ulp worst-case
error" seems likely under modern libms.
Which is actually quite good. Doing better than that is out of scope for
CPython's implementation. The easy way to get < 1 ulp is to use decimal to
compute the intermediate results with excess precision. But that's also "too
slow" for general use.
What Dennis did in his little test driver was fine for that, but we don't
actually need to increase decimal's default precision at all to get < 1 ulp
error in a converted-back-to-float-via-round-nearest result here.
Just an example (doesn't "prove" anything - but points at how to go about
proving things):
>>> decimal.Decimal(3**8).ln() / decimal.Decimal(3).ln()
Decimal('7.999999999999999999999999999')
>>> float(_)
8.0
----------
nosy: +tim.peters
resolution: -> wont fix
stage: -> resolved
status: open -> closed
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue45348>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com