es.math.atanh.js 444 B

123456789101112131415
  1. var $ = require('../internals/export');
  2. // eslint-disable-next-line es/no-math-atanh -- required for testing
  3. var $atanh = Math.atanh;
  4. var log = Math.log;
  5. // `Math.atanh` method
  6. // https://tc39.es/ecma262/#sec-math.atanh
  7. // Tor Browser bug: Math.atanh(-0) -> 0
  8. $({ target: 'Math', stat: true, forced: !($atanh && 1 / $atanh(-0) < 0) }, {
  9. atanh: function atanh(x) {
  10. var n = +x;
  11. return n == 0 ? n : log((1 + n) / (1 - n)) / 2;
  12. }
  13. });