UNPKG

510 BJavaScriptView Raw
1'use strict';
2var $ = require('../internals/export');
3var expm1 = require('../internals/math-expm1');
4
5// eslint-disable-next-line es/no-math-cosh -- required for testing
6var $cosh = Math.cosh;
7var abs = Math.abs;
8var E = Math.E;
9
10var FORCED = !$cosh || $cosh(710) === Infinity;
11
12// `Math.cosh` method
13// https://tc39.es/ecma262/#sec-math.cosh
14$({ target: 'Math', stat: true, forced: FORCED }, {
15 cosh: function cosh(x) {
16 var t = expm1(abs(x) - 1) + 1;
17 return (t + 1 / (t * E * E)) * (E / 2);
18 }
19});