es.math.acosh.js 748 B

123456789101112131415161718192021222324
  1. var $ = require('../internals/export');
  2. var log1p = require('../internals/math-log1p');
  3. // eslint-disable-next-line es-x/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. return (x = +x) < 1 ? NaN : x > 94906265.62425156
  18. ? log(x) + LN2
  19. : log1p(x - 1 + sqrt(x - 1) * sqrt(x + 1));
  20. }
  21. });