Closed benjoffe closed 8 years ago
You're correct about neglibile performance difference for Math.sign changes, reverted.
Thanks, this looks great - if it's not too much to ask, could you rebase this on latest master?
Math.tanh = function (x) {
return Math.sign(x) / (1 + 2 / Math.expm1(2 * Math.abs(x)));
};
What about this one?
@Yaffle i'd be happy to review a new PR that changed the implementation, with assorted tests (altho i'd prefer the edge cases be explicit)
Previous PR for tanh left some code that was no longer needed (the checks against Infinity are redundant with the early exit).