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

Fri Jan 28 13:44:07 EST 2011

A brief history:
I wrote the asinh and acosh functions for the math (or was it cmath?) for python 2.0. It fixed some problems of GVR implementation, but still it was far from perfect, and replaced shortly after.  My 1/4 cent tip: Do not rush --- find a good code.

________________________________
From: numpy-discussion-bounces at scipy.org [numpy-discussion-bounces at scipy.org] On Behalf Of Mark Bakker [markbak at gmail.com]
Sent: 28 January 2011 12:45
To: numpy-discussion at scipy.org
Subject: Re: [Numpy-discussion] Error in tanh for large complex argument

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/7cb824a6/attachment.html>