[Patches] acosh and asinh functions

Guido van Rossum guido@python.org
Mon, 01 May 2000 13:20:48 -0400


> The computation of the inverse hyperbolic functions 'acosh' and 'asinh'
> is erroneous -- it has both low precision and discontinuities.
> 
> The patch (using diff) is followed:
> ====================================================================
> 60,61c60,63
> <  return c_log(c_sum(x,c_prod(c_i,
> <       c_sqrt(c_diff(c_1,c_prod(x,x))))));
> ---
> >   Py_complex z;
> >   z = c_sqrt(c_half);
> >   c_temp = c_log(c_prod(z, c_sum( c_sqrt(c_sum(x,c_1)),
> c_sqrt(c_diff(x,c_1)))));
> >   return c_sum(c_temp,c_temp);
> 89,90c91
> <  z = c_diff(c_sqrt(z),x);
> <  return c_neg(c_log(z));
> ---
> >   return c_log(c_sum(c_sqrt(z),x));
> 338c339
> <   PyErr_SetFromErrno(PyExc_ValueError);
> ---
> >   PyErr_SetFromErrno(PyExc_ValueError);
> 414c415
> <
> ---
> >
> 422c423
> < }
> ---
> > }
> \ No newline at end of file
> =================================================================

Thanks for your contribution.  My math skills are insufficient to
decide whether your patch is correct.  There are several problems
though: (1) c_temp is not declared; (2) this code raises OverflowError
for cmath.asinh(1e154).  Which gives me doubts about the reliability
of the patch.

Perhaps you would care to write up a brief mathematical analysis (with
some literature references) of how acosh and asinh are defined, how
they are typically calculated, and how to recognize a quality
implementation?  If we have a test suite (written in Python) for a
particular acosh/asinh implementation, it will be easier to decide
whether a given implementation is correct.

--Guido van Rossum (home page: http://www.python.org/~guido/)