mirror of
https://github.com/musix-org/musix-oss
synced 2024-12-23 16:13:18 +00:00
15 lines
384 B
JavaScript
15 lines
384 B
JavaScript
var $ = require('../internals/export');
|
|
var expm1 = require('../internals/math-expm1');
|
|
|
|
var exp = Math.exp;
|
|
|
|
// `Math.tanh` method
|
|
// https://tc39.github.io/ecma262/#sec-math.tanh
|
|
$({ target: 'Math', stat: true }, {
|
|
tanh: function tanh(x) {
|
|
var a = expm1(x = +x);
|
|
var b = expm1(-x);
|
|
return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (exp(x) + exp(-x));
|
|
}
|
|
});
|