2016-10-10 03:43:44 +02:00
|
|
|
// 20.2.2.33 Math.tanh(x)
|
2017-08-14 05:01:11 +02:00
|
|
|
var $export = require('./_export');
|
|
|
|
var expm1 = require('./_math-expm1');
|
|
|
|
var exp = Math.exp;
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
$export($export.S, 'Math', {
|
2017-08-14 05:01:11 +02:00
|
|
|
tanh: function tanh(x) {
|
|
|
|
var a = expm1(x = +x);
|
|
|
|
var b = expm1(-x);
|
2016-10-10 03:43:44 +02:00
|
|
|
return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (exp(x) + exp(-x));
|
|
|
|
}
|
2017-08-14 05:01:11 +02:00
|
|
|
});
|