UNPKG

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