You need to sign in or sign up before continuing.
Improve Math.CotH.
(Just realized that) the idea behind current strangely-looking tanh
implementation is to ensure tanh(1e5) = 1
and tanh(−1e5) = −1
instead of NaNs by avoiding ∞ / ∞, and CotH
being equivalent to 1 / tanh
should do the same.
Additionally, I did CotH(−0.0) = −∞
. This also improves behavior around 0: CotH(±1e-100) = ±1e+100
is better answer than ±Inf
... and definitely better than always-positive +Inf
you can get for nonzero negative values very close to 0 if you just take tanh
implementation with numerators and denominators swapped.
Edited by Rika