[Numpy-discussion] Error in tanh for large complex argument
Mark Bakker
markbak at gmail.com
Fri Jan 28 06:57:18 EST 2011
Follow up:
The behavior is correct for real argument:
In [20]: sinh(1000)
Out[20]: inf
In [21]: cosh(1000)
Out[21]: inf
In [22]: tanh(1000)
Out[22]: 1.0
So maybe we should look there for good logic,
Mark
On Fri, Jan 28, 2011 at 11:45 AM, Mark Bakker <markbak at gmail.com> wrote:
> Good point, so we need a better solution that fixes all cases
>
>
> >> I'll file a ticket.
> >>
> >> Incidentally, if tanh(z) is simply programmed as
> >>
> >> (1.0 - exp(-2.0*z)) / (1.0 + exp(-2.0*z))
>
> >This will overflow as z -> -\infty. The solution is probably to use a
> >different expression for Re(z) < 0, and to check how other libraries do
> >this in case the above still misses something.
>
> >
> > Pauli
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110128/caaafad9/attachment.html>
More information about the NumPy-Discussion
mailing list