函数 tanh #
计算值的双曲正切,定义为 tanh(x) = (exp(2 * x) - 1) / (exp(2 * x) + 1)。
为避免与矩阵双曲正切混淆,此函数不适用于矩阵。
Syntax #
math.tanh(x)
Parameters #
| Parameter | Type | Description |
|---|---|---|
x |
number | BigNumber | Complex | 函数输入 |
Returns #
| Type | Description |
|---|---|
| number | BigNumber | Complex | x 的双曲正切 |
Throws #
Type | Description —- | ———–
Examples #
// tanh(x) = sinh(x) / cosh(x) = 1 / coth(x)
math.tanh(0.5) // returns 0.46211715726000974
math.sinh(0.5) / math.cosh(0.5) // returns 0.46211715726000974
1 / math.coth(0.5) // returns 0.46211715726000974