es.math.cosh.js 496 B

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