[issue1381] cmath is numerically unsound

Mark Dickinson report at bugs.python.org
Mon Nov 26 03:18:53 CET 2007


Mark Dickinson added the comment:

Here is (quite a large) patch, cmath.patch, that fixes a variety of 
problems in the current cmath module.  A summary of the changes:

* sqrt, log, acos, acosh, asin, asinh, atan, atanh no longer produce 
overflow errors for very large inputs

* exp, cos, sin, tan, cosh, sinh, tanh produce valid answers in some cases
where they incorrectly overflowed before.

* sqrt and log are more accurate for tiny numbers

* numeric problems in some functions (especially asinh and asin) should
have been fixed

* the branch cuts for asinh have been moved to the standard positions

* the direction of continuity for the branch cuts of tan, tanh have been 
fixed

* on systems with full hardware and system support for signed zeros (most 
modern systems), functions with a branch cut are continuous on both sides 
of the branch cut.  (As recommended by the C99 standard, amongst others.)

The patch includes documentation updates, but there are still no tests.  
(My current tests make heavy use of the MPFR library, and assume IEEE-754 
format doubles, so need to be seriously reworked.)  The tests are on my to-
do list, but I'm unlikely to find time for them before the new year.  In 
the meantime, I'd very much appreciate any feedback on this patch, if 
anyone has the time/energy/inclination to look at it.  (Andreas:  are you 
in a position to give this a test-run?)

Added file: http://bugs.python.org/file8807/cmath.patch

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1381>
__________________________________
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cmath.patch
Url: http://mail.python.org/pipermail/python-bugs-list/attachments/20071126/835bb498/attachment-0001.txt 


More information about the Python-bugs-list mailing list