d2f10778c04904efeb82f38c79f27375b717ad68
[yaffs-website] / es6.math.tanh.js
1 // 20.2.2.33 Math.tanh(x)
2 var $export = require('./_export')
3   , expm1   = require('./_math-expm1')
4   , exp     = Math.exp;
5
6 $export($export.S, 'Math', {
7   tanh: function tanh(x){
8     var a = expm1(x = +x)
9       , b = expm1(-x);
10     return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (exp(x) + exp(-x));
11   }
12 });