Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: Blocklist MSVC ctanh? It misbehaves for large inputs. #5687

Open
@mieswicht

Description

@mieswicht

Hi,

when working with complex impedance data, i encountered an issue and narrowed it down to:

from numpy import *
x=(616.47292227535877+53.814558958179042j)

tanh(x)

Warning (from warnings module):
File "C:\python\Test\Impedance class reduced.py", line 1
from numpy import *
RuntimeWarning: overflow encountered in tanh

Warning (from warnings module):
File "C:\python\Test\Impedance class reduced.py", line 1
from numpy import *
RuntimeWarning: invalid value encountered in tanh

When actually, it should return (1-0j), see http://tinyurl.com/nm4goq3
Then i tried

sinh(x)/cosh(x)

Warning (from warnings module):
File "C:\python\Test\Impedance class reduced.py", line 1
from numpy import *
RuntimeWarning: overflow encountered in cdouble_scalars

Warning (from warnings module):
File "C:\python\Test\Impedance class reduced.py", line 1
from numpy import *
RuntimeWarning: invalid value encountered in cdouble_scalars
(nan+nan*j)

However, the solution was to use numpy.divide:

divide(sinh(x),cosh(x))
(1-0j)

This took me quite some time to figure out, so i guess it would be a good idea to include it in the next release (maybe even with with coth?).

Thanks a lot!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions