函数 expm1 #

计算指数值减去 1 的值。当 x 接近 0 时,此函数比 math.exp(x)-1 更准确。为避免与矩阵指数 expm 混淆,此函数不操作矩阵;如果希望逐元素应用,请参阅示例。

Syntax #

math.expm1(x)

Parameters #

Parameter Type Description
x number | BigNumber | Complex 要进行指数运算的数字

Returns #

Type Description
number | BigNumber | Complex x 的指数减一

Throws #

Type | Description —- | ———–

Examples #

math.expm1(2)                      // returns number 6.38905609893065
math.pow(math.e, 2) - 1            // returns number 6.3890560989306495
math.expm1(1e-8)                   // returns number 1.0000000050000001e-8
math.exp(1e-8) - 1                 // returns number 9.9999999392253e-9
math.log(math.expm1(2) + 1)        // returns number 2

math.map([1, 2, 3], math.expm1)
// returns Array [
//   1.718281828459045,
//   6.3890560989306495,
//   19.085536923187668
// ]

另请参阅 #

exp, expm, log, pow

Fork me on GitHub