[issue1640] Enhancements for mathmodule

Mark Dickinson report at bugs.python.org
Tue Dec 18 15:36:33 CET 2007


Mark Dickinson added the comment:

Unfortunately, implementing asinh, acosh, atanh correctly is not as simple as just using the formulas 
(this is one of the reasons that it's useful to be able to get at the library definitions).  For 
example, the formula

asinh(x) = log(x + sqrt(1.+(x*x)))

has significant error (i.e. much more than just a few ulps) when x is small (so that the argument of 
the log is close to 1), and when x is large and negative (so that the addition involves adding two 
numbers of almost equal magnitude but opposite sign).  It also overflows unnecessarily at around 
1e154 (on an IEEE754 system), as a result of the intermediate calculation x*x overflowing, and it 
fails to give the correct signs on zero arguments.  (asinh(0.) = 0., asinh(-0.) = -0.)

So either some serious work is required here, or code should be borrowed in an appropriately legal 
fashion from some other library, or those few people who don't have asinh, acosh, etc. already in 
libm will have to live without.

Mark

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1640>
__________________________________


More information about the Python-bugs-list mailing list