在 R 编程中计算数字的指数减 1 – expm1()函数
R 语言中的expm1()
函数用于计算指数负 1 即exp()-1 。
Syntax: expm1(x)
Parameters:
a, b: number or number vector
示例 1:
# R program to illustrate
# expm1 function
# Calling the expm1() function
expm1(4) # e5 -1
expm1(10)
expm1(15)
输出:
[1] 53.59815
[1] 22025.47
[1] 3269016
示例 2:
# R program to illustrate
# expm1 function
# Calling the expm1() function
expm1(rep(1:5))
expm1(rep(5:8))
输出:
[1] 1.718282 6.389056 19.085537 53.598150 147.413159
[1] 147.4132 402.4288 1095.6332 2979.9580