es6.math.tanh.js 317 B

123456789101112
  1. // 20.2.2.33 Math.tanh(x)
  2. var $export = require('./_export');
  3. var expm1 = require('./_math-expm1');
  4. var exp = Math.exp;
  5. $export($export.S, 'Math', {
  6. tanh: function tanh(x) {
  7. var a = expm1(x = +x);
  8. var b = expm1(-x);
  9. return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (exp(x) + exp(-x));
  10. }
  11. });