[Numpy-discussion] Error in tanh for large complex argument
markbak at gmail.com
Fri Jan 28 05:25:19 EST 2011
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))
the problem is fixed.
> > Not for large complex values:
> > In : tanh(1000+0j)
> > Out: (nan+nan*j)
> Yep, it's a bug. Care to file a ticket?
> The implementation is just sinh/cosh, which overflows.
> The fix is to provide an asymptotic expansion (sgn Re z),
> although around the imaginary axis the switch is perhaps
> somewhat messy to handle.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion