[Numpy-discussion] Error in tanh for large complex argument

Mark Bakker markbak at gmail.com
Thu Jan 27 05:40:00 EST 2011

Hello list,

When computing tanh for large complex argument I get unexpected nans:

tanh works fine for large real values:

In [84]: tanh(1000)
Out[84]: 1.0

Not for large complex values:

In [85]: tanh(1000+0j)
Out[85]: (nan+nan*j)

While the correct answer is:

In [86]: (1.0-exp(-2.0*(1000+0j)))/(1.0+exp(-2.0*(1000+0j)))
Out[86]: 1.0


Thanks, Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110127/ce1fc074/attachment.html>

More information about the NumPy-Discussion mailing list