es.math.acosh.js 755 B

12345678910111213141516171819202122232425
  1. var $ = require('../internals/export');
  2. var log1p = require('../internals/math-log1p');
  3. // eslint-disable-next-line es/no-math-acosh -- required for testing
  4. var $acosh = Math.acosh;
  5. var log = Math.log;
  6. var sqrt = Math.sqrt;
  7. var LN2 = Math.LN2;
  8. var FORCED = !$acosh
  9. // V8 bug: https://code.google.com/p/v8/issues/detail?id=3509
  10. || Math.floor($acosh(Number.MAX_VALUE)) != 710
  11. // Tor Browser bug: Math.acosh(Infinity) -> NaN
  12. || $acosh(Infinity) != Infinity;
  13. // `Math.acosh` method
  14. // https://tc39.es/ecma262/#sec-math.acosh
  15. $({ target: 'Math', stat: true, forced: FORCED }, {
  16. acosh: function acosh(x) {
  17. var n = +x;
  18. return n < 1 ? NaN : n > 94906265.62425156
  19. ? log(n) + LN2
  20. : log1p(n - 1 + sqrt(n - 1) * sqrt(n + 1));
  21. }
  22. });