Skip to content

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.

coth.patch

Edited by Rika
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information