Node-Red configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

es.math.tanh.js 404B

12345678910111213141516
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var expm1 = require('../internals/math-expm1');
  4. var exp = Math.exp;
  5. // `Math.tanh` method
  6. // https://tc39.es/ecma262/#sec-math.tanh
  7. $({ target: 'Math', stat: true }, {
  8. tanh: function tanh(x) {
  9. var n = +x;
  10. var a = expm1(n);
  11. var b = expm1(-n);
  12. return a === Infinity ? 1 : b === Infinity ? -1 : (a - b) / (exp(n) + exp(-n));
  13. }
  14. });