es.math.cosh.js 474 B

12345678910111213141516
  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. // `Math.cosh` method
  8. // https://tc39.es/ecma262/#sec-math.cosh
  9. $({ target: 'Math', stat: true, forced: !$cosh || $cosh(710) === Infinity }, {
  10. cosh: function cosh(x) {
  11. var t = expm1(abs(x) - 1) + 1;
  12. return (t + 1 / (t * E * E)) * (E / 2);
  13. }
  14. });