es.math.acosh.js 704 B

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