-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overflow encountered with tanh and coth functions #2967
Comments
Thanks for sharing. There is indeed an overflow occurring in the calculation of math.tanh(math.complex(1, 1)) // { re: 1.0839233273386948, im: 0.27175258531951174 }
math.tanh(math.complex(100, 100)) // { re: 1, im: -2.4171061928460553e-87 }
math.tanh(math.complex(1000, 1000)) // { re: NaN, im: -0 } The Before solving this in mathjs, it will be good to raise this issue in the https://github.com/infusion/Complex.js project, ideally it would be solved there. @richinex can you open an issue there? |
Yea sure. I have raised an issue there. |
Hi, I work with impedance spectroscopy and I sometimes have to deal with large complex numbers. I have experience NaN results. I think the mathjs tanh implementation has an overflow issue as I do not experience this problem with Python. Take for instance the problem below:
So I thought I'd share my implementation below. Maybe it helps. It is a translation of numba's implementation to JavaScript
https://github.com/numba/numba/blob/c04edc02deb40b84c3b21ed2a9835353181a5916/numba/targets/cmathimpl.py#L343-L367:
The text was updated successfully, but these errors were encountered: